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

Function parse_first_line

parser/parse_fline.c:1116–1288  ·  view source on GitHub ↗

parses the first line, returns pointer to next line & fills fl; also modifies buffer (to avoid extra copy ops) */

Source from the content-addressed store, hash-verified

1114/* parses the first line, returns pointer to next line & fills fl;
1115 also modifies buffer (to avoid extra copy ops) */
1116char* parse_first_line(char* buffer, unsigned int len, struct msg_start * fl)
1117{
1118
1119 char *tmp;
1120 char* second;
1121 char* third;
1122 char* nl;
1123 unsigned int offset;
1124 /* int l; */
1125 char* end;
1126 char s1,s2,s3;
1127 char *prn;
1128 unsigned int t;
1129
1130 /* grammar:
1131 request = method SP uri SP version CRLF
1132 response = version SP status SP reason CRLF
1133 (version = "SIP/2.0")
1134 */
1135
1136
1137 end=buffer+len;
1138 /* see if it's a reply (status) */
1139
1140 /* jku -- parse well-known methods */
1141
1142 /* drop messages which are so short they are for sure useless;
1143 utilize knowledge of minimum size in parsing the first
1144 token
1145 */
1146 if (len <=16 ) {
1147 LM_INFO("message too short: %d\n", len);
1148 goto error1;
1149 }
1150
1151 tmp=buffer;
1152 /* is it perhaps a reply, ie does it start with "SIP...." ? */
1153 if ( (*tmp=='S' || *tmp=='s') &&
1154 strncasecmp( tmp+1, (char *)SIP_VERSION+1, SIP_VERSION_LEN-1)==0 &&
1155 (*(tmp+SIP_VERSION_LEN)==' ')) {
1156 fl->type=SIP_REPLY;
1157 fl->u.reply.version.len=SIP_VERSION_LEN;
1158 tmp=buffer+SIP_VERSION_LEN;
1159 } else IFISMETHOD( INVITE, 'I' )
1160 else IFISMETHOD( CANCEL, 'C')
1161 else IFISMETHOD( ACK, 'A' )
1162 else IFISMETHOD( BYE, 'B' )
1163 else IFISMETHOD( INFO, 'I' )
1164 /* if you want to add another method XXX, include METHOD_XXX in
1165 H-file (this is the value which you will take later in
1166 processing and define XXX_LEN as length of method name;
1167 then just call IFISMETHOD( XXX, 'X' ) ... 'X' is the first
1168 latter; everything must be capitals
1169 */
1170 else {
1171 /* neither reply, nor any of known method requests,
1172 let's believe it is an unknown method request
1173 */

Callers 2

proto_ipsec_sendFunction · 0.85
parse_msg_optFunction · 0.85

Calls 6

eat_token_endFunction · 0.85
parse_methodFunction · 0.85
eat_space_endFunction · 0.85
is_empty_endFunction · 0.85
eat_token2_endFunction · 0.85
eat_lineFunction · 0.85

Tested by

no test coverage detected