| 804 | |
| 805 | |
| 806 | static int cpl_process_register(struct sip_msg* msg, int no_rpl) |
| 807 | { |
| 808 | struct disposition *disp; |
| 809 | struct disposition_param *param; |
| 810 | int ret; |
| 811 | int mime; |
| 812 | int *mimes; |
| 813 | |
| 814 | /* make sure that is a REGISTER ??? */ |
| 815 | |
| 816 | /* here should be the CONTACT- hack */ |
| 817 | |
| 818 | /* is there a CONTENT-TYPE hdr ? */ |
| 819 | mime = parse_content_type_hdr( msg ); |
| 820 | if (mime==-1) |
| 821 | goto error; |
| 822 | |
| 823 | /* check the mime type */ |
| 824 | LM_DBG("Content-Type mime found %u, %u\n", |
| 825 | mime>>16,mime&0x00ff); |
| 826 | if ( mime && mime==(TYPE_APPLICATION<<16)+SUBTYPE_CPLXML ) { |
| 827 | /* can be an upload or remove -> check for the content-purpose and |
| 828 | * content-action headers */ |
| 829 | LM_DBG("carrying CPL -> look at Content-Disposition\n"); |
| 830 | if (parse_content_disposition( msg )!=0) { |
| 831 | LM_ERR("Content-Disposition missing or corrupted\n"); |
| 832 | goto error; |
| 833 | } |
| 834 | disp = get_content_disposition(msg); |
| 835 | print_disposition( disp ); /* just for DEBUG */ |
| 836 | /* check if the type of disposition is SCRIPT */ |
| 837 | if (disp->type.len!=CPL_SCRIPT_LEN || |
| 838 | strncasecmp(disp->type.s,CPL_SCRIPT,CPL_SCRIPT_LEN) ) { |
| 839 | LM_ERR("bogus message - Content-Type" |
| 840 | "says CPL_SCRIPT, but Content-Disposition something else\n"); |
| 841 | goto error; |
| 842 | } |
| 843 | /* disposition type is OK -> look for action parameter */ |
| 844 | for(param=disp->params;param;param=param->next) { |
| 845 | if (param->name.len==ACTION_PARAM_LEN && |
| 846 | !strncasecmp(param->name.s,ACTION_PARAM,ACTION_PARAM_LEN)) |
| 847 | break; |
| 848 | } |
| 849 | if (param==0) { |
| 850 | LM_ERR("bogus message - " |
| 851 | "Content-Disposition has no action param\n"); |
| 852 | goto error; |
| 853 | } |
| 854 | /* action param found -> check its value: store or remove */ |
| 855 | if (param->body.len==STORE_ACTION_LEN && |
| 856 | !strncasecmp( param->body.s, STORE_ACTION, STORE_ACTION_LEN)) { |
| 857 | /* it's a store action -> get the script from body message and store |
| 858 | * it into database (CPL and BINARY format) */ |
| 859 | if (do_script_action( msg, STORE_SCRIPT)==-1) |
| 860 | goto error; |
| 861 | } else |
| 862 | if (param->body.len==REMOVE_ACTION_LEN && |
| 863 | !strncasecmp( param->body.s, REMOVE_ACTION, REMOVE_ACTION_LEN)) { |
no test coverage detected