parses the first line, returns pointer to next line & fills fl; also modifies buffer (to avoid extra copy ops) */
| 1114 | /* parses the first line, returns pointer to next line & fills fl; |
| 1115 | also modifies buffer (to avoid extra copy ops) */ |
| 1116 | char* 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 | */ |
no test coverage detected