[RADIATOR] Renaming attributes in Grouped AVP

Hugh Irvine hugh at open.com.au
Mon Sep 14 17:08:19 CDT 2009


Hello Arthur -

My previous mail mentioned the example hook that processes multiple  
"cisco-avpairs".

Here is the code for your convenience:


createavpairs

sub {
         my $p=${$_[0]};
         if (my @avpair = $p->get_attr('cisco-avpair')) {
                 foreach my $avpair (@avpair) {
                         $p->add_attr(split('=',$avpair));
                 }
         }
}


You simply need to call "get_attr()" in a list context to get all of  
the attributes with a particular name.

In this case you could probably use something like this for each of  
the attributes you need to process:


sub
{
	my $p=${$_[0]};

	my @attribute;

	@attribute= $p->get_attr('Accounting-Input-Octets');

	$p->att_attr('Accounting-Input-Octets-Called-Side', $attribute[0];
	$p->att_attr('Accounting-Input-Octets-Calling-Side', $attribute[1];

	@attribute = $p->get_attr('Accounting-Output-Octets');

	$p->att_attr('Accounting-Output-Octets-Called-Side', $attribute[0];
	$p->att_attr('Accounting-Output-Octets-Calling-Side', $attribute[1];

	......

	return;
}


hope that helps

regards

Hugh


On 15 Sep 2009, at 03:59, Arthur Konovalov wrote:

> Thank You for the tip.
>
> From my understanding seems that in those examples single attributes
> are processed.
> My task is more complicated.
> How can I memorize  AVP-s which belong to Called-Side group and others
> with same names to Calling-Side?
> Is there a way to store the whole group together and rename the
> attributes afterwards in preprocessing hook?
>
> Regards,
> Arthur
>
> Hugh Irvine wrote:
>>
>>
>> Yes you can manipulate the attributes in a hook.
>>
>> There are many example hooks in "goodies/hooks.txt", including one
>> that does something similar with multiple "cisco-avpairs".
>>
>> regards
>>
>> Hugh
>>
>>
>>
>>
>> On 14 Sep 2009, at 19:40, Arthur Konovalov wrote:
>>
>>> Hi!
>>>
>>> I have a task to store statistics from Diameter accounting messages.
>>> There are 2 identical Media-Statistics grouped AVP in one message-  
>>> one
>>> from Calling-Side and another from Called-Side.
>>>
>>> Part of logfile:
>>>
>>> Mon Sep 14 11:20:11 2009: DEBUG: mmtest.emm.hot.ee <-  
>>> proxy1.emm.hot.ee
>>> recv_v1msg:
>>> Code:           271 (Accounting)
>>> Version:        1
>>> Flags:          0xc0 (RP)
>>> Application ID: 3 (Base Accounting)
>>> Hop-to-Hop ID:  319540787
>>> End-to-End ID:  319540787
>>> Attributes:
>>>   Session-Id: .M., proxy1.emm.hot.ee;18;1081;ppb1_bs13- 
>>> R6A at blade_0_19
>>>   Origin-Host: .M., proxy1.emm.hot.ee
>>>   Origin-Realm: .M., emm.hot.ee
>>>   Destination-Realm: .M., emm.hot.ee
>>>   Destination-Host: .M., mmtest.emm.hot.ee
>>>   Accounting-Record-Type: .M., STOP_RECORD
>>>   Accounting-Record-Number: .M., 2
>>>   Acct-Application-Id: .M., BASE_ACCOUNTING
>>>   Event-Timestamp: .M., 3461905212
>>>   Role-Of-Node: VM., 1
>>>   Time-Stamps: VM.,
>>>      SIP-Request-Timestamp: VM., 3461905212
>>>      SIP-Response-Timestamp: VM., 3461905212
>>>   IMS-Charging-Identifier: VM., proxy1.emm.hot.ee-1252-916407-737035
>>>   Cause-Code: VM., 0
>>>   Node-Functionality: VM., 110
>>>   Media-Statistics: VM.,
>>>      Media-Interface-Statistics: VM.,
>>>         User-Side: VM., Called-Side
>>>         Media-Interface-Flow-Statistics: VM.,
>>>            Media-Component-Number: VM., 1
>>>            Accounting-Input-Octets: .M., 32000
>>>            Accounting-Input-Packets: .M., 160
>>>            Accounting-Output-Octets: .M., 24636
>>>            Accounting-Output-Packets: .M., 124
>>>            Packets-Discarded-Filtering: VM., 0
>>>            Octets-Discarded-Filtering: VM., 0
>>>            Packets-Discarded-Policing: VM., 0
>>>            Octets-Discarded-Policing: VM., 0
>>>            Packets-Out-Of-Sequence: VM., 0
>>>            Packets-Lost: VM., 0
>>>            RTCP-Reported-Average-Jitter: VM., 0
>>>            RTCP-Reported-Packets-Lost: VM., 0
>>>      Media-Interface-Statistics: VM.,
>>>         User-Side: VM., Calling-Side
>>>         Media-Interface-Flow-Statistics: VM.,
>>>            Media-Component-Number: VM., 1
>>>            Accounting-Input-Octets: .M., 24636
>>>            Accounting-Input-Packets: .M., 124
>>>            Accounting-Output-Octets: .M., 32000
>>>            Accounting-Output-Packets: .M., 160
>>>            Packets-Discarded-Filtering: VM., 0
>>>            Octets-Discarded-Filtering: VM., 0
>>>            Packets-Discarded-Policing: VM., 0
>>>            Octets-Discarded-Policing: VM., 0
>>>            Packets-Out-Of-Sequence: VM., 0
>>>            Packets-Lost: VM., 0
>>>            RTCP-Reported-Average-Jitter: VM., 0
>>>            RTCP-Reported-Packets-Lost: VM., 0
>>> Mon Sep 14 11:20:11 2009: DEBUG: StateMachine::event R-Rcv-Message  
>>> in
>>> state R-Open. Calling Process
>>> Mon Sep 14 11:20:11 2009: DEBUG: mmtest.emm.hot.ee Process
>>> Mon Sep 14 11:20:11 2009: DEBUG: Packet dump:
>>> *** Diameter request converted to Radius request ....
>>> Code:       Accounting-Request
>>> Identifier: UNDEF
>>> Authentic:  ,-<232><141><181><152><30> 
>>> +<180><128><212><137><251>MN<220>
>>> Attributes:
>>>       Acct-Session-Id =
>>> "proxy1.emm.hot.ee;18;1081;ppb1_bs13-R6A at blade_0_19"
>>>       NAS-Identifier = "proxy1.emm.hot.ee"
>>>       Acct-Status-Type = 2
>>>       Event-Timestamp = 3461905212
>>>       Role-Of-Node = 1
>>>       SIP-Request-Timestamp = 3461905212
>>>       SIP-Response-Timestamp = 3461905212
>>>       IMS-Charging-Identifier =  
>>> "proxy1.emm.hot.ee-1252-916407-737035"
>>>       Cause-Code = 0
>>>       Node-Functionality = 110
>>>       User-Side = "Called-Side"
>>>       Media-Component-Number = 1
>>>       Acct-Input-Octets = 32000
>>>       Acct-Input-Packets = 160
>>>       Acct-Output-Octets = 24636
>>>       Acct-Output-Packets = 124
>>>       Packets-Discarded-Filtering = 0
>>>       Octets-Discarded-Filtering = 0
>>>       Packets-Discarded-Policing = 0
>>>       Octets-Discarded-Policing = 0
>>>       Packets-Out-Of-Sequence = 0
>>>       Packets-Lost = 0
>>>       RTCP-Reported-Average-Jitter = 0
>>>       RTCP-Reported-Packets-Lost = 0
>>>       User-Side = "Calling-Side"
>>>       Media-Component-Number = 1
>>>       Acct-Input-Octets = 24636
>>>       Acct-Input-Packets = 124
>>>       Acct-Output-Octets = 32000
>>>       Acct-Output-Packets = 160
>>>       Packets-Discarded-Filtering = 0
>>>       Octets-Discarded-Filtering = 0
>>>       Packets-Discarded-Policing = 0
>>>       Octets-Discarded-Policing = 0
>>>       Packets-Out-Of-Sequence = 0
>>>       Packets-Lost = 0
>>>       RTCP-Reported-Average-Jitter = 0
>>>       RTCP-Reported-Packets-Lost = 0
>>>
>>>
>>> I can't store in MySQL table two different attributes with same  
>>> name.
>>> Is it possible to rename attributes (by script, for example) in  
>>> grouped
>>> AVP to excluding names overlapping? For instance by adding prefix or
>>> suffix to Calling and Called part attribute names.
>>>
>>> Please give me any hint, help or workaround.
>>>
>>> Regards,
>>> Arthur
>>>
>>>
>>> _______________________________________________
>>> radiator mailing list
>>> radiator at open.com.au
>>> http://www.open.com.au/mailman/listinfo/radiator
>>
>>
>>
>> NB:
>>
>> Have you read the reference manual ("doc/ref.html")?
>> Have you searched the mailing list archive
>> (www.open.com.au/archives/radiator)?
>> Have you had a quick look on Google (www.google.com)?
>> Have you included a copy of your configuration file (no secrets),
>> together with a trace 4 debug showing what is happening?
>> Have you checked the RadiusExpert wiki:
>> http://www.open.com.au/wiki/index.php/Main_Page
>>
>
> _______________________________________________
> radiator mailing list
> radiator at open.com.au
> http://www.open.com.au/mailman/listinfo/radiator



NB:

Have you read the reference manual ("doc/ref.html")?
Have you searched the mailing list archive (www.open.com.au/archives/radiator)?
Have you had a quick look on Google (www.google.com)?
Have you included a copy of your configuration file (no secrets),
together with a trace 4 debug showing what is happening?
Have you checked the RadiusExpert wiki:
http://www.open.com.au/wiki/index.php/Main_Page

-- 
Radiator: the most portable, flexible and configurable RADIUS server
anywhere. Available on *NIX, *BSD, Windows, MacOS X.
Includes support for reliable RADIUS transport (RadSec),
and DIAMETER translation agent.
-
Nets: internetwork inventory and management - graphical, extensible,
flexible with hardware, software, platform and database independence.
-
CATool: Private Certificate Authority for Unix and Unix-like systems.




More information about the radiator mailing list