| 36 | */ |
| 37 | |
| 38 | char* parse_cseq(char *buf, char* end, struct cseq_body* cb) |
| 39 | { |
| 40 | char *t, *m, *m_end; |
| 41 | |
| 42 | cb->error=PARSE_ERROR; |
| 43 | t=buf; |
| 44 | |
| 45 | cb->number.s=t; |
| 46 | t=eat_token_end(t, end); |
| 47 | if (t>=end) goto error; |
| 48 | cb->number.len=t-cb->number.s; |
| 49 | |
| 50 | m=eat_space_end(t, end); |
| 51 | m_end=eat_token_end(m, end); |
| 52 | |
| 53 | if (m_end>=end) { |
| 54 | LM_ERR("method terminated unexpectedly\n"); |
| 55 | goto error; |
| 56 | } |
| 57 | if (m_end==m){ |
| 58 | /* null method*/ |
| 59 | LM_ERR("no method found\n"); |
| 60 | goto error; |
| 61 | } |
| 62 | cb->method.s=m; |
| 63 | t=m_end; |
| 64 | cb->method.len=t-cb->method.s; |
| 65 | |
| 66 | /* cache the method id */ |
| 67 | if(parse_method(cb->method.s, t, (unsigned int*)&cb->method_id)==0) |
| 68 | { |
| 69 | LM_ERR("cannot parse the method\n"); |
| 70 | goto error; |
| 71 | } |
| 72 | |
| 73 | /* there may be trailing LWS |
| 74 | * (it was not my idea to put it in SIP; -jiri ) |
| 75 | */ |
| 76 | t=eat_lws_end(t, end); |
| 77 | /*check if the header ends here*/ |
| 78 | if (t>=end) { |
| 79 | LM_ERR("strange EoHF\n"); |
| 80 | goto error; |
| 81 | } |
| 82 | if (*t=='\r' && t+1<end && *(t+1)=='\n') { |
| 83 | cb->error=PARSE_OK; |
| 84 | return t+2; |
| 85 | } |
| 86 | if (*t=='\n') { |
| 87 | cb->error=PARSE_OK; |
| 88 | return t+1; |
| 89 | } |
| 90 | LM_ERR("expecting CSeq EoL\n"); |
| 91 | |
| 92 | error: |
| 93 | LM_ERR("bad cseq\n"); |
| 94 | return t; |
| 95 | } |
no test coverage detected