parse_cseq.c
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029 #include "parse_cseq.h"
00030 #include "parser_f.h"
00031 #include "../dprint.h"
00032 #include "parse_def.h"
00033 #include "parse_methods.h"
00034 #include "../mem/mem.h"
00035
00036
00037
00038
00039 char* parse_cseq(char *buf, char* end, struct cseq_body* cb)
00040 {
00041 char *t, *m, *m_end;
00042
00043 cb->error=PARSE_ERROR;
00044 t=buf;
00045
00046 cb->number.s=t;
00047 t=eat_token_end(t, end);
00048 if (t>=end) goto error;
00049 cb->number.len=t-cb->number.s;
00050
00051 m=eat_space_end(t, end);
00052 m_end=eat_token_end(m, end);
00053
00054 if (m_end>=end) {
00055 LM_ERR("method terminated unexpectedly\n");
00056 goto error;
00057 }
00058 if (m_end==m){
00059
00060 LM_ERR("no method found\n");
00061 goto error;
00062 }
00063 cb->method.s=m;
00064 t=m_end;
00065 cb->method.len=t-cb->method.s;
00066
00067
00068 if(parse_method(cb->method.s, t, (unsigned int*)&cb->method_id)==0)
00069 {
00070 LM_ERR("cannot parse the method\n");
00071 goto error;
00072 }
00073
00074
00075
00076
00077 t=eat_lws_end(t, end);
00078
00079 if (t>=end) {
00080 LM_ERR("strange EoHF\n");
00081 goto error;
00082 }
00083 if (*t=='\r' && t+1<end && *(t+1)=='\n') {
00084 cb->error=PARSE_OK;
00085 return t+2;
00086 }
00087 if (*t=='\n') {
00088 cb->error=PARSE_OK;
00089 return t+1;
00090 }
00091 LM_ERR("expecting CSeq EoL\n");
00092
00093 error:
00094 LM_ERR("bad cseq\n");
00095 return t;
00096 }
00097
00098
00099 void free_cseq(struct cseq_body* cb)
00100 {
00101 pkg_free(cb);
00102 }