Skip to content
Snippets Groups Projects
Commit e0472eb1 authored by Pascal Cadotte Michaud's avatar Pascal Cadotte Michaud
Browse files

contrib/sip_to_pjsip: handle setvar in conversion

Given a sip.conf with the following content:

setvar FOO=1
setvar BAR=42

I want my generated pjsip.conf to containt the following set_vars

set_var FOO=1
set_var BAR=42

in the matching endpoint section.

Change-Id: I6c822401fda4133c3b44bf31e655b4eb939d4d26
parent 0b695d1e
Branches
Tags
No related merge requests found
...@@ -40,6 +40,11 @@ def section_by_type(section, pjsip, type): ...@@ -40,6 +40,11 @@ def section_by_type(section, pjsip, type):
return sect return sect
def ignore(key=None, val=None, section=None, pjsip=None,
nmapped=None, type='endpoint'):
"""Ignore a key and mark it as mapped"""
def set_value(key=None, val=None, section=None, pjsip=None, def set_value(key=None, val=None, section=None, pjsip=None,
nmapped=None, type='endpoint'): nmapped=None, type='endpoint'):
"""Sets the key to the value within the section in pjsip.conf""" """Sets the key to the value within the section in pjsip.conf"""
...@@ -508,6 +513,7 @@ peer_map = [ ...@@ -508,6 +513,7 @@ peer_map = [
['dtlscapath', set_value('dtls_ca_path')], ['dtlscapath', set_value('dtls_ca_path')],
['dtlssetup', set_value('dtls_setup')], ['dtlssetup', set_value('dtls_setup')],
['encryption_taglen', from_encryption_taglen], ['encryption_taglen', from_encryption_taglen],
['setvar', ignore],
############################ maps to an aor ################################### ############################ maps to an aor ###################################
...@@ -1117,6 +1123,19 @@ def map_registrations(sip, pjsip, nmapped): ...@@ -1117,6 +1123,19 @@ def map_registrations(sip, pjsip, nmapped):
reg.write(pjsip, nmapped) reg.write(pjsip, nmapped)
def map_setvars(sip, section, pjsip, nmapped):
"""
Map all setvar in peer section to the appropriate endpoint set_var
"""
try:
setvars = sip.section(section)[0].get('setvar')
except LookupError:
return
for setvar in setvars:
set_value('set_var', setvar, section, pjsip, nmapped)
def map_peer(sip, section, pjsip, nmapped): def map_peer(sip, section, pjsip, nmapped):
""" """
Map the options from a peer section in sip.conf into the appropriate Map the options from a peer section in sip.conf into the appropriate
...@@ -1218,6 +1237,7 @@ def convert(sip, filename, non_mappings, include): ...@@ -1218,6 +1237,7 @@ def convert(sip, filename, non_mappings, include):
pass pass
else: else:
map_peer(sip, section, pjsip, nmapped) map_peer(sip, section, pjsip, nmapped)
map_setvars(sip, section, pjsip, nmapped)
find_non_mapped(sip.defaults(), nmapped) find_non_mapped(sip.defaults(), nmapped)
find_non_mapped(sip.sections(), nmapped) find_non_mapped(sip.sections(), nmapped)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment