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

Function get_hdr_field_aux

parser/msg_parser.c:73–368  ·  view source on GitHub ↗

returns pointer to next header line, and fill hdr_f ; * if at end of header returns pointer to the last crlf (always buf)*/

Source from the content-addressed store, hash-verified

71/* returns pointer to next header line, and fill hdr_f ;
72 * if at end of header returns pointer to the last crlf (always buf)*/
73char* get_hdr_field_aux(char* buf, char* end, struct hdr_field* hdr,int sip_well_known_parse)
74{
75
76 char* tmp;
77 char *match;
78 struct via_body *vb;
79 struct cseq_body* cseq_b;
80 struct to_body* to_b;
81 int integer;
82
83 if ((*buf)=='\n' || (*buf)=='\r'){
84 /* double crlf or lflf or crcr */
85 LM_DBG("found end of header\n");
86 hdr->type=HDR_EOH_T;
87 return buf;
88 }
89
90 tmp=parse_hname(buf, end, hdr);
91 if (hdr->type==HDR_ERROR_T){
92 LM_ERR("bad header\n");
93 goto error_bad_hdr;
94 }
95
96 /* eliminate leading whitespace */
97 tmp=eat_lws_end(tmp, end);
98 if (tmp>=end) {
99 LM_ERR("hf empty\n");
100 goto error_bad_hdr;
101 }
102
103 /* if header-field well-known, parse it, find its end otherwise ;
104 * after leaving the hdr->type switch, tmp should be set to the
105 * next header field
106 */
107 switch(hdr->type){
108 case HDR_VIA_T:
109 /* keep number of vias parsed -- we want to report it in
110 replies for diagnostic purposes */
111 via_cnt++;
112 if (sip_well_known_parse) {
113 vb=pkg_malloc(sizeof(struct via_body));
114 if (vb==0){
115 LM_ERR("out of pkg memory\n");
116 goto error;
117 }
118 memset(vb,0,sizeof(struct via_body));
119 hdr->body.s=tmp;
120 tmp=parse_via(tmp, end, vb);
121 if (vb->error==PARSE_ERROR){
122 LM_ERR("bad via\n");
123 free_via_list(vb);
124 set_err_info(OSER_EC_PARSER, OSER_EL_MEDIUM,
125 "error parsing Via");
126 set_err_reply(400, "bad Via header");
127 goto error;
128 }
129 hdr->parsed=vb;
130 vb->hdr.s=hdr->name.s;

Callers 1

parse_headers_auxFunction · 0.85

Calls 9

eat_lws_endFunction · 0.85
parse_viaFunction · 0.85
free_via_listFunction · 0.85
set_err_infoFunction · 0.85
set_err_replyFunction · 0.85
q_memchrFunction · 0.85
parse_cseqFunction · 0.85
parse_toFunction · 0.85
parse_content_lengthFunction · 0.85

Tested by

no test coverage detected