[OpenSER-Devel] Add new assignment operator to config script

Alex Hermann alex at speakup.nl
Thu Aug 16 11:15:13 CEST 2007


Hello all,

find attached a patch which adds a new assignment operator (:=) to the config 
script. Instead of the regular assignment (=), this operator will not add an 
entry to an existing avp, but it deletes the existing avp and creates a new 
avp with only one value.

I think this is usefull because I was using a lot of avp_delete()/assignment 
sequences to keep just 1 value in an avp instead of a list.

Please review and comment on it. Although the patch seems to work ok, I don't 
have any insight in the pointer dances OpenSER does, so I might have done 
something completely insane.

If the patch is acceptable as is, please commit.

Patch is against OpenSER 1.2 svn revision 2606


Config example and result:
route {
	xlog("Part 1");
	$avp(s:test1) = "test1_1";
	$avp(s:test1) = "test1_2";
	$avp(s:test2) := "test2_1";
	$avp(s:test2) := "test2_2";
	avp_print();

	xlog("Part 2");
	$avp(s:test1) := "test1_3";
	$avp(s:test2) = "test2_3";
	avp_print();
}

Log snippet:

[19924]: Part 1
[19924]: INFO:avpops:print_avp: p=0xb5c4fbc0, flags=0x0003
[19924]: INFO:                      name=<test2>
[19924]: INFO:                      val_str=<test2_2 / 7>
[19924]: INFO:avpops:print_avp: p=0xb5c4fb90, flags=0x0003
[19924]: INFO:                      name=<test1>
[19924]: INFO:                      val_str=<test1_2 / 7>
[19924]: INFO:avpops:print_avp: p=0xb5c4fb60, flags=0x0003
[19924]: INFO:                      name=<test1>
[19924]: INFO:                      val_str=<test1_1 / 7>
[19924]: Part 2
[19924]: INFO:avpops:print_avp: p=0xb5c4fb90, flags=0x0003
[19924]: INFO:                      name=<test2>
[19924]: INFO:                      val_str=<test2_3 / 7>
[19924]: INFO:avpops:print_avp: p=0xb5c4fb60, flags=0x0003
[19924]: INFO:                      name=<test1>
[19924]: INFO:                      val_str=<test1_3 / 7>
[19924]: INFO:avpops:print_avp: p=0xb5c4fbc0, flags=0x0003
[19924]: INFO:                      name=<test2>
[19924]: INFO:                      val_str=<test2_2 / 7>

-- 
Greetings,

Alex Hermann
-------------- next part --------------
A non-text attachment was scrubbed...
Name: openser-assign-operator.diff
Type: text/x-diff
Size: 2998 bytes
Desc: not available
Url : http://openser.org/pipermail/devel/attachments/20070816/505f69f8/openser-assign-operator.diff


More information about the Devel mailing list