Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds a parameters= option to the Routing: response from radius #39

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions sippy/B2BRoute.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,16 @@ def __init__(self, sroute = None, cself = None):
self.params['outbound_proxy'] = (v, 5060)
else:
self.params['outbound_proxy'] = (host_port[0], int(host_port[1]))
elif a == 'parameters':
self.params['radius_parameters'] = []

pairs = v.split(';')

for pair in pairs:
[key, _, value] = pair.partition("=")

if value != '':
self.params['radius_parameters'].append((key, value))
else:
self.params[a] = v
if len(extra_headers) > 0:
Expand Down
8 changes: 7 additions & 1 deletion sippy/RadiusAccounting.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,17 +69,23 @@ def __init__(self, global_config, origin, lperiod = None, send_start = False):
self.send_start = send_start

def setParams(self, username, caller, callee, h323_cid, sip_cid, remote_ip, \
h323_in_cid = None):
h323_in_cid = None, radius_parameters = None):
if caller == None:
caller = ''
self._attributes.extend((('User-Name', username), ('Calling-Station-Id', caller), \
('Called-Station-Id', callee), ('h323-conf-id', h323_cid), ('call-id', sip_cid), \
('Acct-Session-Id', sip_cid), ('h323-remote-address', remote_ip)))
if h323_in_cid != None and h323_in_cid != h323_cid:
self._attributes.append(('h323-incoming-conf-id', h323_in_cid))
if radius_parameters is not None:
for attribute, value in radius_parameters:
self._attributes.append((attribute, value))
self.sip_cid = str(sip_cid)
self.complete = True

def addAttribute(self, key, value):
self._attributes.append((key, value))

def conn(self, ua, rtime, origin):
if self.crec:
return
Expand Down
9 changes: 8 additions & 1 deletion sippy/b2bua_radius.py
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,8 @@ def rDone(self, results):
def placeOriginate(self, oroute):
cId, cGUID, cli, cld, body, auth, caller_name = self.eTry.getData()
cld = oroute.cld
radius_parameters = oroute.params.get('radius_parameters', None)

self.huntstop_scodes = oroute.params.get('huntstop_scodes', ())
if 'static_tr_out' in self.global_config:
cld = re_replace(self.global_config['static_tr_out'], cld)
Expand All @@ -295,10 +297,15 @@ def placeOriginate(self, oroute):
self.global_config.getdefault('alive_acct_int', None))
self.acctO.ms_precision = self.global_config.getdefault('precise_acct', False)
self.acctO.setParams(oroute.params.get('bill-to', self.username), oroute.params.get('bill-cli', oroute.cli), \
oroute.params.get('bill-cld', cld), self.cGUID, self.cId, host)
oroute.params.get('bill-cld', cld), self.cGUID, self.cId, host, radius_parameters=radius_parameters)
else:
self.acctO = None
self.acctA.credit_time = oroute.credit_time

if radius_parameters:
for attribute, value in radius_parameters:
self.acctA.addAttribute(attribute, value)

conn_handlers = [self.oConn]
disc_handlers = []
if not oroute.forward_on_fail and self.global_config['acct_enable']:
Expand Down