int parse_identityinfo_header(struct sip_msg *msg) { struct identityinfo_body* identityinfo_b; if ( !msg->identity_info && (parse_headers(msg,HDR_IDENTITY_INFO_F,0)==-1 || !msg->identity_info) ) { LM_ERR("bad msg or missing IDENTITY-INFO header\n"); goto error; } /* maybe the header is already parsed! */ if (msg->identity_info->parsed) return 0; identityinfo_b=pkg_malloc(sizeof(*identityinfo_b)); if (identityinfo_b==0){ LOG(L_ERR, "ERROR:parse_identityinfo_header: out of memory\n"); goto error; } memset(identityinfo_b, 0, sizeof(*identityinfo_b)); parse_identityinfo(msg->identity_info->body.s, msg->identity_info->body.s + msg->identity_info->body.len+1, identityinfo_b); if (identityinfo_b->error==PARSE_ERROR){ free_identityinfo(identityinfo_b); goto error; } msg->identity_info->parsed=(void*)identityinfo_b; return 0; error: return -1; }
/** Frees a hdr_field structure. * WARNING: it frees only parsed (and not name.s, body.s) */ void clean_hdr_field(struct hdr_field* const hf) { void** h_parsed; if (hf->parsed){ h_parsed=&hf->parsed; /* strict aliasing warnings workarround */ switch(hf->type){ /* headers with pkg alloc for parsed structure (alphabetic order) */ case HDR_ACCEPT_T: pkg_free(hf->parsed); break; case HDR_ALLOW_T: free_allow_header(hf); break; case HDR_AUTHORIZATION_T: free_credentials((auth_body_t**)h_parsed); break; case HDR_CONTACT_T: free_contact((contact_body_t**)h_parsed); break; case HDR_CONTENTDISPOSITION_T: free_disposition( ((struct disposition**)h_parsed)); break; case HDR_CSEQ_T: free_cseq(hf->parsed); break; case HDR_DATE_T: free_date(hf->parsed); break; case HDR_DIVERSION_T: free_to(hf->parsed); break; case HDR_EVENT_T: free_event((event_t**)h_parsed); break; case HDR_EXPIRES_T: free_expires((exp_body_t**)h_parsed); break; case HDR_FROM_T: free_to(hf->parsed); break; case HDR_IDENTITY_INFO_T: free_identityinfo(hf->parsed); break; case HDR_IDENTITY_T: free_identity(hf->parsed); break; case HDR_PAI_T: free_pai_ppi_body(hf->parsed); break; case HDR_PPI_T: free_pai_ppi_body(hf->parsed); break; case HDR_PROXYAUTH_T: free_credentials((auth_body_t**)h_parsed); break; case HDR_RECORDROUTE_T: free_rr((rr_t**)h_parsed); break; case HDR_REFER_TO_T: free_to(hf->parsed); break; case HDR_ROUTE_T: free_rr((rr_t**)h_parsed); break; case HDR_RPID_T: free_to(hf->parsed); break; case HDR_SESSIONEXPIRES_T: hdr_free_parsed(h_parsed); break; case HDR_SIPIFMATCH_T: free_sipifmatch((str **)h_parsed); break; case HDR_SUBSCRIPTION_STATE_T: free_subscription_state((subscription_state_t**)h_parsed); break; case HDR_SUPPORTED_T: hdr_free_parsed(h_parsed); break; case HDR_TO_T: free_to(hf->parsed); break; case HDR_VIA_T: free_via_list(hf->parsed); break; /* headers with no alloc for parsed structure */ case HDR_CALLID_T: case HDR_MAXFORWARDS_T: case HDR_CONTENTTYPE_T: case HDR_CONTENTLENGTH_T: case HDR_RETRY_AFTER_T: case HDR_REQUIRE_T: case HDR_PROXYREQUIRE_T: case HDR_UNSUPPORTED_T: case HDR_ACCEPTLANGUAGE_T: case HDR_ORGANIZATION_T: case HDR_PRIORITY_T: case HDR_SUBJECT_T: case HDR_USERAGENT_T: case HDR_SERVER_T: case HDR_MIN_SE_T: case HDR_ACCEPTCONTACT_T: case HDR_ALLOWEVENTS_T: case HDR_CONTENTENCODING_T: case HDR_REFERREDBY_T: case HDR_REJECTCONTACT_T: case HDR_REQUESTDISPOSITION_T: case HDR_WWW_AUTHENTICATE_T: case HDR_PROXY_AUTHENTICATE_T: case HDR_PATH_T: case HDR_PRIVACY_T: case HDR_REASON_T: break; default: LOG(L_CRIT, "BUG: clean_hdr_field: unknown header type %d\n", hf->type); break; } } }