MCPcopy Create free account
hub / github.com/OpenSIPS/opensips / parse_headers_aux

Function parse_headers_aux

parser/msg_parser.c:382–658  ·  view source on GitHub ↗

parse the headers and adds them to msg->headers and msg->to, from etc. * It stops when all the headers requested in flags were parsed, on error * (bad header) or end of headers */ note: it continues where it previously stopped and goes ahead until end is encountered or desired HFs are found; if you call it twice for the same HF which is present only once, it will fail the second time; i

Source from the content-addressed store, hash-verified

380 look at check_transaction_quadruple
381*/
382int parse_headers_aux(struct sip_msg* msg, hdr_flags_t flags, int next, int sip_well_known_parse)
383{
384 struct hdr_field *hf;
385 char* tmp;
386 char* rest;
387 char* end;
388 hdr_flags_t orig_flag;
389
390#define link_sibling_hdr(_hook, _hdr) _add_last(_hdr, msg->_hook, sibling)
391
392 end=msg->buf+msg->len;
393 tmp=msg->unparsed;
394
395 if (next) {
396 orig_flag = msg->parsed_flag;
397 msg->parsed_flag &= ~flags;
398 }else
399 orig_flag=0;
400
401 LM_DBG("flags=%llx\n", (unsigned long long)flags);
402 while( tmp<end && (flags & msg->parsed_flag) != flags){
403 hf=pkg_malloc(sizeof(struct hdr_field));
404 if (hf==0){
405 ser_error=E_OUT_OF_MEM;
406 LM_ERR("pkg memory allocation failed\n");
407 goto error;
408 }
409 memset(hf,0, sizeof(struct hdr_field));
410 hf->type=HDR_ERROR_T;
411 rest=get_hdr_field_aux(tmp, msg->buf+msg->len, hf,sip_well_known_parse);
412 switch (hf->type){
413 case HDR_ERROR_T:
414 LM_INFO("bad header field\n");
415 goto error;
416 case HDR_EOH_T:
417 msg->eoh=tmp; /* or rest?*/
418 msg->parsed_flag|=HDR_EOH_F;
419 pkg_free(hf);
420 goto skip;
421 case HDR_OTHER_T: /*do nothing*/
422 case HDR_TO_PATH_T:
423 case HDR_FROM_PATH_T:
424 case HDR_MESSAGE_ID_T:
425 case HDR_BYTE_RANGE_T:
426 case HDR_FAILURE_REPORT_T:
427 case HDR_SUCCESS_REPORT_T:
428 case HDR_STATUS_T:
429 case HDR_USE_PATH_T:
430 break;
431 case HDR_CALLID_T:
432 if (msg->callid==0) msg->callid=hf;
433 msg->parsed_flag|=HDR_CALLID_F;
434 break;
435 case HDR_TO_T:
436 if (msg->to==0) msg->to=hf;
437 msg->parsed_flag|=HDR_TO_F;
438 break;
439 case HDR_CSEQ_T:

Callers 2

ws_parse_req_handshakeFunction · 0.85
ws_parse_rpl_handshakeFunction · 0.85

Calls 1

get_hdr_field_auxFunction · 0.85

Tested by

no test coverage detected