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

Function parse_aaa_avps

modules/auth_db/aaa_avps.h:69–172  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

67
68
69static inline int parse_aaa_avps(char *definition,
70 struct aaa_avp **avp_def, int *cnt)
71{
72 struct aaa_avp *avp;
73 int avp_name = -1;
74 pv_spec_t avp_spec;
75 str foo;
76 char *p;
77 char *e;
78 char *s;
79 char t;
80
81 p = definition;
82 *avp_def = 0;
83 *cnt = 0;
84
85 if (p==0 || *p==0)
86 return 0;
87
88 /* get element by element */
89 while ( (e=strchr(p,';'))!=0 || (e=p+strlen(p))!=p ) {
90 /* new aaa_avp struct */
91 if ( (avp=(struct aaa_avp*)pkg_malloc(sizeof(struct aaa_avp)))==0 ) {
92 LM_ERR("no more pkg mem\n");
93 goto error;
94 }
95 memset( avp, 0, sizeof(struct aaa_avp));
96 /* definition is between p and e */
97 if ( (s=strchr(p,'='))!=0 && s<e ) {
98 /* avp = attr */
99 foo.s = p;
100 foo.len = s-p;
101 trim( &foo );
102 if (foo.len==0)
103 goto parse_error;
104 t = foo.s[foo.len];
105 foo.s[foo.len] = '\0';
106
107 if (pv_parse_spec(&foo, &avp_spec)==0
108 || avp_spec.type!=PVT_AVP) {
109 LM_ERR("malformed or non AVP %s AVP definition\n", foo.s);
110 goto parse_error;;
111 }
112
113 if(pv_get_avp_name(0, &(avp_spec.pvp), &avp_name,
114 &avp->avp_type)!=0)
115 {
116 LM_ERR("[%s]- invalid AVP definition\n", foo.s);
117 goto parse_error;
118 }
119 foo.s[foo.len] = t;
120
121 /* copy the avp name into the avp structure */
122 avp->avp_name = avp_name;
123 /* go to after the equal sign */
124 p = s+1;
125 }
126 /* attr - is between p and e*/

Callers 1

mod_initFunction · 0.85

Calls 6

trimFunction · 0.85
pv_parse_specFunction · 0.85
pv_get_avp_nameFunction · 0.85
parse_avp_specFunction · 0.85
free_aaa_avpFunction · 0.85
free_aaa_avp_listFunction · 0.85

Tested by

no test coverage detected