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

Function encode_address_switch_attr

modules/cpl_c/cpl_parser.c:332–393  ·  view source on GitHub ↗

Attr. encoding for ADDRESS_SWITCH node: * | attr1_t(2) attr1_val(2) | FIELD attr * [| attr2_t(2) attr2_val(2) |]? SUBFILED attr */

Source from the content-addressed store, hash-verified

330 * [| attr2_t(2) attr2_val(2) |]? SUBFILED attr
331 */
332static inline int encode_address_switch_attr(xmlNodePtr node, char *node_ptr,
333 char *buf_end)
334{
335 xmlAttrPtr attr;
336 char *p, *p_orig;
337 unsigned char *nr_attr;
338 str val;
339
340 nr_attr = &(NR_OF_ATTR(node_ptr));
341 *nr_attr = 0;
342 p = p_orig = ATTR_PTR(node_ptr);
343
344 FOR_ALL_ATTR(node,attr) {
345 (*nr_attr)++;
346 /* get the value of the attribute */
347 get_attr_val( attr->name , val, error);
348 switch(attr->name[0]) {
349 case 'F': case 'f':
350 set_attr_type(p, FIELD_ATTR, buf_end, error);
351 if (val.s[0]=='D' || val.s[0]=='d')
352 append_short_attr(p, DESTINATION_VAL, buf_end, error);
353 else if (val.s[6]=='A' || val.s[6]=='a')
354 append_short_attr(p,ORIGINAL_DESTINATION_VAL,buf_end,error);
355 else if (!val.s[6])
356 append_short_attr(p, ORIGIN_VAL, buf_end, error);
357 else {
358 LM_ERR("unknown"
359 " value <%s> for FIELD attr\n",val.s);
360 goto error;
361 };
362 break;
363 case 'S': case 's':
364 set_attr_type(p, SUBFIELD_ATTR, buf_end, error);
365 switch (val.s[0]) {
366 case 'u': case 'U':
367 append_short_attr(p, USER_VAL, buf_end, error);
368 break;
369 case 'h': case 'H':
370 append_short_attr(p, HOST_VAL, buf_end, error);
371 break;
372 case 'p': case 'P':
373 append_short_attr(p, PORT_VAL, buf_end, error);
374 break;
375 case 't': case 'T':
376 append_short_attr(p, TEL_VAL, buf_end, error);
377 break;
378 case 'd': case 'D':
379 /*append_short_attr(p, DISPLAY_VAL, buf_end, error);
380 break;*/ /* NOT YET SUPPORTED BY INTERPRETER */
381 case 'a': case 'A':
382 /*append_short_attr(p, ADDRESS_TYPE_VAL, buf_end,error);
383 break;*/ /* NOT YET SUPPORTED BY INTERPRETER */
384 default:
385 LM_ERR("unknown value <%s> for SUBFIELD attr\n",val.s);
386 goto error;
387 }
388 break;
389 default:

Callers 1

encode_nodeFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected