git-svn-id: https://openser.svn.sourceforge.net/svnroot/openser/trunk@2802 689a6050-402a-0410-94f2-e92a70836424
... | ... |
@@ -56,12 +56,12 @@ static inline int get_uri_user(struct sip_msg* _m, str** _uri_user) |
56 | 56 |
if ((REQ_LINE(_m).method.len == 8) && |
57 | 57 |
(memcmp(REQ_LINE(_m).method.s, "REGISTER", 8) == 0)) { |
58 | 58 |
if ((puri=parse_to_uri(_m))==NULL) { |
59 |
- LOG(L_ERR, "get_uri_user(): Error while parsing To header\n"); |
|
59 |
+ LM_ERR("failed to parse To header\n"); |
|
60 | 60 |
return -1; |
61 | 61 |
} |
62 | 62 |
} else { |
63 | 63 |
if ((puri=parse_from_uri(_m))==NULL) { |
64 |
- LOG(L_ERR, "get_uri_user(): Error while parsing From header\n"); |
|
64 |
+ LM_ERR("parsing From header\n"); |
|
65 | 65 |
return -1; |
66 | 66 |
} |
67 | 67 |
} |
... | ... |
@@ -89,7 +89,7 @@ static inline int authorize(struct sip_msg* _msg, pv_elem_t* _realm, |
89 | 89 |
/* get pre_auth domain from _realm pvar (if exists) */ |
90 | 90 |
if (_realm) { |
91 | 91 |
if (pv_printf_s(_msg, _realm, &domain)!=0) { |
92 |
- LOG(L_ERR,"ERROR:auth_radius:authorize: pv_printf_s failed\n"); |
|
92 |
+ LM_ERR("pv_printf_s failed\n"); |
|
93 | 93 |
return AUTH_ERROR; |
94 | 94 |
} |
95 | 95 |
} else { |
... | ... |
@@ -114,23 +114,21 @@ static inline int authorize(struct sip_msg* _msg, pv_elem_t* _realm, |
114 | 114 |
&_msg->first_line.u.request.method, |
115 | 115 |
&pv_val.rs); |
116 | 116 |
} else { |
117 |
- LOG(L_ERR, "ERROR:auth_radius:authorize: " |
|
118 |
- "uri_user pvar value is not string\n"); |
|
117 |
+ LM_ERR("uri_user pvar value is not string\n"); |
|
119 | 118 |
return AUTH_ERROR; |
120 | 119 |
} |
121 | 120 |
} else { |
122 |
- LOG(L_ERR, "ERROR:auth_radius:authorize: " |
|
123 |
- "cannot get uri_user pvar value\n"); |
|
121 |
+ LM_ERR("cannot get uri_user pvar value\n"); |
|
124 | 122 |
return AUTH_ERROR; |
125 | 123 |
} |
126 | 124 |
} else { |
127 | 125 |
if (get_uri_user(_msg, &uri_user) < 0) { |
128 |
- LOG(L_ERR, "authorize(): To/From URI not found\n"); |
|
126 |
+ LM_ERR("To/From URI not found\n"); |
|
129 | 127 |
return AUTH_ERROR; |
130 | 128 |
} |
131 | 129 |
user.s = (char *)pkg_malloc(uri_user->len); |
132 | 130 |
if (user.s == NULL) { |
133 |
- LOG(L_ERR, "authorize: No memory left for user\n"); |
|
131 |
+ LM_ERR("no pkg memory left for user\n"); |
|
134 | 132 |
return AUTH_ERROR; |
135 | 133 |
} |
136 | 134 |
un_escape(uri_user, &user); |
... | ... |
@@ -114,7 +114,7 @@ static int mod_init(void) |
114 | 114 |
DICT_VENDOR *vend; |
115 | 115 |
bind_auth_t bind_auth; |
116 | 116 |
|
117 |
- DBG("auth_radius - Initializing\n"); |
|
117 |
+ LM_INFO("initializing...\n"); |
|
118 | 118 |
|
119 | 119 |
memset(attrs, 0, sizeof(attrs)); |
120 | 120 |
memset(vals, 0, sizeof(vals)); |
... | ... |
@@ -137,30 +137,29 @@ static int mod_init(void) |
137 | 137 |
vals[V_SIP_SESSION].n = "Sip-Session"; |
138 | 138 |
|
139 | 139 |
if ((rh = rc_read_config(radius_config)) == NULL) { |
140 |
- LOG(L_ERR, "auth_radius: Error opening configuration file \n"); |
|
140 |
+ LM_ERR("failed to open configuration file \n"); |
|
141 | 141 |
return -1; |
142 | 142 |
} |
143 | 143 |
|
144 | 144 |
if (rc_read_dictionary(rh, rc_conf_str(rh, "dictionary")) != 0) { |
145 |
- LOG(L_ERR, "auth_radius: Error opening dictionary file \n"); |
|
145 |
+ LM_ERR("failed to open dictionary file \n"); |
|
146 | 146 |
return -2; |
147 | 147 |
} |
148 | 148 |
|
149 | 149 |
vend = rc_dict_findvend(rh, "Cisco"); |
150 | 150 |
if (vend == NULL) { |
151 |
- DBG("auth_radius: No `Cisco' vendor in Radius " |
|
152 |
- "dictionary\n"); |
|
151 |
+ LM_DBG("no `Cisco' vendor in Radius dictionary\n"); |
|
153 | 152 |
attrs[A_CISCO_AVPAIR].n = NULL; |
154 | 153 |
} |
155 | 154 |
|
156 | 155 |
bind_auth = (bind_auth_t)find_export("bind_auth", 0, 0); |
157 | 156 |
if (!bind_auth) { |
158 |
- LOG(L_ERR, "auth_radius: Unable to find bind_auth function\n"); |
|
157 |
+ LM_ERR("unable to find bind_auth function\n"); |
|
159 | 158 |
return -1; |
160 | 159 |
} |
161 | 160 |
|
162 | 161 |
if (bind_auth(&auth_api) < 0) { |
163 |
- LOG(L_ERR, "auth_radius: Cannot bind to auth module\n"); |
|
162 |
+ LM_ERR("cannot bind to auth module\n"); |
|
164 | 163 |
return -4; |
165 | 164 |
} |
166 | 165 |
|
... | ... |
@@ -190,8 +189,7 @@ static int auth_fixup(void** param, int param_no) |
190 | 189 |
} else { |
191 | 190 |
s.len = strlen(s.s); |
192 | 191 |
if (pv_parse_format(&s,&model)<0) { |
193 |
- LOG(L_ERR, "ERROR:auth_radius:auth_fixup: " |
|
194 |
- "pv_parse_format failed\n"); |
|
192 |
+ LM_ERR("pv_parse_format failed\n"); |
|
195 | 193 |
return E_OUT_OF_MEM; |
196 | 194 |
} |
197 | 195 |
} |
... | ... |
@@ -201,21 +199,18 @@ static int auth_fixup(void** param, int param_no) |
201 | 199 |
if (param_no == 2) { /* URI user (a pvar) */ |
202 | 200 |
sp = (pv_spec_t*)pkg_malloc(sizeof(pv_spec_t)); |
203 | 201 |
if (sp == 0) { |
204 |
- LOG(L_ERR, "ERROR:auth_radius:auth_fixup(): " |
|
205 |
- "no pkg memory left\n"); |
|
202 |
+ LM_ERR("no pkg memory left\n"); |
|
206 | 203 |
return -1; |
207 | 204 |
} |
208 | 205 |
s.s = (char*)*param; |
209 | 206 |
s.len = strlen(s.s); |
210 | 207 |
if (pv_parse_spec(&s, sp) == 0) { |
211 |
- LOG(L_ERR,"ERROR:auth_radius:auth_fixup(): parsing of " |
|
212 |
- "pseudo variable %s failed!\n", (char*)*param); |
|
208 |
+ LM_ERR("parsing of pseudo variable %s failed!\n", (char*)*param); |
|
213 | 209 |
pkg_free(sp); |
214 | 210 |
return -1; |
215 | 211 |
} |
216 | 212 |
if (sp->type == PVT_NULL) { |
217 |
- LOG(L_ERR,"ERROR:auth_radius:auth_fixup(): bad pseudo " |
|
218 |
- "variable\n"); |
|
213 |
+ LM_ERR("bad pseudo variable\n"); |
|
219 | 214 |
pkg_free(sp); |
220 | 215 |
return -1; |
221 | 216 |
} |
... | ... |
@@ -58,8 +58,7 @@ static inline int extract_avp(VALUE_PAIR* vp, unsigned short *flags, |
58 | 58 |
p = vp->strvalue; |
59 | 59 |
end = vp->strvalue + vp->lvalue; |
60 | 60 |
|
61 |
- DBG("DEBUG:auth_radius:extract_avp: string is <%.*s>\n", |
|
62 |
- (int)(long)(end-p), p); |
|
61 |
+ LM_DBG("string is <%.*s>\n", (int)(long)(end-p), p); |
|
63 | 62 |
|
64 | 63 |
/* get name */ |
65 | 64 |
if (*p!='#') { |
... | ... |
@@ -74,12 +73,11 @@ static inline int extract_avp(VALUE_PAIR* vp, unsigned short *flags, |
74 | 73 |
while( p<end && *p!=':' && *p!='#') |
75 | 74 |
p++; |
76 | 75 |
if (names.s==p || p==end) { |
77 |
- LOG(L_ERR,"ERROR:auth_radius:extract_avp: empty AVP name\n"); |
|
76 |
+ LM_ERR("empty AVP name\n"); |
|
78 | 77 |
goto error; |
79 | 78 |
} |
80 | 79 |
names.len = p - names.s; |
81 |
- DBG("DEBUG:auth_radius:extract_avp: AVP name is <%.*s>\n", |
|
82 |
- names.len, names.s); |
|
80 |
+ LM_DBG("AVP name is <%.*s>\n", names.len, names.s); |
|
83 | 81 |
|
84 | 82 |
/* get value */ |
85 | 83 |
if (*p!='#') { |
... | ... |
@@ -89,17 +87,15 @@ static inline int extract_avp(VALUE_PAIR* vp, unsigned short *flags, |
89 | 87 |
values.s = ++p; |
90 | 88 |
values.len = end-values.s; |
91 | 89 |
if (values.len==0) { |
92 |
- LOG(L_ERR,"ERROR:auth_radius:extract_avp: empty AVP value\n"); |
|
90 |
+ LM_ERR("empty AVP value\n"); |
|
93 | 91 |
goto error; |
94 | 92 |
} |
95 |
- DBG("DEBUG:auth_radius:extract_avp: AVP val is <%.*s>\n", |
|
96 |
- values.len, values.s); |
|
93 |
+ LM_DBG("AVP val is <%.*s>\n", values.len, values.s); |
|
97 | 94 |
|
98 | 95 |
if ( !((*flags)&AVP_NAME_STR) ) { |
99 | 96 |
/* convert name to id*/ |
100 | 97 |
if (str2int(&names,&r)!=0 ) { |
101 |
- LOG(L_ERR,"ERROR:auth_radius:extract_avp: invalid AVP ID '%.*s'\n", |
|
102 |
- names.len,names.s); |
|
98 |
+ LM_ERR("invalid AVP ID '%.*s'\n", names.len,names.s); |
|
103 | 99 |
goto error; |
104 | 100 |
} |
105 | 101 |
name->n = (int)r; |
... | ... |
@@ -110,8 +106,7 @@ static inline int extract_avp(VALUE_PAIR* vp, unsigned short *flags, |
110 | 106 |
if ( !((*flags)&AVP_VAL_STR) ) { |
111 | 107 |
/* convert value to integer */ |
112 | 108 |
if (str2int(&values,&r)!=0 ) { |
113 |
- LOG(L_ERR,"ERROR:auth_radius:extract_avp: invalid AVP numrical " |
|
114 |
- "value '%.*s'\n", values.len,values.s); |
|
109 |
+ LM_ERR("invalid AVP numrical value '%.*s'\n", values.len,values.s); |
|
115 | 110 |
goto error; |
116 | 111 |
} |
117 | 112 |
value->n = (int)r; |
... | ... |
@@ -136,19 +131,16 @@ static int generate_avps(VALUE_PAIR* received) |
136 | 131 |
|
137 | 132 |
vp = received; |
138 | 133 |
|
139 |
- DBG("DEBUG:auth_radius:generate_avps: getting SIP AVPs from avpair %d\n", |
|
140 |
- attrs[A_SIP_AVP].v); |
|
134 |
+ LM_DBG("getting SIP AVPs from avpair %d\n", attrs[A_SIP_AVP].v); |
|
141 | 135 |
|
142 | 136 |
for( ; (vp=rc_avpair_get(vp,attrs[A_SIP_AVP].v,0)) ; vp=vp->next) { |
143 | 137 |
flags = 0; |
144 | 138 |
if (extract_avp( vp, &flags, &name, &val)!=0 ) |
145 | 139 |
continue; |
146 | 140 |
if (add_avp( flags, name, val) < 0) { |
147 |
- LOG(L_ERR, "ERROR:auth_radius:generate_avps: Unable to create " |
|
148 |
- "a new AVP\n"); |
|
141 |
+ LM_ERR("unable to create a new AVP\n"); |
|
149 | 142 |
} else { |
150 |
- DBG("DEBUG:auth_radius:generate_avps: " |
|
151 |
- "AVP '%.*s'/%d='%.*s'/%d has been added\n", |
|
143 |
+ LM_DBG("AVP '%.*s'/%d='%.*s'/%d has been added\n", |
|
152 | 144 |
(flags&AVP_NAME_STR)?name.s.len:4, |
153 | 145 |
(flags&AVP_NAME_STR)?name.s.s:"null", |
154 | 146 |
(flags&AVP_NAME_STR)?0:name.n, |
... | ... |
@@ -167,21 +159,19 @@ static int add_cisco_vsa(VALUE_PAIR** send, struct sip_msg* msg) |
167 | 159 |
str callid; |
168 | 160 |
|
169 | 161 |
if (!msg->callid && parse_headers(msg, HDR_CALLID_F, 0) == -1) { |
170 |
- LOG(L_ERR, "ERROR:auth_radius:add_cisco_vsa: Cannot parse " |
|
171 |
- "Call-ID header field\n"); |
|
162 |
+ LM_ERR("cannot parse Call-ID header field\n"); |
|
172 | 163 |
return -1; |
173 | 164 |
} |
174 | 165 |
|
175 | 166 |
if (!msg->callid) { |
176 |
- LOG(L_ERR, "ERROR:auth_radius:add_cisco_vsa: Call-ID header " |
|
177 |
- "field not found\n"); |
|
167 |
+ LM_ERR("call-ID header field not found\n"); |
|
178 | 168 |
return -1; |
179 | 169 |
} |
180 | 170 |
|
181 | 171 |
callid.len = msg->callid->body.len + 8; |
182 | 172 |
callid.s = pkg_malloc(callid.len); |
183 | 173 |
if (callid.s == NULL) { |
184 |
- LOG(L_ERR, "ERROR:auth_radius:add_cisco_vsa: No pkg memory left\n"); |
|
174 |
+ LM_ERR("no pkg memory left\n"); |
|
185 | 175 |
return -1; |
186 | 176 |
} |
187 | 177 |
|
... | ... |
@@ -190,8 +180,7 @@ static int add_cisco_vsa(VALUE_PAIR** send, struct sip_msg* msg) |
190 | 180 |
|
191 | 181 |
if (rc_avpair_add(rh, send, attrs[A_CISCO_AVPAIR].v, callid.s, |
192 | 182 |
callid.len, VENDOR(attrs[A_CISCO_AVPAIR].v)) == 0) { |
193 |
- LOG(L_ERR, "ERROR:auth_radius:add_cisco_vsa: Unable to add " |
|
194 |
- "Cisco-AVPair attribute\n"); |
|
183 |
+ LM_ERR("unable to add Cisco-AVPair attribute\n"); |
|
195 | 184 |
pkg_free(callid.s); |
196 | 185 |
return -1; |
197 | 186 |
} |
... | ... |
@@ -219,8 +208,7 @@ int radius_authorize_sterman(struct sip_msg* _msg, dig_cred_t* _cred, str* _meth |
219 | 208 |
send = received = 0; |
220 | 209 |
|
221 | 210 |
if (!(_cred && _method && _user)) { |
222 |
- LOG(L_ERR, "ERROR:auth_radius:radius_authorize_sterman: " |
|
223 |
- "Invalid parameter value\n"); |
|
211 |
+ LM_ERR("invalid parameter value\n"); |
|
224 | 212 |
return -1; |
225 | 213 |
} |
226 | 214 |
|
... | ... |
@@ -233,16 +221,14 @@ int radius_authorize_sterman(struct sip_msg* _msg, dig_cred_t* _cred, str* _meth |
233 | 221 |
*/ |
234 | 222 |
if (_cred->username.domain.len) { |
235 | 223 |
if (!rc_avpair_add(rh, &send, attrs[A_USER_NAME].v, _cred->username.whole.s, _cred->username.whole.len, 0)) { |
236 |
- LOG(L_ERR, "ERROR:auth_radius:radius_authorize_sterman: Unable " |
|
237 |
- "to add User-Name attribute\n"); |
|
224 |
+ LM_ERR("unable to add User-Name attribute\n"); |
|
238 | 225 |
goto err; |
239 | 226 |
} |
240 | 227 |
} else { |
241 | 228 |
user_name.len = _cred->username.user.len + _cred->realm.len + 1; |
242 | 229 |
user_name.s = pkg_malloc(user_name.len); |
243 | 230 |
if (!user_name.s) { |
244 |
- LOG(L_ERR, "ERROR:auth_radius:radius_authorize_sterman: " |
|
245 |
- "No pkg memory left\n"); |
|
231 |
+ LM_ERR("no pkg memory left\n"); |
|
246 | 232 |
return -3; |
247 | 233 |
} |
248 | 234 |
memcpy(user_name.s, _cred->username.whole.s, _cred->username.whole.len); |
... | ... |
@@ -251,8 +237,7 @@ int radius_authorize_sterman(struct sip_msg* _msg, dig_cred_t* _cred, str* _meth |
251 | 237 |
_cred->realm.len); |
252 | 238 |
if (!rc_avpair_add(rh, &send, attrs[A_USER_NAME].v, user_name.s, |
253 | 239 |
user_name.len, 0)) { |
254 |
- LOG(L_ERR, "ERROR:auth_radius:radius_authorize_sterman: " |
|
255 |
- "Unable to add User-Name attribute\n"); |
|
240 |
+ LM_ERR("unable to add User-Name attribute\n"); |
|
256 | 241 |
pkg_free(user_name.s); |
257 | 242 |
goto err; |
258 | 243 |
} |
... | ... |
@@ -261,34 +246,29 @@ int radius_authorize_sterman(struct sip_msg* _msg, dig_cred_t* _cred, str* _meth |
261 | 246 |
|
262 | 247 |
if (!rc_avpair_add(rh, &send, attrs[A_DIGEST_USER_NAME].v, |
263 | 248 |
_cred->username.whole.s, _cred->username.whole.len, 0)) { |
264 |
- LOG(L_ERR, "ERROR:auth_radius:radius_authorize_sterman: " |
|
265 |
- "Unable to add Digest-User-Name attribute\n"); |
|
249 |
+ LM_ERR("unable to add Digest-User-Name attribute\n"); |
|
266 | 250 |
goto err; |
267 | 251 |
} |
268 | 252 |
|
269 | 253 |
if (!rc_avpair_add(rh, &send, attrs[A_DIGEST_REALM].v, _cred->realm.s, |
270 | 254 |
_cred->realm.len, 0)) { |
271 |
- LOG(L_ERR, "ERROR:auth_radius:radius_authorize_sterman: Unable " |
|
272 |
- "to add Digest-Realm attribute\n"); |
|
255 |
+ LM_ERR("unable to add Digest-Realm attribute\n"); |
|
273 | 256 |
goto err; |
274 | 257 |
} |
275 | 258 |
if (!rc_avpair_add(rh, &send, attrs[A_DIGEST_NONCE].v, _cred->nonce.s, |
276 | 259 |
_cred->nonce.len, 0)) { |
277 |
- LOG(L_ERR, "ERROR:auth_radius:radius_authorize_sterman: Unable " |
|
278 |
- "to add Digest-Nonce attribute\n"); |
|
260 |
+ LM_ERR("unable to add Digest-Nonce attribute\n"); |
|
279 | 261 |
goto err; |
280 | 262 |
} |
281 | 263 |
|
282 | 264 |
if (!rc_avpair_add(rh, &send, attrs[A_DIGEST_URI].v, _cred->uri.s, |
283 | 265 |
_cred->uri.len, 0)) { |
284 |
- LOG(L_ERR, "ERROR:auth_radius:radius_authorize_sterman: Unable " |
|
285 |
- "to add Digest-URI attribute\n"); |
|
266 |
+ LM_ERR("unable to add Digest-URI attribute\n"); |
|
286 | 267 |
goto err; |
287 | 268 |
} |
288 | 269 |
if (!rc_avpair_add(rh, &send, attrs[A_DIGEST_METHOD].v, method.s, |
289 | 270 |
method.len, 0)) { |
290 |
- LOG(L_ERR, "ERROR:auth_radius:radius_authorize_sterman: Unable " |
|
291 |
- "to add Digest-Method attribute\n"); |
|
271 |
+ LM_ERR("unable to add Digest-Method attribute\n"); |
|
292 | 272 |
goto err; |
293 | 273 |
} |
294 | 274 |
|
... | ... |
@@ -297,45 +277,38 @@ int radius_authorize_sterman(struct sip_msg* _msg, dig_cred_t* _cred, str* _meth |
297 | 277 |
*/ |
298 | 278 |
if (_cred->qop.qop_parsed == QOP_AUTH) { |
299 | 279 |
if (!rc_avpair_add(rh, &send, attrs[A_DIGEST_QOP].v, "auth", 4, 0)) { |
300 |
- LOG(L_ERR, "ERROR:auth_radius:radius_authorize_sterman: " |
|
301 |
- "Unable to add Digest-QOP attribute\n"); |
|
280 |
+ LM_ERR("unable to add Digest-QOP attribute\n"); |
|
302 | 281 |
goto err; |
303 | 282 |
} |
304 | 283 |
if (!rc_avpair_add(rh, &send, attrs[A_DIGEST_NONCE_COUNT].v, |
305 | 284 |
_cred->nc.s, _cred->nc.len, 0)) { |
306 |
- LOG(L_ERR, "ERROR:auth_radius:radius_authorize_sterman: Unable " |
|
307 |
- "to add Digest-CNonce-Count attribute\n"); |
|
285 |
+ LM_ERR("unable to add Digest-CNonce-Count attribute\n"); |
|
308 | 286 |
goto err; |
309 | 287 |
} |
310 | 288 |
if (!rc_avpair_add(rh, &send, attrs[A_DIGEST_CNONCE].v, |
311 | 289 |
_cred->cnonce.s, _cred->cnonce.len, 0)) { |
312 |
- LOG(L_ERR, "ERROR:auth_radius:radius_authorize_sterman: Unable " |
|
313 |
- "to add Digest-CNonce attribute\n"); |
|
290 |
+ LM_ERR("unable to add Digest-CNonce attribute\n"); |
|
314 | 291 |
goto err; |
315 | 292 |
} |
316 | 293 |
} else if (_cred->qop.qop_parsed == QOP_AUTHINT) { |
317 | 294 |
if (!rc_avpair_add(rh, &send, attrs[A_DIGEST_QOP].v, |
318 | 295 |
"auth-int", 8, 0)) { |
319 |
- LOG(L_ERR, "ERROR:auth_radius:radius_authorize_sterman: Unable " |
|
320 |
- "to add Digest-QOP attribute\n"); |
|
296 |
+ LM_ERR("unable to add Digest-QOP attribute\n"); |
|
321 | 297 |
goto err; |
322 | 298 |
} |
323 | 299 |
if (!rc_avpair_add(rh, &send, attrs[A_DIGEST_NONCE_COUNT].v, |
324 | 300 |
_cred->nc.s, _cred->nc.len, 0)) { |
325 |
- LOG(L_ERR, "ERROR:auth_radius:radius_authorize_sterman: Unable " |
|
326 |
- "to add Digest-Nonce-Count attribute\n"); |
|
301 |
+ LM_ERR("unable to add Digest-Nonce-Count attribute\n"); |
|
327 | 302 |
goto err; |
328 | 303 |
} |
329 | 304 |
if (!rc_avpair_add(rh, &send, attrs[A_DIGEST_CNONCE].v, |
330 | 305 |
_cred->cnonce.s, _cred->cnonce.len, 0)) { |
331 |
- LOG(L_ERR, "ERROR:auth_radius:radius_authorize_sterman: Unable " |
|
332 |
- "to add Digest-CNonce attribute\n"); |
|
306 |
+ LM_ERR("unable to add Digest-CNonce attribute\n"); |
|
333 | 307 |
goto err; |
334 | 308 |
} |
335 | 309 |
if (!rc_avpair_add(rh, &send, attrs[A_DIGEST_BODY_DIGEST].v, |
336 | 310 |
_cred->opaque.s, _cred->opaque.len, 0)) { |
337 |
- LOG(L_ERR, "ERROR:auth_radius:radius_authorize_sterman: Unable " |
|
338 |
- "to add Digest-Body-Digest attribute\n"); |
|
311 |
+ LM_ERR("unable to add Digest-Body-Digest attribute\n"); |
|
339 | 312 |
goto err; |
340 | 313 |
} |
341 | 314 |
|
... | ... |
@@ -346,22 +319,20 @@ int radius_authorize_sterman(struct sip_msg* _msg, dig_cred_t* _cred, str* _meth |
346 | 319 |
/* Add the response... What to calculate against... */ |
347 | 320 |
if (!rc_avpair_add(rh, &send, attrs[A_DIGEST_RESPONSE].v, |
348 | 321 |
_cred->response.s, _cred->response.len, 0)) { |
349 |
- LOG(L_ERR, "sterman(): Unable to add Digest-Response attribute\n"); |
|
322 |
+ LM_ERR("unable to add Digest-Response attribute\n"); |
|
350 | 323 |
goto err; |
351 | 324 |
} |
352 | 325 |
|
353 | 326 |
/* Indicate the service type, Authenticate only in our case */ |
354 | 327 |
service = vals[V_SIP_SESSION].v; |
355 | 328 |
if (!rc_avpair_add(rh, &send, attrs[A_SERVICE_TYPE].v, &service, -1, 0)) { |
356 |
- LOG(L_ERR, "ERROR:auth_radius:radius_authorize_sterman: Unable to " |
|
357 |
- "add Service-Type attribute\n"); |
|
329 |
+ LM_ERR("unable to add Service-Type attribute\n"); |
|
358 | 330 |
goto err; |
359 | 331 |
} |
360 | 332 |
|
361 | 333 |
/* Add SIP URI as a check item */ |
362 | 334 |
if (!rc_avpair_add(rh,&send,attrs[A_SIP_URI_USER].v,user.s,user.len,0)) { |
363 |
- LOG(L_ERR, "ERROR:auth_radius:radius_authorize_sterman: Unable to " |
|
364 |
- "add Sip-URI-User attribute\n"); |
|
335 |
+ LM_ERR("unable to add Sip-URI-User attribute\n"); |
|
365 | 336 |
goto err; |
366 | 337 |
} |
367 | 338 |
|
... | ... |
@@ -373,7 +344,7 @@ int radius_authorize_sterman(struct sip_msg* _msg, dig_cred_t* _cred, str* _meth |
373 | 344 |
|
374 | 345 |
/* Send request */ |
375 | 346 |
if ((i = rc_auth(rh, SIP_PORT, send, &received, msg)) == OK_RC) { |
376 |
- DBG("DEBUG:auth_radius:radius_authorize_sterman: Success\n"); |
|
347 |
+ LM_DBG("Success\n"); |
|
377 | 348 |
rc_avpair_free(send); |
378 | 349 |
send = 0; |
379 | 350 |
|
... | ... |
@@ -382,8 +353,7 @@ int radius_authorize_sterman(struct sip_msg* _msg, dig_cred_t* _cred, str* _meth |
382 | 353 |
rc_avpair_free(received); |
383 | 354 |
return 1; |
384 | 355 |
} else { |
385 |
- LOG(L_ERR,"ERROR:auth_radius:radius_authorize_sterman: " |
|
386 |
- "rc_auth failed\n"); |
|
356 |
+ LM_ERR("rc_auth failed\n"); |
|
387 | 357 |
goto err; |
388 | 358 |
} |
389 | 359 |
|
... | ... |
@@ -169,6 +169,7 @@ static int reset_gflag(struct sip_msg *bar, char *flag, char *foo) |
169 | 169 |
|
170 | 170 |
static int is_gflag(struct sip_msg *bar, char *flag, char *foo) |
171 | 171 |
{ |
172 |
+ LM_DBG("-------mask %X , flags %X", (*gflags), ((unsigned int)(long)flag)); |
|
172 | 173 |
return ( (*gflags) & ((unsigned int)(long)flag)) ? 1 : -1; |
173 | 174 |
} |
174 | 175 |
|
... | ... |
@@ -67,20 +67,17 @@ static int mi_sock_check(int fd, char* fname); |
67 | 67 |
#define mi_create_dtgram_replysocket(_socketfd,_socket_domain, _err) \ |
68 | 68 |
_socketfd = socket(_socket_domain, SOCK_DGRAM, 0);\ |
69 | 69 |
if (_socketfd == -1) {\ |
70 |
- LOG(L_ERR, "ERROR: datagram_fnc: mi_create_dtgram_replysocket"\ |
|
71 |
- "cannot create socket: %s\n", strerror(errno));\ |
|
70 |
+ LM_ERR("cannot create socket: %s\n", strerror(errno));\ |
|
72 | 71 |
goto _err;\ |
73 | 72 |
}\ |
74 | 73 |
/* Turn non-blocking mode on for tx*/\ |
75 | 74 |
flags = fcntl(_socketfd, F_GETFL);\ |
76 | 75 |
if (flags == -1){\ |
77 |
- LOG(L_ERR, "ERROR: datagram_fnc: mi_create_dtgram_replysocket: "\ |
|
78 |
- "fcntl failed: %s\n", strerror(errno));\ |
|
76 |
+ LM_ERR("fcntl failed: %s\n", strerror(errno));\ |
|
79 | 77 |
goto _err;\ |
80 | 78 |
}\ |
81 | 79 |
if (fcntl(_socketfd, F_SETFL, flags | O_NONBLOCK) == -1) {\ |
82 |
- LOG(L_ERR, "ERROR: datagram_fnc: mi_create_dtgram_replysocket:"\ |
|
83 |
- "fcntl: set non-blocking failed: %s\n", strerror(errno));\ |
|
80 |
+ LM_ERR("fcntl: set non-blocking failed: %s\n", strerror(errno));\ |
|
84 | 81 |
goto _err;\ |
85 | 82 |
} |
86 | 83 |
|
... | ... |
@@ -97,21 +94,18 @@ int mi_init_datagram_server(sockaddr_dtgram *addr, unsigned int socket_domain, |
97 | 94 |
|
98 | 95 |
socks->rx_sock = socket(socket_domain, SOCK_DGRAM, 0); |
99 | 96 |
if (socks->rx_sock == -1) { |
100 |
- LOG(L_ERR, "ERROR: datagram_fnc: mi_init_datagram_server: " |
|
101 |
- "Cannot create RX socket: %s\n", strerror(errno)); |
|
97 |
+ LM_ERR("cannot create RX socket: %s\n", strerror(errno)); |
|
102 | 98 |
return -1; |
103 | 99 |
} |
104 | 100 |
|
105 | 101 |
switch(socket_domain) |
106 | 102 |
{ |
107 | 103 |
case AF_LOCAL: |
108 |
- DBG("DBG:datagram_fnc:mi_init_datagram_server: we have a " |
|
109 |
- "unix socket, socket_name is %s\n",addr->unix_addr.sun_path); |
|
104 |
+ LM_DBG("we have a unix socket: %s\n", addr->unix_addr.sun_path); |
|
110 | 105 |
socket_name = addr->unix_addr.sun_path; |
111 | 106 |
if(bind(socks->rx_sock,(struct sockaddr*)&addr->unix_addr, |
112 | 107 |
SUN_LEN(&addr->unix_addr))< 0) { |
113 |
- LOG(L_ERR, "ERROR: datagram_fnc: mi_init_datagram_server: " |
|
114 |
- "bind: %s\n", strerror(errno)); |
|
108 |
+ LM_ERR("bind: %s\n", strerror(errno)); |
|
115 | 109 |
goto err_rx; |
116 | 110 |
} |
117 | 111 |
if(mi_sock_check(socks->rx_sock, socket_name)!=0) |
... | ... |
@@ -119,18 +113,16 @@ int mi_init_datagram_server(sockaddr_dtgram *addr, unsigned int socket_domain, |
119 | 113 |
/* change permissions */ |
120 | 114 |
if (mode){ |
121 | 115 |
if (chmod(socket_name, mode)<0){ |
122 |
- LOG(L_ERR, "ERROR: datagram_fnc: mi_mod_init: failed to " |
|
123 |
- "change the permissions for %s to %04o: %s[%d]\n", |
|
124 |
- socket_name, mode, strerror(errno), errno); |
|
116 |
+ LM_ERR("failed to change the permissions for %s to %04o:" |
|
117 |
+ "%s[%d]\n",socket_name, mode, strerror(errno), errno); |
|
125 | 118 |
goto err_rx; |
126 | 119 |
} |
127 | 120 |
} |
128 | 121 |
/* change ownership */ |
129 | 122 |
if ((uid!=-1) || (gid!=-1)){ |
130 | 123 |
if (chown(socket_name, uid, gid)<0){ |
131 |
- LOG(L_ERR, "ERROR: datagram_fnc: mi_mod_init: failed to " |
|
132 |
- "change the owner/group for %s to %d.%d; %s[%d]\n", |
|
133 |
- socket_name, uid, gid, strerror(errno), errno); |
|
124 |
+ LM_ERR("failed to change the owner/group for %s to %d.%d;" |
|
125 |
+ "%s[%d]\n",socket_name, uid, gid, strerror(errno), errno); |
|
134 | 126 |
goto err_rx; |
135 | 127 |
} |
136 | 128 |
} |
... | ... |
@@ -139,8 +131,7 @@ int mi_init_datagram_server(sockaddr_dtgram *addr, unsigned int socket_domain, |
139 | 131 |
case AF_INET: |
140 | 132 |
if (bind(socks->rx_sock, (struct sockaddr*)&addr->udp_addr.sin, |
141 | 133 |
sizeof(addr->udp_addr)) < 0) { |
142 |
- LOG(L_ERR, "ERROR: datagram_fnc: mi_init_datagram_server: " |
|
143 |
- "bind: %s\n", strerror(errno)); |
|
134 |
+ LM_ERR("bind: %s\n", strerror(errno)); |
|
144 | 135 |
goto err_rx; |
145 | 136 |
} |
146 | 137 |
break; |
... | ... |
@@ -148,15 +139,13 @@ int mi_init_datagram_server(sockaddr_dtgram *addr, unsigned int socket_domain, |
148 | 139 |
case AF_INET6: |
149 | 140 |
if(bind(socks->rx_sock, (struct sockaddr*)&addr->udp_addr.sin6, |
150 | 141 |
sizeof(addr->udp_addr)) < 0) { |
151 |
- LOG(L_ERR, "ERROR: datagram_fnc: mi_init_datagram_server: " |
|
152 |
- "bind: %s\n", strerror(errno)); |
|
142 |
+ LM_ERR("bind: %s\n", strerror(errno)); |
|
153 | 143 |
goto err_rx; |
154 | 144 |
} |
155 | 145 |
break; |
156 | 146 |
#endif |
157 | 147 |
default: |
158 |
- LOG(L_ERR, "ERROR: mi_datagram: mi_init_datagram_server: domain " |
|
159 |
- "not supported\n"); |
|
148 |
+ LM_ERR("domain not supported\n"); |
|
160 | 149 |
goto err_both; |
161 | 150 |
|
162 | 151 |
} |
... | ... |
@@ -176,8 +165,7 @@ int mi_init_datagram_buffer(void){ |
176 | 165 |
|
177 | 166 |
mi_buf = pkg_malloc(DATAGRAM_SOCK_BUF_SIZE); |
178 | 167 |
if ( mi_buf==NULL) { |
179 |
- LOG(L_ERR,"ERROR:datagram_fnc:mi_init_datagram_server: no more " |
|
180 |
- "pkg memory\n"); |
|
168 |
+ LM_ERR("no more pkg memory\n"); |
|
181 | 169 |
return -1; |
182 | 170 |
} |
183 | 171 |
return 0; |
... | ... |
@@ -193,41 +181,38 @@ int mi_sock_check(int fd, char* fname) |
193 | 181 |
struct stat lst; |
194 | 182 |
|
195 | 183 |
if (fstat(fd, &fst)<0){ |
196 |
- LOG(L_ERR, "ERROR:datagram_fnc:mi_sock_check: fstat failed: %s\n", |
|
184 |
+ LM_ERR("fstat failed: %s\n", |
|
197 | 185 |
strerror(errno)); |
198 | 186 |
return -1; |
199 | 187 |
} |
200 | 188 |
/* check if socket */ |
201 | 189 |
if (!S_ISSOCK(fst.st_mode)){ |
202 |
- LOG(L_ERR, "ERROR:datagram_fnc:mi_sock_check: %s is not a sock\n", |
|
203 |
- fname); |
|
190 |
+ LM_ERR("%s is not a sock\n", fname); |
|
204 | 191 |
return -1; |
205 | 192 |
} |
206 | 193 |
/* check if hard-linked */ |
207 | 194 |
if (fst.st_nlink>1){ |
208 |
- LOG(L_ERR, "ERROR:datagram_fnc:mi_sock_check: security: sock_check: " |
|
209 |
- "%s is hard-linked %d times\n", fname, (unsigned)fst.st_nlink); |
|
195 |
+ LM_ERR("security: sock_check: %s is hard-linked %d times\n", |
|
196 |
+ fname, (unsigned)fst.st_nlink); |
|
210 | 197 |
return -1; |
211 | 198 |
} |
212 | 199 |
|
213 | 200 |
/* lstat to check for soft links */ |
214 | 201 |
if (lstat(fname, &lst)<0){ |
215 |
- LOG(L_ERR, "ERROR:datagram_fnc:mi_sock_check: lstat failed: %s\n", |
|
216 |
- strerror(errno)); |
|
202 |
+ LM_ERR("lstat failed: %s\n", strerror(errno)); |
|
217 | 203 |
return -1; |
218 | 204 |
} |
219 | 205 |
if (S_ISLNK(lst.st_mode)){ |
220 |
- LOG(L_ERR, "ERROR:datagram_fnc:mi_sock_check: security: sock_check: " |
|
221 |
- "%s is a soft link\n", fname); |
|
206 |
+ LM_ERR("security: sock_check: %s is a soft link\n", fname); |
|
222 | 207 |
return -1; |
223 | 208 |
} |
224 | 209 |
/* if this is not a symbolic link, check to see if the inode didn't |
225 | 210 |
* change to avoid possible sym.link, rm sym.link & replace w/ sock race |
226 | 211 |
*/ |
227 |
- /*DBG("for %s lst.st_dev %fl fst.st_dev %i lst.st_ino %i fst.st_ino" |
|
212 |
+ /*LM_DBG("for %s lst.st_dev %fl fst.st_dev %i lst.st_ino %i fst.st_ino" |
|
228 | 213 |
"%i\n", fname, lst.st_dev, fst.st_dev, lst.st_ino, fst.st_ino);*/ |
229 | 214 |
/*if ((lst.st_dev!=fst.st_dev)||(lst.st_ino!=fst.st_ino)){ |
230 |
- LOG(L_ERR, "ERROR:datagram_fnc:mi_sock_check: security: sock_check: " |
|
215 |
+ LM_ERR("security: sock_check: " |
|
231 | 216 |
"socket %s inode/dev number differ: %d %d \n", fname, |
232 | 217 |
(int)fst.st_ino, (int)lst.st_ino); |
233 | 218 |
}*/ |
... | ... |
@@ -245,21 +230,19 @@ static int mi_send_dgram(int fd, char* buf, unsigned int len, |
245 | 230 |
size_t total_len; |
246 | 231 |
total_len = strlen(buf); |
247 | 232 |
|
248 |
- /*DBG("mi_datagram:mi_send_dgram:response is %s \n tolen is %i " |
|
233 |
+ /*LM_DBG("response is %s \n tolen is %i " |
|
249 | 234 |
"and len is %i\n",buf, tolen,len);*/ |
250 | 235 |
|
251 | 236 |
if(total_len == 0 || tolen ==0) |
252 | 237 |
return -1; |
253 |
- DBG("DBG: datagram_fnc: mi_send_dgram: datagram_size is %i\n", |
|
254 |
- DATAGRAM_SOCK_BUF_SIZE); |
|
238 |
+ |
|
255 | 239 |
if (total_len>DATAGRAM_SOCK_BUF_SIZE) |
256 | 240 |
{ |
257 |
- DBG("DBG: datagram_fnc: mi_send_dgram: datagram too big, " |
|
241 |
+ LM_DBG("datagram too big, " |
|
258 | 242 |
"truncking, datagram_size is %i\n",DATAGRAM_SOCK_BUF_SIZE); |
259 | 243 |
len = DATAGRAM_SOCK_BUF_SIZE; |
260 | 244 |
} |
261 |
- /*DBG("DBG:mi_datagram:mi_send_dgram: destination address length " |
|
262 |
- "is %i\n", tolen);*/ |
|
245 |
+ /*LM_DBG("destination address length is %i\n", tolen);*/ |
|
263 | 246 |
n=sendto(fd, buf, len, 0, to, tolen); |
264 | 247 |
return n; |
265 | 248 |
} |
... | ... |
@@ -276,49 +259,45 @@ static int identify_command(datagram_stream * dtgram, struct mi_cmd * *f) |
276 | 259 |
p= dtgram->start; |
277 | 260 |
start = p; |
278 | 261 |
if (!p){ |
279 |
- LOG(L_ERR, "ERR:datagram_fnc:identify_command: null pointer \n"); |
|
262 |
+ LM_ERR("null pointer \n"); |
|
280 | 263 |
return -1; |
281 | 264 |
} |
282 | 265 |
|
283 | 266 |
/*if no command*/ |
284 | 267 |
if ( dtgram->len ==0 ){ |
285 |
- DBG("DBG:datagram_fnc:identify_command:command empty case1 \n"); |
|
268 |
+ LM_DBG("command empty case1 \n"); |
|
286 | 269 |
goto error; |
287 | 270 |
} |
288 | 271 |
if (*p != MI_CMD_SEPARATOR){ |
289 |
- LOG(L_ERR, "ERROR:datagram_fnc:identify_command: command must begin " |
|
290 |
- "with: %c \n", MI_CMD_SEPARATOR); |
|
272 |
+ LM_ERR("command must begin with: %c \n", MI_CMD_SEPARATOR); |
|
291 | 273 |
goto error; |
292 | 274 |
} |
293 | 275 |
command = p+1; |
294 | 276 |
|
295 |
- DBG("DBG:datagram_fnc:identify_command: the command starts here: " |
|
296 |
- "%s\n", command); |
|
277 |
+ LM_DBG("the command starts here: %s\n", command); |
|
297 | 278 |
p=strchr(command, MI_CMD_SEPARATOR ); |
298 | 279 |
if (!p ){ |
299 |
- LOG(L_ERR, "ERROR:datagram_fnc:identify_command: empty command \n"); |
|
280 |
+ LM_ERR("empty command \n"); |
|
300 | 281 |
goto error; |
301 | 282 |
} |
302 | 283 |
if(*(p+1)!='\n'){ |
303 |
- LOG(L_ERR,"ERROR:datagram_fnc:identify_command: the request first line" |
|
304 |
- "is invalid :no newline after the second %c\n",MI_CMD_SEPARATOR); |
|
284 |
+ LM_ERR("the request's first line is invalid :no newline after " |
|
285 |
+ "the second %c\n",MI_CMD_SEPARATOR); |
|
305 | 286 |
goto error; |
306 | 287 |
} |
307 | 288 |
|
308 | 289 |
/* make command zero-terminated */ |
309 | 290 |
*p=0; |
310 |
- DBG("DBG:datagram_fnc:identify_command: the command " |
|
311 |
- "is %s\n",command); |
|
291 |
+ LM_DBG("the command is %s\n",command); |
|
312 | 292 |
/*search for the appropiate command*/ |
313 | 293 |
*f=lookup_mi_cmd( command, p-command); |
314 | 294 |
if(!*f) |
315 | 295 |
goto error; |
316 | 296 |
/*the current offset has changed*/ |
317 |
- DBG("mi_datagram:identify_command: dtgram->len is " |
|
318 |
- "%i\n", dtgram->len); |
|
297 |
+ LM_DBG("dtgram->len is %i\n", dtgram->len); |
|
319 | 298 |
dtgram->current = p+2 ; |
320 | 299 |
dtgram->len -=p+2 - dtgram->start; |
321 |
- DBG("mi_datagram:identify_command: dtgram->len is %i\n",dtgram->len); |
|
300 |
+ LM_DBG("dtgram->len is %i\n",dtgram->len); |
|
322 | 301 |
|
323 | 302 |
return 0; |
324 | 303 |
error: |
... | ... |
@@ -344,8 +323,7 @@ static void datagram_close_async(struct mi_root *mi_rpl,struct mi_handler *hdl, |
344 | 323 |
|
345 | 324 |
p = (my_socket_address *)hdl->param; |
346 | 325 |
|
347 |
- DBG("DEBUG:mi_datagram:datagram_close_async: the socket domain is %i and" |
|
348 |
- "af_local is %i\n", p->domain,AF_LOCAL); |
|
326 |
+ LM_DBG("the socket domain is %i and af_local is %i\n", p->domain,AF_LOCAL); |
|
349 | 327 |
|
350 | 328 |
mi_create_dtgram_replysocket(reply_sock,p->domain, err); |
351 | 329 |
|
... | ... |
@@ -356,19 +334,16 @@ static void datagram_close_async(struct mi_root *mi_rpl,struct mi_handler *hdl, |
356 | 334 |
/*allocate the response datagram*/ |
357 | 335 |
dtgram.start = pkg_malloc(DATAGRAM_SOCK_BUF_SIZE); |
358 | 336 |
if(!dtgram.start){ |
359 |
- LOG(L_ERR, "ERROR: mi_datagram_datagram_close_async: failed" |
|
360 |
- "to allocate the response datagram \n"); |
|
337 |
+ LM_ERR("no more pkg memory\n"); |
|
361 | 338 |
goto err; |
362 | 339 |
} |
363 | 340 |
/*build the response*/ |
364 | 341 |
if(mi_datagram_write_tree(&dtgram , mi_rpl) != 0){ |
365 |
- LOG(L_ERR, "ERROR mi_datagram:datagram_close_async: error" |
|
366 |
- "while building the response \n"); |
|
342 |
+ LM_ERR("failed to build the response \n"); |
|
367 | 343 |
|
368 | 344 |
goto err1; |
369 | 345 |
} |
370 |
- DBG("mi_datagram:close_async: the response is %s", |
|
371 |
- dtgram.start); |
|
346 |
+ LM_DBG("the response is %s", dtgram.start); |
|
372 | 347 |
|
373 | 348 |
/*send the response*/ |
374 | 349 |
ret = mi_send_dgram(reply_sock, dtgram.start, |
... | ... |
@@ -376,12 +351,10 @@ static void datagram_close_async(struct mi_root *mi_rpl,struct mi_handler *hdl, |
376 | 351 |
(struct sockaddr *)&p->address, |
377 | 352 |
p->address_len, mi_socket_timeout); |
378 | 353 |
if (ret>0){ |
379 |
- DBG("DBG mi_datagram:datagram_close_async : the " |
|
380 |
- "response: %s has been sent in %i octets\n", |
|
354 |
+ LM_DBG("the response: %s has been sent in %i octets\n", |
|
381 | 355 |
dtgram.start, ret); |
382 | 356 |
}else{ |
383 |
- LOG(L_ERR, "ERROR midatagram:mi_datagram_server: an error " |
|
384 |
- "occured while sending the response, ret is %i\n",ret); |
|
357 |
+ LM_ERR("failed to send the response, ret is %i\n",ret); |
|
385 | 358 |
} |
386 | 359 |
free_mi_tree( mi_rpl ); |
387 | 360 |
pkg_free(dtgram.start); |
... | ... |
@@ -419,7 +392,7 @@ static inline struct mi_handler* build_async_handler(unsigned int sock_domain, |
419 | 392 |
hdl = (struct mi_handler*)shm_malloc( sizeof(struct mi_handler) + |
420 | 393 |
sizeof(my_socket_address)); |
421 | 394 |
if (hdl==0) { |
422 |
- LOG(L_ERR,"ERROR:mi_datagram:build_async_handler: no more shm mem\n"); |
|
395 |
+ LM_ERR("no more shm mem\n"); |
|
423 | 396 |
return 0; |
424 | 397 |
} |
425 | 398 |
|
... | ... |
@@ -428,26 +401,24 @@ static inline struct mi_handler* build_async_handler(unsigned int sock_domain, |
428 | 401 |
|
429 | 402 |
switch(sock_domain) |
430 | 403 |
{/*we can have either of these types of sockets*/ |
431 |
- case AF_LOCAL: DBG("mi_datagram:mi_datagram_server :" |
|
432 |
- "we have an unix socket\n"); |
|
404 |
+ case AF_LOCAL: LM_DBG("we have an unix socket\n"); |
|
433 | 405 |
memcpy(&repl_address->address.unix_deb, |
434 | 406 |
(struct sockaddr*)reply_addr, |
435 | 407 |
reply_addr_len); |
436 | 408 |
break; |
437 |
- case AF_INET: DBG("mi_datagram:mi_datagram_server :" |
|
438 |
- "we have an IPv4 socket\n"); |
|
409 |
+ case AF_INET: LM_DBG("we have an IPv4 socket\n"); |
|
439 | 410 |
memcpy(&repl_address->address.inet_v4, |
440 | 411 |
(struct sockaddr*)reply_addr, |
441 | 412 |
reply_addr_len); |
442 | 413 |
break; |
443 |
- case AF_INET6: DBG("mi_datagram:mi_datagram_server :" |
|
444 |
- "we have an IPv6 socket\n"); |
|
414 |
+ case AF_INET6: LM_DBG("we have an IPv6 socket\n"); |
|
445 | 415 |
memcpy(&repl_address->address.inet_v6, |
446 | 416 |
(struct sockaddr*)reply_addr, |
447 | 417 |
reply_addr_len); |
448 | 418 |
break; |
449 |
- default: LOG(L_CRIT, "BUG: mi_datagram:build_async_handler :" |
|
450 |
- "socket_domain has an incorrect value\n"); |
|
419 |
+ default: LM_CRIT("socket_domain has an incorrect value\n"); |
|
420 |
+ shm_free(hdl); |
|
421 |
+ return 0; |
|
451 | 422 |
|
452 | 423 |
} |
453 | 424 |
repl_address->domain = sock_domain; |
... | ... |
@@ -483,85 +454,73 @@ void mi_datagram_server(int rx_sock, int tx_sock) |
483 | 454 |
(struct sockaddr*)&reply_addr, &reply_addr_len); |
484 | 455 |
|
485 | 456 |
if (ret == -1) { |
486 |
- LOG(L_ERR, "datagram_fnc: mi_datagram_server: recvfrom: (%d) %s\n", |
|
487 |
- errno, strerror(errno)); |
|
457 |
+ LM_ERR("recvfrom: (%d) %s\n", errno, strerror(errno)); |
|
488 | 458 |
if ((errno == EINTR) || |
489 | 459 |
(errno == EAGAIN) || |
490 | 460 |
(errno == EWOULDBLOCK) || |
491 | 461 |
(errno == ECONNREFUSED)) { |
492 |
- DBG("datagram_fnc:mi_datagram_server: Got %d (%s), going on\n", |
|
493 |
- errno, strerror(errno)); |
|
462 |
+ LM_DBG("got %d (%s), going on\n", errno, strerror(errno)); |
|
494 | 463 |
continue; |
495 | 464 |
} |
496 |
- DBG("DBG:datagram_fnc:mi_datagram_server: error in recvfrom\n"); |
|
465 |
+ LM_DBG("error in recvfrom\n"); |
|
497 | 466 |
continue; |
498 | 467 |
} |
499 | 468 |
|
500 | 469 |
if(ret == 0) |
501 | 470 |
continue; |
502 | 471 |
|
503 |
- DBG("DBG: mi_datagram: mi_datagram_server: " |
|
504 |
- "process %i has received %.*s\n", getpid(), ret, mi_buf); |
|
472 |
+ LM_DBG("received %.*s\n", ret, mi_buf); |
|
505 | 473 |
|
506 | 474 |
if(ret> DATAGRAM_SOCK_BUF_SIZE){ |
507 |
- LOG(L_ERR, "ERROR: mi_datagram:mi_datagram_server: " |
|
508 |
- "buffer overflow\n"); |
|
475 |
+ LM_ERR("buffer overflow\n"); |
|
509 | 476 |
continue; |
510 | 477 |
} |
511 | 478 |
|
512 |
- DBG("DBG:mi-datagram:mi_datagram_server: mi_buf is %s and " |
|
513 |
- "we have received %i bytes\n",mi_buf, ret); |
|
479 |
+ LM_DBG("mi_buf is %s and we have received %i bytes\n",mi_buf, ret); |
|
514 | 480 |
dtgram.start = mi_buf; |
515 | 481 |
dtgram.len = ret; |
516 | 482 |
dtgram.current = dtgram.start; |
517 | 483 |
|
518 | 484 |
ret = identify_command(&dtgram, &f); |
519 |
- DBG("DBG: datagram:mi_datagram_server: the function " |
|
520 |
- "identify_command exited with the value %i\n", ret); |
|
521 | 485 |
/*analyze the command--from the first line*/ |
522 | 486 |
if(ret != 0) |
523 | 487 |
{ |
524 |
- LOG(L_ERR, "ERROR:datagram_fnc:identify_command: command not " |
|
525 |
- "available\n"); |
|
488 |
+ LM_ERR("command not available\n"); |
|
526 | 489 |
mi_send_dgram(tx_sock, MI_COMMAND_NOT_AVAILABLE, |
527 | 490 |
MI_COMMAND_AVAILABLE_LEN, |
528 | 491 |
(struct sockaddr* )&reply_addr, reply_addr_len, |
529 | 492 |
mi_socket_timeout); |
530 | 493 |
continue; |
531 | 494 |
} |
532 |
- DBG("DBG:datagram_fnc:mi_datagram_server: we have a valid " |
|
533 |
- "command \n"); |
|
495 |
+ LM_DBG("we have a valid command \n"); |
|
534 | 496 |
|
535 | 497 |
/* if asyncron cmd, build the async handler */ |
536 | 498 |
if (f->flags&MI_ASYNC_RPL_FLAG) { |
537 | 499 |
hdl = build_async_handler(mi_socket_domain, &reply_addr, |
538 | 500 |
reply_addr_len); |
539 | 501 |
if (hdl==0) { |
540 |
- LOG(L_ERR, "ERROR:datagram_fnc:mi_datagram_server: failed to " |
|
541 |
- "build async handler\n"); |
|
542 |
- mi_send_dgram(tx_sock, MI_INTERNAL_ERROR, MI_INTERNAL_ERROR_LEN, (struct sockaddr* )&reply_addr, reply_addr_len, |
|
543 |
- mi_socket_timeout); |
|
502 |
+ LM_ERR("failed to build async handler\n"); |
|
503 |
+ mi_send_dgram(tx_sock, MI_INTERNAL_ERROR, |
|
504 |
+ MI_INTERNAL_ERROR_LEN,(struct sockaddr* )&reply_addr, |
|
505 |
+ reply_addr_len, mi_socket_timeout); |
|
544 | 506 |
continue; |
545 | 507 |
} |
546 | 508 |
} else{ |
547 | 509 |
hdl = 0; |
548 | 510 |
} |
549 | 511 |
|
550 |
- DBG("DBG:datagram_fnc:mi_datagram_server: after identifing " |
|
551 |
- "the command, the received datagram is %s\n",dtgram.current); |
|
512 |
+ LM_DBG("after identifing the command, the received datagram is %s\n", |
|
513 |
+ dtgram.current); |
|
552 | 514 |
|
553 | 515 |
/*if no params required*/ |
554 | 516 |
if (f->flags&MI_NO_INPUT_FLAG) { |
555 |
- DBG("DBG:datagram_fnc:mi_datagram_server: the function " |
|
556 |
- "has no params\n"); |
|
517 |
+ LM_DBG("the command has no params\n"); |
|
557 | 518 |
mi_cmd = 0; |
558 | 519 |
} else { |
559 |
- DBG("DBG:datagram_fnc:mi_datagram_server: parsing the " |
|
560 |
- "function's params\n"); |
|
520 |
+ LM_DBG("parsing the command's params\n"); |
|
561 | 521 |
mi_cmd = mi_datagram_parse_tree(&dtgram); |
562 | 522 |
if (mi_cmd==NULL){ |
563 |
- LOG(L_ERR,"ERROR:datagram_fnc:mi_datagram_server:error parsing" |
|
564 |
- "MI tree\n"); |
|
523 |
+ LM_ERR("failed to parse the MI tree\n"); |
|
565 | 524 |
mi_send_dgram(tx_sock, MI_PARSE_ERROR, MI_PARSE_ERROR_LEN, |
566 | 525 |
(struct sockaddr* )&reply_addr, reply_addr_len, |
567 | 526 |
mi_socket_timeout); |
... | ... |
@@ -571,12 +530,10 @@ void mi_datagram_server(int rx_sock, int tx_sock) |
571 | 530 |
mi_cmd->async_hdl = hdl; |
572 | 531 |
} |
573 | 532 |
|
574 |
- DBG("DBG:datagram_fnc:mi_datagram_server:done parsing " |
|
575 |
- "the mi tree\n"); |
|
533 |
+ LM_DBG("done parsing the mi tree\n"); |
|
576 | 534 |
if ( (mi_rpl=run_mi_cmd(f, mi_cmd))==0 ){ |
577 | 535 |
/*error while running the command*/ |
578 |
- LOG(L_ERR, "ERROR:datagram_fnc:mi_datagram_server: command " |
|
579 |
- "processing failed\n"); |
|
536 |
+ LM_ERR("failed to process the command\n"); |
|
580 | 537 |
mi_send_dgram(tx_sock, MI_COMMAND_FAILED, MI_COMMAND_FAILED_LEN, |
581 | 538 |
(struct sockaddr* )&reply_addr, reply_addr_len, |
582 | 539 |
mi_socket_timeout); |
... | ... |
@@ -584,13 +541,11 @@ void mi_datagram_server(int rx_sock, int tx_sock) |
584 | 541 |
} |
585 | 542 |
|
586 | 543 |
/*the command exited well*/ |
587 |
- DBG("DBG: mi_datagram:mi_datagram_server: " |
|
588 |
- "command process (%s)succeded\n",f->name.s); |
|
544 |
+ LM_DBG("command process (%s)succeded\n",f->name.s); |
|
589 | 545 |
|
590 | 546 |
if (mi_rpl!=MI_ROOT_ASYNC_RPL) { |
591 | 547 |
if(mi_datagram_write_tree(&dtgram , mi_rpl) != 0){ |
592 |
- LOG(L_ERR, "ERROR mi_datagram:mi_datagram_server: error" |
|
593 |
- "while building the response \n"); |
|
548 |
+ LM_ERR("failed to build the response \n"); |
|
594 | 549 |
goto failure; |
595 | 550 |
} |
596 | 551 |
|
... | ... |
@@ -599,12 +554,10 @@ void mi_datagram_server(int rx_sock, int tx_sock) |
599 | 554 |
(struct sockaddr* )&reply_addr, |
600 | 555 |
reply_addr_len, mi_socket_timeout); |
601 | 556 |
if (ret>0){ |
602 |
- DBG("DEBUG mi_datagram:mi_datagram_server : the " |
|
603 |
- "response: %s has been sent in %i octets\n", |
|
557 |
+ LM_DBG("the response: %s has been sent in %i octets\n", |
|
604 | 558 |
dtgram.start, ret); |
605 | 559 |
}else{ |
606 |
- LOG(L_ERR, "ERROR midatagram:mi_datagram_server: an error " |
|
607 |
- "occured while sending the response\n"); |
|
560 |
+ LM_ERR("failed to send the response\n"); |
|
608 | 561 |
} |
609 | 562 |
free_mi_tree( mi_rpl ); |
610 | 563 |
free_async_handler(hdl); |
... | ... |
@@ -148,37 +148,34 @@ static int mi_mod_init(void) |
148 | 148 |
str port_str; |
149 | 149 |
|
150 | 150 |
/* checking the mi_socket module param */ |
151 |
- DBG("DBG: mi_datagram: mi_mod_init: testing socket existance ...\n"); |
|
151 |
+ LM_DBG("testing socket existance ...\n"); |
|
152 | 152 |
|
153 | 153 |
if( mi_socket==NULL || *mi_socket == 0) { |
154 |
- LOG(L_ERR, "ERROR:mi_datagram: mod_init: no DATAGRAM_ socket " |
|
155 |
- "configured\n"); |
|
154 |
+ LM_ERR("no DATAGRAM_ socket configured\n"); |
|
156 | 155 |
return -1; |
157 | 156 |
} |
158 | 157 |
|
159 |
- DBG("DBG:mi_datagram:mi_mod_init: the socket's name/addres is " |
|
160 |
- "%s\n", mi_socket); |
|
158 |
+ LM_DBG("the socket's name/addres is %s\n", mi_socket); |
|
161 | 159 |
|
162 | 160 |
memset( &mi_dtgram_addr, 0, sizeof(mi_dtgram_addr) ); |
163 | 161 |
|
164 | 162 |
if(strncmp(mi_socket, "udp:",4) == 0) |
165 | 163 |
{ |
166 | 164 |
/*for an UDP socket*/ |
167 |
- DBG("DBG:mi_datagram:mi_mod_init: we have an udp socket\n"); |
|
165 |
+ LM_DBG("we have an udp socket\n"); |
|
168 | 166 |
/*separate proto and host */ |
169 | 167 |
p = mi_socket+4; |
170 | 168 |
if( (*(p)) == '\0') |
171 | 169 |
{ |
172 |
- LOG(L_ERR,"ERROR:mi_datagram:mi_mod_init:malformed ip address\n"); |
|
170 |
+ LM_ERR("malformed ip address\n"); |
|
173 | 171 |
return -1; |
174 | 172 |
} |
175 | 173 |
host_s=p; |
176 |
- DBG("DBG: mi_datagram:mi_mod_init: the remaining address " |
|
177 |
- "after separating the protocol is %s\n",p); |
|
174 |
+ LM_DBG("the remaining address after separating the protocol is %s\n",p); |
|
178 | 175 |
|
179 | 176 |
if( (p = strrchr(p+1, ':')) == 0 ) |
180 | 177 |
{ |
181 |
- LOG(L_ERR,"ERROR:mi_datagram:mi_mod_init: no port specified\n"); |
|
178 |
+ LM_ERR("no port specified\n"); |
|
182 | 179 |
return -1; |
183 | 180 |
} |
184 | 181 |
|
... | ... |
@@ -186,29 +183,25 @@ static int mi_mod_init(void) |
186 | 183 |
*p = '\0'; p++; |
187 | 184 |
port_str.s = p; |
188 | 185 |
port_str.len = strlen(p); |
189 |
- DBG("DBG:mi_datagram:mi_mod_init: the port string is %s\n", p); |
|
186 |
+ LM_DBG("the port string is %s\n", p); |
|
190 | 187 |
if(str2int(&port_str, &port_no) != 0 ){ |
191 |
- LOG(L_ERR, "ERROR: mi_datagram:mi_mod_init: there is not " |
|
192 |
- "a valid number port\n"); |
|
188 |
+ LM_ERR("there is not a valid number port\n"); |
|
193 | 189 |
return -1; |
194 | 190 |
} |
195 | 191 |
*p = '\0'; |
196 | 192 |
if (port_no<1024 || port_no>MAX_NB_PORT) |
197 | 193 |
{ |
198 |
- LOG(L_ERR, "ERROR: mi_datagram:mi_mod_init: invalid port " |
|
199 |
- "number; must be in [1024,%d]\n",MAX_NB_PORT); |
|
194 |
+ LM_ERR("invalid port number; must be in [1024,%d]\n",MAX_NB_PORT); |
|
200 | 195 |
return -1; |
201 | 196 |
} |
202 | 197 |
|
203 | 198 |
if(! (host = resolvehost(host_s, 0)) ){ |
204 |
- LOG(L_ERR, "ERROR: mi_datagram:mi_mod_init failed to resolv %s" |
|
205 |
- "\n", host_s); |
|
199 |
+ LM_ERR("failed to resolve %s\n", host_s); |
|
206 | 200 |
return -1; |
207 | 201 |
} |
208 |
- DBG("DBG: mi_datagram:mi_init: the ip is %s\n",host_s); |
|
202 |
+ LM_DBG("the ip is %s\n",host_s); |
|
209 | 203 |
if(hostent2su( &(mi_dtgram_addr.udp_addr), host, 0, port_no ) !=0){ |
210 |
- LOG(L_ERR, "ERROR: mi_datagram:mi_mod_init failed to resolv %s" |
|
211 |
- "\n", mi_socket); |
|
204 |
+ LM_ERR("failed to resolve %s\n", mi_socket); |
|
212 | 205 |
return -1; |
213 | 206 |
} |
214 | 207 |
mi_socket_domain = host->h_addrtype; |
... | ... |
@@ -216,43 +209,39 @@ static int mi_mod_init(void) |
216 | 209 |
else |
217 | 210 |
{ |
218 | 211 |
/*in case of a Unix socket*/ |
219 |
- DBG("DBG:mi_datagram:mi_mod_init we have an UNIX socket\n"); |
|
212 |
+ LM_DBG("we have an UNIX socket\n"); |
|
220 | 213 |
|
221 | 214 |
n=stat(mi_socket, &filestat); |
222 | 215 |
if( n==0){ |
223 |
- LOG(L_INFO,"mi_datagram:mi_mid_init : the socket %s already exists" |
|
224 |
- "trying to delete it...\n",mi_socket); |
|
216 |
+ LM_INFO("the socket %s already existstrying to delete it...\n", |
|
217 |
+ mi_socket); |
|
225 | 218 |
if (unlink(mi_socket)<0){ |
226 |
- LOG(L_ERR, "ERROR: mi_datagram: mi_mod_init: cannot delete " |
|
227 |
- "old socket (%s): %s\n", mi_socket, strerror(errno)); |
|
219 |
+ LM_ERR("cannot delete old socket : %s\n", strerror(errno)); |
|
228 | 220 |
return -1; |
229 | 221 |
} |
230 | 222 |
}else if (n<0 && errno!=ENOENT){ |
231 |
- LOG(L_ERR, "ERROR: mi_datagram: mi_mod_init: socket stat failed:" |
|
232 |
- "%s\n", strerror(errno)); |
|
223 |
+ LM_ERR("socket stat failed:%s\n", strerror(errno)); |
|
233 | 224 |
return -1; |
234 | 225 |
} |
235 | 226 |
|
236 | 227 |
/* check mi_unix_socket_mode */ |
237 | 228 |
if(!mi_unix_socket_mode){ |
238 |
- LOG(L_WARN, "WARNING:mi_datagram: mi_mod_init: cannot specify " |
|
239 |
- "mi_unix_socket_mode = 0, forcing it to rw-------\n"); |
|
229 |
+ LM_WARN("cannot specify mi_unix_socket_mode = 0, " |
|
230 |
+ "forcing it to rw-------\n"); |
|
240 | 231 |
mi_unix_socket_mode = S_IRUSR| S_IWUSR; |
241 | 232 |
} |
242 | 233 |
|
243 | 234 |
if (mi_unix_socket_uid_s){ |
244 | 235 |
if (user2uid(&mi_unix_socket_uid, &mi_unix_socket_gid, |
245 | 236 |
mi_unix_socket_uid_s)<0){ |
246 |
- LOG(L_ERR, "ERROR:mi_datagram: mi_mod_init:bad user name %s\n", |
|
247 |
- mi_unix_socket_uid_s); |
|
237 |
+ LM_ERR("bad user name %s\n", mi_unix_socket_uid_s); |
|
248 | 238 |
return -1; |
249 | 239 |
} |
250 | 240 |
} |
251 | 241 |
|
252 | 242 |
if (mi_unix_socket_gid_s){ |
253 | 243 |
if (group2gid(&mi_unix_socket_gid, mi_unix_socket_gid_s)<0){ |
254 |
- LOG(L_ERR,"ERROR:mi_datagram: mi_mod_init:bad group name %s\n", |
|
255 |
- mi_unix_socket_gid_s); |
|
244 |
+ LM_ERR("bad group name %s\n", mi_unix_socket_gid_s); |
|
256 | 245 |
return -1; |
257 | 246 |
} |
258 | 247 |
} |
... | ... |
@@ -272,8 +261,7 @@ static int mi_child_init(int rank) |
272 | 261 |
if (rank==PROC_TIMER || rank>0 ) { |
273 | 262 |
if(mi_datagram_writer_init( DATAGRAM_SOCK_BUF_SIZE , |
274 | 263 |
mi_reply_indent )!= 0){ |
275 |
- LOG(L_CRIT, "CRITICAL:mi_datagram:mi_child_init: failed to " |
|
276 |
- "initiate mi_datagram_writer\n"); |
|
264 |
+ LM_CRIT("failed to initiate mi_datagram_writer\n"); |
|
277 | 265 |
return -1; |
278 | 266 |
} |
279 | 267 |
} |
... | ... |
@@ -291,8 +279,7 @@ static int pre_datagram_process(void) |
291 | 279 |
mi_unix_socket_gid); |
292 | 280 |
|
293 | 281 |
if ( res ) { |
294 |
- LOG(L_CRIT, "CRITICAL:mi_datagram:mi_init: The function " |
|
295 |
- "mi_init_datagram_server returned with error!!!\n"); |
|
282 |
+ LM_CRIT("function mi_init_datagram_server returned with error!!!\n"); |
|
296 | 283 |
return -1; |
297 | 284 |
} |
298 | 285 |
|
... | ... |
@@ -302,25 +289,21 @@ static int pre_datagram_process(void) |
302 | 289 |
|
303 | 290 |
static void datagram_process(int rank) |
304 | 291 |
{ |
305 |
- LOG(L_INFO,"INFO:mi_datagram:mi_child_init: a new child %d/%d\n", |
|
306 |
- rank, getpid()); |
|
292 |
+ LM_INFO("a new child %d/%d\n", rank, getpid()); |
|
307 | 293 |
|
308 | 294 |
/*child's initial settings*/ |
309 | 295 |
if ( init_mi_child()!=0) { |
310 |
- LOG(L_CRIT,"CRITICAL:mi_datagram:mi_child_init: failed to init" |
|
311 |
- "the mi process\n"); |
|
296 |
+ LM_CRIT("failed to init the mi process\n"); |
|
312 | 297 |
exit(-1); |
313 | 298 |
} |
314 | 299 |
if (mi_init_datagram_buffer()!=0){ |
315 |
- LOG(L_CRIT,"CRITICAL:mi_datagram:mi_child_init: failed to " |
|
316 |
- "allocate datagram buffer\n"); |
|
300 |
+ LM_ERR("failed to allocate datagram buffer\n"); |
|
317 | 301 |
exit(-1); |
318 | 302 |
} |
319 | 303 |
|
320 | 304 |
if (mi_datagram_writer_init( DATAGRAM_SOCK_BUF_SIZE , |
321 | 305 |
mi_reply_indent )!= 0){ |
322 |
- LOG(L_CRIT, "CRITICAL:mi_datagram:mi_child_init: failed to " |
|
323 |
- "initiate mi_datagram_writer\n"); |
|
306 |
+ LM_CRIT("failed to initiate mi_datagram_writer\n"); |
|
324 | 307 |
exit(-1); |
325 | 308 |
} |
326 | 309 |
|
... | ... |
@@ -349,13 +332,12 @@ static int mi_destroy(void) |
349 | 332 |
n=stat(mi_socket, &filestat); |
350 | 333 |
if (n==0){ |
351 | 334 |
if (unlink(mi_socket)<0){ |
352 |
- LOG(L_ERR, "ERROR: mi_datagram: mi_destroy: cannot delete the " |
|
353 |
- "socket (%s): %s\n", mi_socket, strerror(errno)); |
|
335 |
+ LM_ERR("cannot delete the socket (%s): %s\n", |
|
336 |
+ mi_socket, strerror(errno)); |
|
354 | 337 |
goto error; |
355 | 338 |
} |
356 | 339 |
} else if (n<0 && errno!=ENOENT) { |
357 |
- LOG(L_ERR, "ERROR: mi_datagram: mi_destroy: SOCKET stat failed: " |
|
358 |
- "%s\n", strerror(errno)); |
|
340 |
+ LM_ERR("socket stat failed: %s\n", strerror(errno)); |
|
359 | 341 |
goto error; |
360 | 342 |
} |
361 | 343 |
} |
... | ... |
@@ -63,14 +63,13 @@ static inline int mi_datagram_parse_node(datagram_stream * data, str *name, |
63 | 63 |
char *mark_nsp; |
64 | 64 |
int newline_found = 0; |
65 | 65 |
|
66 |
- DBG("DBG:mi_datagram:mi_parse_tree: the remaining datagram to" |
|
67 |
- "be parsed is %s and %i in length \n",data->current,data->len); |
|
66 |
+ LM_DBG("the remaining datagram to be parsed is %s and %i in length \n", |
|
67 |
+ data->current,data->len); |
|
68 | 68 |
|
69 | 69 |
p =data->current; |
70 | 70 |
start1 = start = p; |
71 | 71 |
if(data->len > DATAGRAM_SOCK_BUF_SIZE) { |
72 |
- LOG(L_ERR,"ERROR: datagram:datagram_parse_node: overflow while parsing" |
|
73 |
- "the received datagram\n"); |
|
72 |
+ LM_ERR("overflow while parsing the received datagram\n"); |
|
74 | 73 |
goto parse_err; |
75 | 74 |
} |
76 | 75 |
pmax = start + data->len ; |
... | ... |
@@ -89,8 +88,7 @@ static inline int mi_datagram_parse_node(datagram_stream * data, str *name, |
89 | 88 |
|
90 | 89 |
/* start parsing */ |
91 | 90 |
if (*start!='"') { |
92 |
- DBG("DBG:mi_datagram_parser:mi_parse_node: the string " |
|
93 |
- "is not just a quoted string\n"); |
|
91 |
+ LM_DBG("the string is not just a quoted string\n"); |
|
94 | 92 |
/* look for the atribute name */ |
95 | 93 |
|
96 | 94 |
p = mark_nsp = start; |
... | ... |
@@ -99,22 +97,19 @@ static inline int mi_datagram_parse_node(datagram_stream * data, str *name, |
99 | 97 |
if (!isspace((int)*p)) { |
100 | 98 |
if (*p=='"') |
101 | 99 |
{ |
102 |
- DBG("DBG:mi_datagram_parser:mi_parse_node:" |
|
103 |
- "found \" before attr_separator\n"); |
|
100 |
+ LM_DBG("found \" before attr_separator\n"); |
|
104 | 101 |
goto parse_err; |
105 | 102 |
} |
106 | 103 |
mark_nsp = p; |
107 | 104 |
} |
108 | 105 |
if(*p=='\n' && p!=(pmax -1)){ |
109 |
- DBG("DBG:mi_datagram_parser:mi_parse_node: " |
|
110 |
- "found newline before attr_separator--we have just the " |
|
106 |
+ LM_DBG("found newline before attr_separator--we have just the " |
|
111 | 107 |
"attribute's value\n"); |
112 | 108 |
mark_nsp++; pmax = ++p; |
113 | 109 |
break; |
114 | 110 |
}else if (p == (pmax-1)){ |
115 | 111 |
mark_nsp++; pmax = ++p; |
116 |
- DBG("mi_datagram:mi_datagram_parser: just a value, no new" |
|
117 |
- " line"); |
|
112 |
+ LM_DBG("just a value, no new line"); |
|
118 | 113 |
break; |
119 | 114 |
} |
120 | 115 |
p++; |
... | ... |
@@ -122,17 +117,14 @@ static inline int mi_datagram_parse_node(datagram_stream * data, str *name, |
122 | 117 |
|
123 | 118 |
if (p!=pmax) { |
124 | 119 |
/* we have found the separator */ |
125 |
- DBG("DBG:mi_datagram_parser:mi_parse_node: we've found " |
|
126 |
- "the attr_separator\n"); |
|
120 |
+ LM_DBG("we've found the attr_separator\n"); |
|
127 | 121 |
if (p==start) { |
128 | 122 |
/* empty attr name */ |
129 |
- DBG("DBG:mi_datagram_parser:mi_parse_node: " |
|
130 |
- "empty attr_name\n"); |
|
123 |
+ LM_DBG("empty attr_name\n"); |
|
131 | 124 |
} else { |
132 | 125 |
name->s = start; |
133 | 126 |
name->len = mark_nsp - start+1; |
134 |
- DBG("DBG:mi_datagram:mi_parse_node: attr name <%.*s> " |
|
135 |
- "found\n",name->len, name->s); |
|
127 |
+ LM_DBG("attr name <%.*s> found\n",name->len, name->s); |
|
136 | 128 |
} |
137 | 129 |
|
138 | 130 |
p += 2; /* for separator */ |
... | ... |
@@ -142,35 +134,30 @@ static inline int mi_datagram_parse_node(datagram_stream * data, str *name, |
142 | 134 |
{ |
143 | 135 |
if(*p=='\n') |
144 | 136 |
{ |
145 |
- DBG("DBG:mi_datagram:mi_parse_node: empty value\n"); |
|
137 |
+ LM_DBG("empty value\n"); |
|
146 | 138 |
/* empty value.....we are done */ |
147 | 139 |
goto done; |
148 | 140 |
} |
149 | 141 |
} |
150 |
- /*DBG("mi_datagram:mi_datagram_parser:p is %s case2\n",p);*/ |
|
142 |
+ /*LM_DBG("p is %s case2\n",p);*/ |
|
151 | 143 |
|
152 | 144 |
if(p==pmax && *p=='\n') |
153 | 145 |
{ |
154 |
- DBG("DBG:mi_datagram:mi_parse_node: empty value\n"); |
|
146 |
+ LM_DBG("empty value\n"); |
|
155 | 147 |
/* empty value.....we are done */ |
156 | 148 |
goto done; |
157 | 149 |
} |
158 |
- /*DBG("mi_datagram:mi_datagram_parser:p is %s case1\n",p);*/ |
|
150 |
+ /*LM_DBG("p is %s case1\n",p);*/ |
|
159 | 151 |
/* value (only if not quoted ) */ |
160 | 152 |
if (*p!='"') { |
161 |
- DBG("DBG:mi_datagram_parser:mi_parse_node: " |
|
162 |
- "not quoted value, p is %c \n", *p); |
|
153 |
+ LM_DBG("not quoted value, p is %c \n", *p); |
|
163 | 154 |
for( start=p ; p!=pmax ; p++ ) { |
164 |
- /*DBG("mi_datagram:mi_datagram_parser: p is %s\n",p);*/ |
|
165 | 155 |
if (!isspace((int)*p)) { |
166 | 156 |
if (*p=='"'){ |
167 |
- /* DBG("mi_datagram:mi_datagram_parser:i've " |
|
168 |
- "found \"");*/ |
|
169 | 157 |
goto parse_err; |
170 | 158 |
} |
171 | 159 |
mark_nsp = p; |
172 |
- DBG("DGB: mi_datagram:mi_datagram_parse_node:" |
|
173 |
- "nsp is %p ,p is %p, pmax is %p and *p is %c\n", |
|
160 |
+ LM_DBG("nsp is %p ,p is %p, pmax is %p and *p is %c\n", |
|
174 | 161 |
mark_nsp, p, pmax,*p); |
175 | 162 |
} |
176 | 163 |
if(*p=='\n'){/*end of the node*/ |
... | ... |
@@ -181,10 +168,8 @@ static inline int mi_datagram_parse_node(datagram_stream * data, str *name, |
181 | 168 |
|
182 | 169 |
value->s = start; |
183 | 170 |
value->len = mark_nsp - start+1; |
184 |
- DBG("DBG:mi_datagram:mi_datagram_parse_node:*start is " |
|
185 |
- "%c and start is %p\n",*start, start); |
|
186 |
- DBG("DBG:mi_datagram:mi_parse_node: " |
|
187 |
- "attr value <%s> found\n"/*,value->len*/, value->s); |
|
171 |
+ LM_DBG("*start is %c and start is %p\n",*start, start); |
|
172 |
+ LM_DBG("attr value <%s> found\n"/*,value->len*/, value->s); |
|
188 | 173 |
goto done; |
189 | 174 |
} |
190 | 175 |
/* quoted value....continue */ |
... | ... |
@@ -192,18 +177,15 @@ static inline int mi_datagram_parse_node(datagram_stream * data, str *name, |
192 | 177 |
/* we have an empty name ... and we read a non-quoted value */ |
193 | 178 |
value->s = start; |
194 | 179 |
value->len = mark_nsp - start; |
195 |
- DBG("DBG:mi_datagram:mi_parse_node: the value's length is " |
|
196 |
- "%i\n",value->len); |
|
197 |
- DBG("DBG:mi_datagram:mi_parse_node: empty name, " |
|
198 |
- "attr not quoted value <%.*s> found\n",value->len, value->s); |
|
180 |
+ LM_DBG("empty name, attr not quoted value <%.*s> found\n", |
|
181 |
+ value->len, value->s); |
|
199 | 182 |
goto done; |
200 | 183 |
} |
201 | 184 |
} else { |
202 | 185 |
p = start; /*send the value only: as a quoted string*/ |
203 | 186 |
} |
204 | 187 |
/*we have a quoted value*/ |
205 |
- DBG("DBG:mi_datagram:mi_parse_node: we have a quoted value, %s\n", |
|
206 |
- p); |
|
188 |
+ LM_DBG("we have a quoted value, %s\n", p); |
|
207 | 189 |
start = p+1; /*skip the first "*/ |
208 | 190 |
value->s = start; |
209 | 191 |
|
... | ... |
@@ -212,20 +194,18 @@ static inline int mi_datagram_parse_node(datagram_stream * data, str *name, |
212 | 194 |
while (p<pmax) { |
213 | 195 |
if (*p=='"' && start!=p){ /*search the closing "*/ |
214 | 196 |
|
215 |
- DBG("DBG:mi_datagram:mi_parse_node, \" found p is %s\n",p); |
|
197 |
+ LM_DBG("\" found p is %s\n",p); |
|
216 | 198 |
|
217 | 199 |
if (start+1!=p && *(p-1)=='\\') { |
218 |
- DBG("DBG:mi_datagram:mi_parse_node: skipping %c",*p); |
|
200 |
+ LM_DBG("skipping %c",*p); |
|
219 | 201 |
/* skip current char */ |
220 | 202 |
memmove( p-1, p, pmax-p); |
221 | 203 |
pmax--; |
222 | 204 |
} else { |
223 |
- DBG("DBG:mi_datagram:mi_parse_node: we have reached " |
|
224 |
- "the end of attr value, p is %s\n", p); |
|
205 |
+ LM_DBG("we have reached the end of attr value, p is %s\n", p); |
|
225 | 206 |
/* end of value */ |
226 | 207 |
value->len = p - value->s; |
227 |
- DBG("DBG:mi_datagram:mi_parse_node:attr value" |
|
228 |
- "<%.*s> found\n",value->len, value->s); |
|
208 |
+ LM_DBG("attr value <%.*s> found\n",value->len, value->s); |
|
229 | 209 |
|
230 | 210 |
/* is the line ending propely (only spaces) ? */ |
231 | 211 |
p++; |
... | ... |
@@ -233,16 +213,14 @@ static inline int mi_datagram_parse_node(datagram_stream * data, str *name, |
233 | 213 |
{ |
234 | 214 |
if(*p=='\n') { |
235 | 215 |
/*case : ""quoted string" \n on a line */ |
236 |
- DBG("DBG:mi_datagram:mi_parse_node:" |
|
237 |
- "line ended properly case1\n"); |
|
216 |
+ LM_DBG("line ended properly case1\n"); |
|
238 | 217 |
pmax = p; |
239 | 218 |
break; |
240 | 219 |
} |
241 | 220 |
} |
242 | 221 |
if (p!=pmax )/*didn't find the second " on the current line*/ |
243 | 222 |
{ |
244 |
- LOG(L_ERR, "ERROR:mi_datagram:mi_parse_node: didn't find " |
|
245 |
- "newline case1 \n"); |
|
223 |
+ LM_ERR("didn't find newline case1 \n"); |
|
246 | 224 |
goto parse_err; |
247 | 225 |
} |
248 | 226 |
newline_found = 1; |
... | ... |
@@ -256,21 +234,19 @@ static inline int mi_datagram_parse_node(datagram_stream * data, str *name, |
256 | 234 |
|
257 | 235 |
if(p== pmax && !newline_found) |
258 | 236 |
{ |
259 |
- LOG(L_ERR, "ERROR: mi_datagram:mi_datagram_parse_node: didn't find " |
|
260 |
- "newline case2\n"); |
|
237 |
+ LM_ERR("didn't find newline case2\n"); |
|
261 | 238 |
goto parse_err; |
262 | 239 |
} |
263 | 240 |
|
264 | 241 |
done: |
265 | 242 |
/*set the current datagram's offset */ |
266 |
- DBG("mi_datagram:mi_datagram_parser:1 data->len is %i\n",data->len); |
|
243 |
+ LM_DBG("1 data->len is %i\n",data->len); |
|
267 | 244 |
data->len -= p-start1; |
268 |
- DBG("mi_datagram:mi_datagram_parser:2 data->len is %i\n",data->len); |
|
245 |
+ LM_DBG("2 data->len is %i\n",data->len); |
|
269 | 246 |
data->current = p; |
270 | 247 |
return 0; |
271 | 248 |
parse_err: |
272 |
- LOG(L_ERR,"ERROR:mi_datagram_parser:mi_parse_node: parse error " |
|
273 |
- "around %c\n",*p); |
|
249 |
+ LM_ERR("parse error around %c\n",*p); |
|
274 | 250 |
return -1; |
275 | 251 |
} |
276 | 252 |
|
... | ... |
@@ -286,14 +262,13 @@ struct mi_root * mi_datagram_parse_tree(datagram_stream * datagram) { |
286 | 262 |
|
287 | 263 |
if(!datagram || datagram->current[0] == '\0') |
288 | 264 |
{ |
289 |
- LOG(L_ERR,"ERROR:mi_datagram:mi_parse_node:no data in the datagram\n"); |
|
265 |
+ LM_ERR("no data in the datagram\n"); |
|
290 | 266 |
return 0; |
291 | 267 |
} |
292 | 268 |
|
293 | 269 |
root = init_mi_tree(0,0,0); |
294 | 270 |
if (!root) { |
295 |
- LOG(L_ERR, "ERROR:mi_datagram:mi_parse_tree: the MI tree cannot be " |
|
296 |
- "initialized!\n"); |
|
271 |
+ LM_ERR("the MI tree cannot be initialized!\n"); |
|
297 | 272 |
goto error; |
298 | 273 |
} |
299 | 274 |
node = &root->node; |
... | ... |
@@ -306,24 +281,22 @@ struct mi_root * mi_datagram_parse_tree(datagram_stream * datagram) { |
306 | 281 |
|
307 | 282 |
if(ret == 1) |
308 | 283 |
return root; |
309 |
- DBG("INFO:mi_datagram:mi_parse_tree: adding node <%.*s> ; val" |
|
310 |
- "<%.*s>\n",name.len,name.s, value.len,value.s); |
|
284 |
+ LM_DBG("adding node <%.*s> ; val <%.*s>\n", |
|
285 |
+ name.len,name.s, value.len,value.s); |
|
311 | 286 |
|
312 | 287 |
if(!add_mi_node_child(node,0,name.s,name.len,value.s,value.len)){ |
313 |
- LOG(L_ERR, "ERROR:mi_datagram:mi_parse_tree: cannot add the child " |
|
314 |
- "node to the tree\n"); |
|
288 |
+ LM_ERR("cannot add the child node to the tree\n"); |
|
315 | 289 |
goto error; |
316 | 290 |
} |
317 |
- DBG("DBG: mi_datagram:mi_datagram_parse_tree: the remaining " |
|
318 |
- "datagram has %i bytes\n",datagram->len); |
|
291 |
+ LM_DBG("the remaining datagram has %i bytes\n",datagram->len); |
|
319 | 292 |
/*end condition*/ |
320 | 293 |
if(datagram->len == 0) { |
321 |
- DBG("DBG:mi_datagram:mi_parse_tree: found end of input\n"); |
|
294 |
+ LM_DBG("found end of input\n"); |
|
322 | 295 |
return root; |
323 | 296 |
} |
324 | 297 |
} |
325 | 298 |
|
326 |
- LOG(L_ERR, "ERROR:mi_datagram:mi_parse_tree: Parse error!\n"); |
|
299 |
+ LM_ERR("parse error!\n"); |
|
327 | 300 |
error: |
328 | 301 |
if (root) |
329 | 302 |
free_mi_tree(root); |
... | ... |
@@ -68,14 +68,13 @@ static inline int mi_datagram_write_node(datagram_stream * dtgram, |
68 | 68 |
|
69 | 69 |
start = p = dtgram->current; |
70 | 70 |
end = dtgram->start + dtgram->len; |
71 |
- DBG("DBG:mi_datagram:mi_datagram_write_node:writing the name " |
|
72 |
- "<%.*s> and value <%.*s> \n",node->name.len, node->name.s, |
|
73 |
- node->value.len, node->value.s); |
|
71 |
+ LM_DBG("writing the name <%.*s> and value <%.*s> \n", |
|
72 |
+ node->name.len, node->name.s, node->value.len, node->value.s); |
|
74 | 73 |
/* write indents */ |
75 | 74 |
if (mi_datagram_indent.s) { |
76 | 75 |
if (p + level*mi_datagram_indent.len>end) |
77 | 76 |
{ |
78 |
- DBG("datagram: write_node: a too long line\n"); |
|
77 |
+ LM_DBG("a too long line\n"); |
|
79 | 78 |
return -1; |
80 | 79 |
} |
81 | 80 |
for( ; level>0 ; level-- ) { |
... |