parse_allow.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
00030
00031
00032
00033 #include <stdlib.h>
00034 #include <string.h>
00035 #include "../dprint.h"
00036 #include "../mem/mem.h"
00037 #include "parse_allow.h"
00038 #include "parse_methods.h"
00039 #include "msg_parser.h"
00040
00041
00042
00043
00044
00045
00046
00047 int parse_allow(struct sip_msg *msg)
00048 {
00049 unsigned int allow;
00050 struct hdr_field *hdr;
00051 struct allow_body *ab = 0;
00052
00053
00054 if (msg->allow && msg->allow->parsed)
00055 return 0;
00056
00057
00058 if (parse_headers(msg,HDR_EOH_F,0)==-1 || !msg->allow)
00059 return -1;
00060
00061
00062 allow = 0;
00063 for( hdr=msg->allow ; hdr ; hdr=hdr->sibling) {
00064 if (hdr->parsed) {
00065 allow |= ((struct allow_body*)hdr->parsed)->allow;
00066 continue;
00067 }
00068
00069 ab = (struct allow_body*)pkg_malloc(sizeof(struct allow_body));
00070 if (ab == 0) {
00071 LM_ERR("out of pkg_memory\n");
00072 return -1;
00073 }
00074
00075 if (parse_methods(&(hdr->body), &(ab->allow))!=0) {
00076 LM_ERR("bad allow body header\n");
00077 goto error;
00078 }
00079 ab->allow_all = 0;
00080 hdr->parsed = (void*)ab;
00081 allow |= ab->allow;
00082 }
00083
00084 ((struct allow_body*)msg->allow->parsed)->allow_all = allow;
00085 return 0;
00086
00087 error:
00088 if(ab!=0)
00089 pkg_free(ab);
00090 return -1;
00091 }
00092