Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Index: tests/channels/pjsip/subscriptions/rls/lists/nominal/tests.yaml
- ===================================================================
- --- tests/channels/pjsip/subscriptions/rls/lists/nominal/tests.yaml (revision 0)
- +++ tests/channels/pjsip/subscriptions/rls/lists/nominal/tests.yaml (revision 0)
- @@ -0,0 +1,3 @@
- +tests:
- + - dir: 'presence'
- + - dir: 'mwi'
- Property changes on: tests/channels/pjsip/subscriptions/rls/lists/nominal/tests.yaml
- ___________________________________________________________________
- Added: svn:keywords
- + Author Date Id Revision
- Added: svn:eol-style
- + native
- Added: svn:mime-type
- + text/plain
- Index: tests/channels/pjsip/subscriptions/rls/lists/nominal/presence/initial_notify/notify.py
- ===================================================================
- --- tests/channels/pjsip/subscriptions/rls/lists/nominal/presence/initial_notify/notify.py (revision 0)
- +++ tests/channels/pjsip/subscriptions/rls/lists/nominal/presence/initial_notify/notify.py (revision 0)
- @@ -0,0 +1,60 @@
- +#/usr/bin/env python
- +
- +import sys
- +import logging
- +
- +sys.path.append('lib/python')
- +sys.path.append('tests/channels/pjsip/subscriptions/rls')
- +
- +from pcap import VOIPListener
- +from rls_integrity import RLSValidator
- +
- +LOGGER = logging.getLogger(__name__)
- +
- +LIST_NAME = 'pres_list'
- +RESOURCES = {
- + 'alice': {
- + 'type': 'PIDF',
- + 'state': 'active'
- + },
- + 'bob': {
- + 'type': 'PIDF',
- + 'state': 'active'
- + }
- + }
- +
- +
- +class IntegrityCheck(VOIPListener):
- + def __init__(self, module_config, test_object):
- + """Create listener and add AMI observer/callbacks."""
- + VOIPListener.__init__(self, module_config, test_object)
- + self.add_callback('SIP', self.multipart_handler)
- + self.test_object = test_object
- + self.token = test_object.create_fail_token("Haven't handled all "
- + "expected NOTIFY packets.")
- +
- + def multipart_handler(self, packet):
- + """Checks multipart packets to see if NOTIFY messages have
- + anticipated data.
- + """
- + if 'NOTIFY' not in packet.request_line:
- + return
- +
- + if packet.body.packet_type != 'Multipart':
- + return
- +
- + validator = RLSValidator(test_object=self.test_object,
- + packet=packet,
- + version=0,
- + full_state=True,
- + list_name=LIST_NAME,
- + resources=RESOURCES)
- + validator.check_integrity()
- +
- + # If we actually make it to here, the test passes. Yay!
- + self.test_object.set_passed(True)
- + self.test_object.remove_fail_token(self.token)
- +
- + self.remove_callbacks('SIP')
- +
- + self.test_object.stop_reactor()
- Property changes on: tests/channels/pjsip/subscriptions/rls/lists/nominal/presence/initial_notify/notify.py
- ___________________________________________________________________
- Added: svn:eol-style
- + native
- Added: svn:executable
- + *
- Added: svn:mime-type
- + text/plain
- Added: svn:keywords
- + Author Date Id Revision
- Index: tests/channels/pjsip/subscriptions/rls/lists/nominal/presence/initial_notify/test-config.yaml
- ===================================================================
- --- tests/channels/pjsip/subscriptions/rls/lists/nominal/presence/initial_notify/test-config.yaml (revision 0)
- +++ tests/channels/pjsip/subscriptions/rls/lists/nominal/presence/initial_notify/test-config.yaml (revision 0)
- @@ -0,0 +1,58 @@
- +testinfo:
- + summary: 'Baseline test to ensure subscription establishment and RLMI document correctness.'
- + description: |
- + 'This test uses SIPp to establish a subscription to a resource list.
- + The resource list is a presence list that contains two elements,
- + alice@default and bob@default. Once the subscription is established, a
- + PCAP listner is used to ensure that the NOTIFY body sent by Asterisk is
- + what is expected. It checks the following:
- + * That the multipart body contains three parts
- + * That the multipart body consists of one RLMI document and two
- + PIDF documents
- + * That the RLMI document has the proper integrity
- + * There is only a single list element
- + * The version number is 0
- + * There are two resource elements
- + * The two resource elements have an instance element with a
- + cid attribute corresponding to the Content-ID of the two
- + multipart body parts
- + * Each resource element has the expected name element present
- + * The PIDF documents have proper integrity
- + * The reported states are correct for each part
- + * The Content-ID header matches the corresponding cid attribute
- + from the instance element in the RLMI document.'
- +
- +properties:
- + minversion: '13.0.0'
- + dependencies:
- + - python: 'twisted'
- + - python: 'starpy'
- + - python: 'yappcap'
- + - python: 'pyxb'
- + - asterisk: 'res_pjsip'
- + - asterisk: 'res_pjsip_pubsub'
- + tags:
- + - rls
- + - pjsip
- +
- +test-modules:
- + add-test-to-search-path: 'True'
- + test-object:
- + config-section: 'test-case-config'
- + typename: 'sipp.SIPpTestCase'
- + modules:
- + -
- + config-section: 'pcap-config'
- + typename: 'notify.IntegrityCheck'
- +
- +test-case-config:
- + test-iterations:
- + -
- + scenarios:
- + - { 'key-args': {'scenario': 'list_subscribe.xml', '-i': '127.0.0.1', '-p': '5061', '-s': 'pres_list'} }
- +
- +pcap-config:
- + bpf-filter: 'udp port 5061'
- + register-observer: True
- + debug-packets: True
- + device: 'lo'
- Property changes on: tests/channels/pjsip/subscriptions/rls/lists/nominal/presence/initial_notify/test-config.yaml
- ___________________________________________________________________
- Added: svn:mime-type
- + text/plain
- Added: svn:keywords
- + Author Date Id Revision
- Added: svn:eol-style
- + native
- Index: tests/channels/pjsip/subscriptions/rls/lists/nominal/presence/initial_notify/configs/ast1/pjsip.conf
- ===================================================================
- --- tests/channels/pjsip/subscriptions/rls/lists/nominal/presence/initial_notify/configs/ast1/pjsip.conf (revision 0)
- +++ tests/channels/pjsip/subscriptions/rls/lists/nominal/presence/initial_notify/configs/ast1/pjsip.conf (revision 0)
- @@ -0,0 +1,21 @@
- +[pres_list]
- +type = resource_list
- +event = presence
- +list_item = alice
- +list_item = bob
- +
- +[sipp]
- +type=aor
- +max_contacts=1
- +contact=sip:sipp@127.0.0.1:5061
- +
- +[sipp]
- +type = endpoint
- +context = default
- +aors=sipp
- +transport=local
- +
- +[local]
- +type=transport
- +protocol=udp
- +bind=0.0.0.0:5060
- Property changes on: tests/channels/pjsip/subscriptions/rls/lists/nominal/presence/initial_notify/configs/ast1/pjsip.conf
- ___________________________________________________________________
- Added: svn:keywords
- + Author Date Id Revision
- Added: svn:eol-style
- + native
- Added: svn:mime-type
- + text/plain
- Index: tests/channels/pjsip/subscriptions/rls/lists/nominal/presence/initial_notify/configs/ast1/extensions.conf
- ===================================================================
- --- tests/channels/pjsip/subscriptions/rls/lists/nominal/presence/initial_notify/configs/ast1/extensions.conf (revision 0)
- +++ tests/channels/pjsip/subscriptions/rls/lists/nominal/presence/initial_notify/configs/ast1/extensions.conf (revision 0)
- @@ -0,0 +1,3 @@
- +[default]
- +exten => alice,hint,Custom:alice
- +exten => bob,hint,Custom:bob
- Property changes on: tests/channels/pjsip/subscriptions/rls/lists/nominal/presence/initial_notify/configs/ast1/extensions.conf
- ___________________________________________________________________
- Added: svn:mime-type
- + text/plain
- Added: svn:keywords
- + Author Date Id Revision
- Added: svn:eol-style
- + native
- Index: tests/channels/pjsip/subscriptions/rls/lists/nominal/presence/full_state/test-config.yaml
- ===================================================================
- --- tests/channels/pjsip/subscriptions/rls/lists/nominal/presence/full_state/test-config.yaml (revision 0)
- +++ tests/channels/pjsip/subscriptions/rls/lists/nominal/presence/full_state/test-config.yaml (revision 0)
- @@ -0,0 +1,45 @@
- +testinfo:
- + summary: 'Test to ensure that the full_state=yes option is honored in pjsip.conf'
- + description: |
- + 'This test uses SIPp to establish a subscription to a resource list.
- + The resource list is a presence list that contains two elements,
- + alice@default and bob@default. Once established, the test sends a state
- + change for the alice@default resource. A PCAP listener is used to
- + ensure that the NOTIFY bodies sent by Asterisk are valid. Each of the
- + two bodies should convey full resource state of the list. The version
- + number of the list should increment for each NOTIFY body.'
- +
- +properties:
- + minversion: '13.0.0'
- + dependencies:
- + - python: 'twisted'
- + - python: 'starpy'
- + - python: 'yappcap'
- + - python: 'pyxb'
- + - asterisk: 'res_pjsip'
- + - asterisk: 'res_pjsip_pubsub'
- + tags:
- + - rls
- + - pjsip
- +
- +test-modules:
- + add-test-to-search-path: 'True'
- + test-object:
- + config-section: 'test-case-config'
- + typename: 'sipp.SIPpTestCase'
- + modules:
- + -
- + config-section: 'pcap-config'
- + typename: 'full_state.IntegrityCheck'
- +
- +test-case-config:
- + test-iterations:
- + -
- + scenarios:
- + - { 'key-args': {'scenario': 'list_subscribe.xml', '-i': '127.0.0.1', '-p': '5061', '-s': 'pres_list'} }
- +
- +pcap-config:
- + bpf-filter: 'udp port 5061'
- + register-observer: True
- + debug-packets: True
- + device: 'lo'
- Property changes on: tests/channels/pjsip/subscriptions/rls/lists/nominal/presence/full_state/test-config.yaml
- ___________________________________________________________________
- Added: svn:eol-style
- + native
- Added: svn:mime-type
- + text/plain
- Added: svn:keywords
- + Author Date Id Revision
- Index: tests/channels/pjsip/subscriptions/rls/lists/nominal/presence/full_state/configs/ast1/extensions.conf
- ===================================================================
- --- tests/channels/pjsip/subscriptions/rls/lists/nominal/presence/full_state/configs/ast1/extensions.conf (revision 0)
- +++ tests/channels/pjsip/subscriptions/rls/lists/nominal/presence/full_state/configs/ast1/extensions.conf (revision 0)
- @@ -0,0 +1,3 @@
- +[default]
- +exten => alice,hint,Custom:alice
- +exten => bob,hint,Custom:bob
- Property changes on: tests/channels/pjsip/subscriptions/rls/lists/nominal/presence/full_state/configs/ast1/extensions.conf
- ___________________________________________________________________
- Added: svn:eol-style
- + native
- Added: svn:mime-type
- + text/plain
- Added: svn:keywords
- + Author Date Id Revision
- Index: tests/channels/pjsip/subscriptions/rls/lists/nominal/presence/full_state/configs/ast1/pjsip.conf
- ===================================================================
- --- tests/channels/pjsip/subscriptions/rls/lists/nominal/presence/full_state/configs/ast1/pjsip.conf (revision 0)
- +++ tests/channels/pjsip/subscriptions/rls/lists/nominal/presence/full_state/configs/ast1/pjsip.conf (revision 0)
- @@ -0,0 +1,22 @@
- +[pres_list]
- +type = resource_list
- +event = presence
- +list_item = alice
- +list_item = bob
- +full_state = yes
- +
- +[sipp]
- +type=aor
- +max_contacts=1
- +contact=sip:sipp@127.0.0.1:5061
- +
- +[sipp]
- +type = endpoint
- +context = default
- +aors=sipp
- +transport=local
- +
- +[local]
- +type=transport
- +protocol=udp
- +bind=0.0.0.0:5060
- Property changes on: tests/channels/pjsip/subscriptions/rls/lists/nominal/presence/full_state/configs/ast1/pjsip.conf
- ___________________________________________________________________
- Added: svn:mime-type
- + text/plain
- Added: svn:keywords
- + Author Date Id Revision
- Added: svn:eol-style
- + native
- Index: tests/channels/pjsip/subscriptions/rls/lists/nominal/presence/full_state/full_state.py
- ===================================================================
- --- tests/channels/pjsip/subscriptions/rls/lists/nominal/presence/full_state/full_state.py (revision 0)
- +++ tests/channels/pjsip/subscriptions/rls/lists/nominal/presence/full_state/full_state.py (revision 0)
- @@ -0,0 +1,84 @@
- +#/usr/bin/env python
- +
- +import sys
- +import logging
- +
- +sys.path.append('lib/python')
- +sys.path.append('tests/channels/pjsip/subscriptions/rls')
- +
- +from pcap import VOIPListener
- +from rls_integrity import RLSValidator
- +
- +LOGGER = logging.getLogger(__name__)
- +
- +LIST_NAME = 'pres_list'
- +RESOURCES = {
- + 'alice': {
- + 'type': 'PIDF',
- + 'state': 'active'
- + },
- + 'bob': {
- + 'type': 'PIDF',
- + 'state': 'active'
- + }
- +}
- +
- +
- +class IntegrityCheck(VOIPListener):
- + def __init__(self, module_config, test_object):
- + """Create listener and add AMI observer/callbacks."""
- + VOIPListener.__init__(self, module_config, test_object)
- + self.test_object = test_object
- + self.token = test_object.create_fail_token("Haven't handled all "
- + "expected NOTIFY packets.")
- + self.version = 0
- + self.ami = None
- + self.test_object.register_ami_observer(self.ami_connect)
- + self.test_object.register_scenario_started_observer(
- + self.scenario_started)
- + self.add_callback('SIP', self.multipart_handler)
- +
- + def multipart_handler(self, packet):
- + """Checks multipart packets to see if NOTIFY messages have
- + anticipated data.
- + """
- + if 'NOTIFY' not in packet.request_line:
- + return
- +
- + if packet.body.packet_type != 'Multipart':
- + return
- +
- + if self.version > 1:
- + return
- +
- + validator = RLSValidator(test_object=self.test_object,
- + packet=packet,
- + version=self.version,
- + full_state=True,
- + list_name=LIST_NAME,
- + resources=RESOURCES)
- + validator.check_integrity()
- + self.version += 1
- +
- + if self.version > 1:
- + # We expect two NOTIFYs only. If we get them, things passed!
- + self.test_object.set_passed(True)
- + self.test_object.remove_fail_token(self.token)
- + self.test_object.stop_reactor()
- +
- + def ami_connect(self, ami):
- + """Callback when AMI connects. Sets test AMI instance."""
- + self.ami = ami
- +
- + def scenario_started(self, scenario):
- + """Callback when SIPp scenario has started.
- +
- + Once the scenario has started, we change the device state
- + of Alice. The result should be that Asterisk sends a NOTIFY.
- + """
- + message = {
- + 'Action': 'SetVar',
- + 'Variable': 'DEVICE_STATE(Custom:alice)',
- + 'Value': 'INUSE'
- + }
- + self.ami.sendMessage(message)
- Property changes on: tests/channels/pjsip/subscriptions/rls/lists/nominal/presence/full_state/full_state.py
- ___________________________________________________________________
- Added: svn:eol-style
- + native
- Added: svn:executable
- + *
- Added: svn:mime-type
- + text/plain
- Added: svn:keywords
- + Author Date Id Revision
- Index: tests/channels/pjsip/subscriptions/rls/lists/nominal/presence/full_state/sipp/list_subscribe.xml
- ===================================================================
- --- tests/channels/pjsip/subscriptions/rls/lists/nominal/presence/full_state/sipp/list_subscribe.xml (revision 0)
- +++ tests/channels/pjsip/subscriptions/rls/lists/nominal/presence/full_state/sipp/list_subscribe.xml (revision 0)
- @@ -0,0 +1,84 @@
- +<?xml version="1.0" encoding="ISO-8859-1" ?>
- +<!DOCTYPE scenario SYSTEM "sipp.dtd">
- +
- +<scenario name="Basic Sipstone UAC">
- + <send retrans="500">
- + <![CDATA[
- +
- + SUBSCRIBE sip:[service]@[remote_ip]:[remote_port] SIP/2.0
- + Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]
- + From: sipp <sip:sipp@[local_ip]:[local_port]>;tag=[pid]SIPpTag00[call_number]
- + To: sut <sip:[service]@[remote_ip]:[remote_port]>
- + Call-ID: [call_id]
- + CSeq: 1 SUBSCRIBE
- + Contact: sip:sipp@[local_ip]:[local_port]
- + Max-Forwards: 70
- + Subject: Performance Test
- + Event: presence
- + Supported: eventlist
- + Accept: application/rlmi+xml
- + Accept: application/pidf+xml
- + Accept: multipart/related
- + Expires: 3600
- + Content-Length: 0
- +
- + ]]>
- + </send>
- +
- + <recv response="100"
- + optional="true">
- + </recv>
- +
- + <recv response="200" rtd="true">
- + <action>
- + <ereg regexp="eventlist" search_in="hdr" header="Require:" check_it="true" assign_to="1" />
- + </action>
- + </recv>
- +
- + <recv request="NOTIFY" crlf="true">
- + <action>
- + <ereg regexp="eventlist" search_in="hdr" header="Require:" check_it="true" assign_to="1" />
- + </action>
- + </recv>
- +
- + <Reference variables="1" />
- +
- + <send>
- + <![CDATA[
- +
- + SIP/2.0 200 OK
- + [last_Via:]
- + [last_From:]
- + [last_To:]
- + [last_Call-ID:]
- + [last_CSeq:]
- + Contact: <sip:[local_ip]:[local_port];transport=[transport]>
- + Content-Length: 0
- +
- + ]]>
- + </send>
- +
- + <recv request="NOTIFY" crlf="true">
- + <action>
- + <ereg regexp="eventlist" search_in="hdr" header="Require:" check_it="true" assign_to="1" />
- + </action>
- + </recv>
- +
- + <Reference variables="1" />
- +
- + <send>
- + <![CDATA[
- +
- + SIP/2.0 200 OK
- + [last_Via:]
- + [last_From:]
- + [last_To:]
- + [last_Call-ID:]
- + [last_CSeq:]
- + Contact: <sip:[local_ip]:[local_port];transport=[transport]>
- + Content-Length: 0
- +
- + ]]>
- + </send>
- +
- +</scenario>
- Property changes on: tests/channels/pjsip/subscriptions/rls/lists/nominal/presence/full_state/sipp/list_subscribe.xml
- ___________________________________________________________________
- Added: svn:mime-type
- + text/plain
- Added: svn:keywords
- + Author Date Id Revision
- Added: svn:eol-style
- + native
- Index: tests/channels/pjsip/subscriptions/rls/lists/nominal/presence/subscription_establishment/sipp/list_subscribe.xml
- ===================================================================
- --- tests/channels/pjsip/subscriptions/rls/lists/nominal/presence/subscription_establishment/sipp/list_subscribe.xml (revision 0)
- +++ tests/channels/pjsip/subscriptions/rls/lists/nominal/presence/subscription_establishment/sipp/list_subscribe.xml (revision 0)
- @@ -0,0 +1,38 @@
- +<?xml version="1.0" encoding="ISO-8859-1" ?>
- +<!DOCTYPE scenario SYSTEM "sipp.dtd">
- +
- +<scenario name="Basic Sipstone UAC">
- + <send retrans="500">
- + <![CDATA[
- +
- + SUBSCRIBE sip:[service]@[remote_ip]:[remote_port] SIP/2.0
- + Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]
- + From: sipp <sip:sipp@[local_ip]:[local_port]>;tag=[pid]SIPpTag00[call_number]
- + To: sut <sip:[service]@[remote_ip]:[remote_port]>
- + Call-ID: [call_id]
- + CSeq: 1 SUBSCRIBE
- + Contact: sip:sipp@[local_ip]:[local_port]
- + Max-Forwards: 70
- + Subject: Performance Test
- + Event: presence
- + Supported: eventlist
- + Accept: application/rlmi+xml
- + Accept: application/pidf+xml
- + Accept: multipart/related
- + Content-Length: 0
- +
- + ]]>
- + </send>
- +
- + <recv response="100"
- + optional="true">
- + </recv>
- +
- + <recv response="200" rtd="true">
- + <action>
- + <ereg regexp="eventlist" search_in="hdr" header="Require:" check_it="true" assign_to="1" />
- + </action>
- + </recv>
- +
- + <Reference variables="1" />
- +</scenario>
- Property changes on: tests/channels/pjsip/subscriptions/rls/lists/nominal/presence/subscription_establishment/sipp/list_subscribe.xml
- ___________________________________________________________________
- Added: svn:mime-type
- + text/plain
- Added: svn:keywords
- + Author Date Id Revision
- Added: svn:eol-style
- + native
- Index: tests/channels/pjsip/subscriptions/rls/lists/nominal/presence/subscription_establishment/test-config.yaml
- ===================================================================
- --- tests/channels/pjsip/subscriptions/rls/lists/nominal/presence/subscription_establishment/test-config.yaml (revision 0)
- +++ tests/channels/pjsip/subscriptions/rls/lists/nominal/presence/subscription_establishment/test-config.yaml (revision 0)
- @@ -0,0 +1,31 @@
- +testinfo:
- + summary: 'This test ensures that a list subscription can be established.'
- + description: |
- + 'This test uses a SIPp scenario to subscribe to a presence list. The
- + SIPp script ensures that Asterisk returns a 200 OK and that a
- + "Require: eventlist" header is present.'
- +
- +properties:
- + minversion: '13.0.0'
- + dependencies:
- + - python: 'twisted'
- + - python: 'starpy'
- + - asterisk: 'res_pjsip'
- + - asterisk: 'res_pjsip_pubsub'
- + - sipp:
- + version: 'v3.0'
- + tags:
- + - rls
- + - pjsip
- +
- +test-modules:
- + add-test-to-search-path: 'True'
- + test-object:
- + config-section: 'test-case-config'
- + typename: 'sipp.SIPpTestCase'
- +
- +test-case-config:
- + test-iterations:
- + -
- + scenarios:
- + - { 'key-args': {'scenario': 'list_subscribe.xml', '-i': '127.0.0.1', '-p': '5061', '-s': 'pres_list'} }
- Property changes on: tests/channels/pjsip/subscriptions/rls/lists/nominal/presence/subscription_establishment/test-config.yaml
- ___________________________________________________________________
- Added: svn:eol-style
- + native
- Added: svn:mime-type
- + text/plain
- Added: svn:keywords
- + Author Date Id Revision
- Index: tests/channels/pjsip/subscriptions/rls/lists/nominal/presence/subscription_establishment/configs/ast1/extensions.conf
- ===================================================================
- --- tests/channels/pjsip/subscriptions/rls/lists/nominal/presence/subscription_establishment/configs/ast1/extensions.conf (revision 0)
- +++ tests/channels/pjsip/subscriptions/rls/lists/nominal/presence/subscription_establishment/configs/ast1/extensions.conf (revision 0)
- @@ -0,0 +1,3 @@
- +[default]
- +exten => alice,hint,Custom:alice
- +exten => bob,hint,Custom:bob
- Property changes on: tests/channels/pjsip/subscriptions/rls/lists/nominal/presence/subscription_establishment/configs/ast1/extensions.conf
- ___________________________________________________________________
- Added: svn:mime-type
- + text/plain
- Added: svn:keywords
- + Author Date Id Revision
- Added: svn:eol-style
- + native
- Index: tests/channels/pjsip/subscriptions/rls/lists/nominal/presence/subscription_establishment/configs/ast1/pjsip.conf
- ===================================================================
- --- tests/channels/pjsip/subscriptions/rls/lists/nominal/presence/subscription_establishment/configs/ast1/pjsip.conf (revision 0)
- +++ tests/channels/pjsip/subscriptions/rls/lists/nominal/presence/subscription_establishment/configs/ast1/pjsip.conf (revision 0)
- @@ -0,0 +1,21 @@
- +[pres_list]
- +type = resource_list
- +event = presence
- +list_item = alice
- +list_item = bob
- +
- +[sipp]
- +type=aor
- +max_contacts=1
- +contact=sip:sipp@127.0.0.1:5061
- +
- +[sipp]
- +type = endpoint
- +context = default
- +aors=sipp
- +transport=local
- +
- +[local]
- +type=transport
- +protocol=udp
- +bind=0.0.0.0:5060
- Property changes on: tests/channels/pjsip/subscriptions/rls/lists/nominal/presence/subscription_establishment/configs/ast1/pjsip.conf
- ___________________________________________________________________
- Added: svn:eol-style
- + native
- Added: svn:mime-type
- + text/plain
- Added: svn:keywords
- + Author Date Id Revision
- Index: tests/channels/pjsip/subscriptions/rls/lists/nominal/presence/resubscribe_full_state/configs/ast1/extensions.conf
- ===================================================================
- --- tests/channels/pjsip/subscriptions/rls/lists/nominal/presence/resubscribe_full_state/configs/ast1/extensions.conf (revision 0)
- +++ tests/channels/pjsip/subscriptions/rls/lists/nominal/presence/resubscribe_full_state/configs/ast1/extensions.conf (revision 0)
- @@ -0,0 +1,4 @@
- +[default]
- +exten => alice,hint,Custom:alice
- +exten => bob,hint,Custom:bob
- +
- Property changes on: tests/channels/pjsip/subscriptions/rls/lists/nominal/presence/resubscribe_full_state/configs/ast1/extensions.conf
- ___________________________________________________________________
- Added: svn:mime-type
- + text/plain
- Added: svn:keywords
- + Author Date Id Revision
- Added: svn:eol-style
- + native
- Index: tests/channels/pjsip/subscriptions/rls/lists/nominal/presence/resubscribe_full_state/configs/ast1/pjsip.conf
- ===================================================================
- --- tests/channels/pjsip/subscriptions/rls/lists/nominal/presence/resubscribe_full_state/configs/ast1/pjsip.conf (revision 0)
- +++ tests/channels/pjsip/subscriptions/rls/lists/nominal/presence/resubscribe_full_state/configs/ast1/pjsip.conf (revision 0)
- @@ -0,0 +1,22 @@
- +[pres_list]
- +type = resource_list
- +event = presence
- +list_item = alice
- +list_item = bob
- +full_state = yes
- +
- +[sipp]
- +type=aor
- +max_contacts=1
- +contact=sip:sipp@127.0.0.1:5061
- +
- +[sipp]
- +type = endpoint
- +context = default
- +aors=sipp
- +transport=local
- +
- +[local]
- +type=transport
- +protocol=udp
- +bind=0.0.0.0:5060
- Property changes on: tests/channels/pjsip/subscriptions/rls/lists/nominal/presence/resubscribe_full_state/configs/ast1/pjsip.conf
- ___________________________________________________________________
- Added: svn:mime-type
- + text/plain
- Added: svn:keywords
- + Author Date Id Revision
- Added: svn:eol-style
- + native
- Index: tests/channels/pjsip/subscriptions/rls/lists/nominal/presence/resubscribe_full_state/sipp/resubscribe.xml
- ===================================================================
- --- tests/channels/pjsip/subscriptions/rls/lists/nominal/presence/resubscribe_full_state/sipp/resubscribe.xml (revision 0)
- +++ tests/channels/pjsip/subscriptions/rls/lists/nominal/presence/resubscribe_full_state/sipp/resubscribe.xml (revision 0)
- @@ -0,0 +1,112 @@
- +<?xml version="1.0" encoding="ISO-8859-1" ?>
- +<!DOCTYPE scenario SYSTEM "sipp.dtd">
- +
- +<scenario name="Basic Sipstone UAC">
- + <send retrans="500">
- + <![CDATA[
- +
- + SUBSCRIBE sip:[service]@[remote_ip]:[remote_port] SIP/2.0
- + Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]
- + From: sipp <sip:sipp@[local_ip]:[local_port]>;tag=[pid]SIPpTag00[call_number]
- + To: sut <sip:[service]@[remote_ip]:[remote_port]>
- + Call-ID: [call_id]
- + CSeq: 1 SUBSCRIBE
- + Contact: sip:sipp@[local_ip]:[local_port]
- + Max-Forwards: 70
- + Subject: Performance Test
- + Event: presence
- + Supported: eventlist
- + Accept: application/rlmi+xml
- + Accept: application/pidf+xml
- + Accept: multipart/related
- + Expires: 3600
- + Content-Length: 0
- +
- + ]]>
- + </send>
- +
- + <recv response="100"
- + optional="true">
- + </recv>
- +
- + <recv response="200" rtd="true">
- + <action>
- + <ereg regexp="eventlist" search_in="hdr" header="Require:" check_it="true" assign_to="1" />
- + </action>
- + </recv>
- +
- + <!-- Initial NOTIFY upon subscribing -->
- + <recv request="NOTIFY" crlf="true">
- + <action>
- + <ereg regexp="eventlist" search_in="hdr" header="Require:" check_it="true" assign_to="1" />
- + </action>
- + </recv>
- +
- + <send>
- + <![CDATA[
- +
- + SIP/2.0 200 OK
- + [last_Via:]
- + [last_From:]
- + [last_To:]
- + [last_Call-ID:]
- + [last_CSeq:]
- + Contact: <sip:[local_ip]:[local_port];transport=[transport]>
- + Content-Length: 0
- +
- + ]]>
- + </send>
- +
- + <send retrans="500">
- + <![CDATA[
- +
- + SUBSCRIBE sip:[service]@[remote_ip]:[remote_port] SIP/2.0
- + Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]
- + From: sipp <sip:sipp@[local_ip]:[local_port]>;tag=[pid]SIPpTag00[call_number]
- + To: sut <sip:[service]@[remote_ip]:[remote_port]>[peer_tag_param]
- + Call-ID: [call_id]
- + CSeq: [cseq] SUBSCRIBE
- + Contact: sip:sipp@[local_ip]:[local_port]
- + Max-Forwards: 70
- + Subject: Performance Test
- + Event: presence
- + Supported: eventlist
- + Accept: application/rlmi+xml
- + Accept: application/pidf+xml
- + Accept: multipart/related
- + Expires: 3600
- + Content-Length: 0
- +
- + ]]>
- + </send>
- +
- + <!-- NOTIFY upon resubscription -->
- + <recv request="NOTIFY" crlf="true">
- + <action>
- + <ereg regexp="eventlist" search_in="hdr" header="Require:" check_it="true" assign_to="1" />
- + </action>
- + </recv>
- +
- + <recv response="200" crlf="true">
- + <action>
- + <ereg regexp="eventlist" search_in="hdr" header="Require:" check_it="true" assign_to="1" />
- + </action>
- + </recv>
- +
- + <Reference variables="1" />
- +
- + <send>
- + <![CDATA[
- +
- + SIP/2.0 200 OK
- + [last_Via:]
- + [last_From:]
- + [last_To:]
- + [last_Call-ID:]
- + [last_CSeq:]
- + Contact: <sip:[local_ip]:[local_port];transport=[transport]>
- + Content-Length: 0
- +
- + ]]>
- + </send>
- +
- Property changes on: tests/channels/pjsip/subscriptions/rls/lists/nominal/presence/resubscribe_full_state/sipp/resubscribe.xml
- ___________________________________________________________________
- Added: svn:mime-type
- + text/plain
- Added: svn:keywords
- + Author Date Id Revision
- Added: svn:eol-style
- + native
- Index: tests/channels/pjsip/subscriptions/rls/lists/nominal/presence/resubscribe_full_state/resubscribe.py
- ===================================================================
- --- tests/channels/pjsip/subscriptions/rls/lists/nominal/presence/resubscribe_full_state/resubscribe.py (revision 0)
- +++ tests/channels/pjsip/subscriptions/rls/lists/nominal/presence/resubscribe_full_state/resubscribe.py (revision 0)
- @@ -0,0 +1,65 @@
- +#/usr/bin/env python
- +
- +import sys
- +import logging
- +
- +sys.path.append('lib/python')
- +sys.path.append('tests/channels/pjsip/subscriptions/rls')
- +
- +from pcap import VOIPListener
- +from rls_integrity import RLSValidator
- +
- +LOGGER = logging.getLogger(__name__)
- +
- +LIST_NAME = 'pres_list'
- +RESOURCES = {
- + 'alice': {
- + 'type': 'PIDF',
- + 'state': 'active'
- + },
- + 'bob': {
- + 'type': 'PIDF',
- + 'state': 'active'
- + }
- +}
- +
- +
- +class IntegrityCheck(VOIPListener):
- + def __init__(self, module_config, test_object):
- + """Create listener and add AMI observer/callbacks."""
- + VOIPListener.__init__(self, module_config, test_object)
- + self.test_object = test_object
- + self.token = test_object.create_fail_token("Haven't handled all "
- + "expected NOTIFY packets.")
- + self.version = 0
- + self.ami = None
- + self.add_callback('SIP', self.multipart_handler)
- +
- + def multipart_handler(self, packet):
- + """Checks multipart packets to see if NOTIFY messages have
- + anticipated data.
- + """
- + if 'NOTIFY' not in packet.request_line:
- + return
- +
- + if packet.body.packet_type != 'Multipart':
- + return
- +
- + if self.version > 1:
- + # This should be impossible, but check for it anyway
- + return
- +
- + validator = RLSValidator(test_object=self.test_object,
- + packet=packet,
- + version=self.version,
- + full_state=True,
- + list_name=LIST_NAME,
- + resources=RESOURCES)
- + validator.check_integrity()
- + self.version += 1
- +
- + if self.version > 1:
- + # We expect two NOTIFYs only. If we get them, things passed!
- + self.test_object.set_passed(True)
- + self.test_object.remove_fail_token(self.token)
- + self.test_object.stop_reactor()
- Property changes on: tests/channels/pjsip/subscriptions/rls/lists/nominal/presence/resubscribe_full_state/resubscribe.py
- ___________________________________________________________________
- Added: svn:executable
- + *
- Added: svn:mime-type
- + text/plain
- Added: svn:keywords
- + Author Date Id Revision
- Added: svn:eol-style
- + native
- Index: tests/channels/pjsip/subscriptions/rls/lists/nominal/presence/resubscribe_full_state/test-config.yaml
- ===================================================================
- --- tests/channels/pjsip/subscriptions/rls/lists/nominal/presence/resubscribe_full_state/test-config.yaml (revision 0)
- +++ tests/channels/pjsip/subscriptions/rls/lists/nominal/presence/resubscribe_full_state/test-config.yaml (revision 0)
- @@ -0,0 +1,46 @@
- +testinfo:
- + summary: 'Test to ensure that full state is sent on resubscription'
- + description: |
- + 'This test uses SIPp to establish a subscription to a resource list.
- + The resource list is a presence list that contains two elements,
- + alice@default and bob@default. Once the subscription is established,
- + the scenario resubscribes to the list. A PCAP listener is used to
- + ensure that the NOTIFY bodies sent by Asterisk are valid. Each of the
- + two bodies should convey full resource state of the list, even though
- + the list is configured to receive partial state notifications. The
- + version number of the list should increment for each NOTIFY body.'
- +
- +properties:
- + minversion: '13.0.0'
- + dependencies:
- + - python: 'twisted'
- + - python: 'starpy'
- + - python: 'yappcap'
- + - python: 'pyxb'
- + - asterisk: 'res_pjsip'
- + - asterisk: 'res_pjsip_pubsub'
- + tags:
- + - rls
- + - pjsip
- +
- +test-modules:
- + add-test-to-search-path: 'True'
- + test-object:
- + config-section: 'test-case-config'
- + typename: 'sipp.SIPpTestCase'
- + modules:
- + -
- + config-section: 'pcap-config'
- + typename: 'resubscribe.IntegrityCheck'
- +
- +test-case-config:
- + test-iterations:
- + -
- + scenarios:
- + - { 'key-args': {'scenario': 'resubscribe.xml', '-i': '127.0.0.1', '-p': '5061', '-s': 'pres_list'} }
- +
- +pcap-config:
- + bpf-filter: 'udp port 5061'
- + register-observer: True
- + debug-packets: True
- + device: 'lo'
- Property changes on: tests/channels/pjsip/subscriptions/rls/lists/nominal/presence/resubscribe_full_state/test-config.yaml
- ___________________________________________________________________
- Added: svn:eol-style
- + native
- Added: svn:mime-type
- + text/plain
- Added: svn:keywords
- + Author Date Id Revision
- Index: tests/channels/pjsip/subscriptions/rls/lists/nominal/presence/termination_full_state/configs/ast1/pjsip.conf
- ===================================================================
- --- tests/channels/pjsip/subscriptions/rls/lists/nominal/presence/termination_full_state/configs/ast1/pjsip.conf (revision 0)
- +++ tests/channels/pjsip/subscriptions/rls/lists/nominal/presence/termination_full_state/configs/ast1/pjsip.conf (revision 0)
- @@ -0,0 +1,22 @@
- +[pres_list]
- +type = resource_list
- +event = presence
- +list_item = alice
- +list_item = bob
- +full_state = yes
- +
- +[sipp]
- +type=aor
- +max_contacts=1
- +contact=sip:sipp@127.0.0.1:5061
- +
- +[sipp]
- +type = endpoint
- +context = default
- +aors=sipp
- +transport=local
- +
- +[local]
- +type=transport
- +protocol=udp
- +bind=0.0.0.0:5060
- Property changes on: tests/channels/pjsip/subscriptions/rls/lists/nominal/presence/termination_full_state/configs/ast1/pjsip.conf
- ___________________________________________________________________
- Added: svn:mime-type
- + text/plain
- Added: svn:keywords
- + Author Date Id Revision
- Added: svn:eol-style
- + native
- Index: tests/channels/pjsip/subscriptions/rls/lists/nominal/presence/termination_full_state/configs/ast1/extensions.conf
- ===================================================================
- --- tests/channels/pjsip/subscriptions/rls/lists/nominal/presence/termination_full_state/configs/ast1/extensions.conf (revision 0)
- +++ tests/channels/pjsip/subscriptions/rls/lists/nominal/presence/termination_full_state/configs/ast1/extensions.conf (revision 0)
- @@ -0,0 +1,4 @@
- +[default]
- +exten => alice,hint,Custom:alice
- +exten => bob,hint,Custom:bob
- +
- Property changes on: tests/channels/pjsip/subscriptions/rls/lists/nominal/presence/termination_full_state/configs/ast1/extensions.conf
- ___________________________________________________________________
- Added: svn:mime-type
- + text/plain
- Added: svn:keywords
- + Author Date Id Revision
- Added: svn:eol-style
- + native
- Index: tests/channels/pjsip/subscriptions/rls/lists/nominal/presence/termination_full_state/sipp/termination.xml
- ===================================================================
- --- tests/channels/pjsip/subscriptions/rls/lists/nominal/presence/termination_full_state/sipp/termination.xml (revision 0)
- +++ tests/channels/pjsip/subscriptions/rls/lists/nominal/presence/termination_full_state/sipp/termination.xml (revision 0)
- @@ -0,0 +1,118 @@
- +<?xml version="1.0" encoding="ISO-8859-1" ?>
- +<!DOCTYPE scenario SYSTEM "sipp.dtd">
- +
- +<scenario name="Basic Sipstone UAC">
- + <send retrans="500">
- + <![CDATA[
- +
- + SUBSCRIBE sip:[service]@[remote_ip]:[remote_port] SIP/2.0
- + Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]
- + From: sipp <sip:sipp@[local_ip]:[local_port]>;tag=[pid]SIPpTag00[call_number]
- + To: sut <sip:[service]@[remote_ip]:[remote_port]>
- + Call-ID: [call_id]
- + CSeq: 1 SUBSCRIBE
- + Contact: sip:sipp@[local_ip]:[local_port]
- + Max-Forwards: 70
- + Subject: Performance Test
- + Event: presence
- + Supported: eventlist
- + Accept: application/rlmi+xml
- + Accept: application/pidf+xml
- + Accept: multipart/related
- + Expires: 3600
- + Content-Length: 0
- +
- + ]]>
- + </send>
- +
- + <recv response="100"
- + optional="true">
- + </recv>
- +
- + <recv response="200" rtd="true">
- + <action>
- + <ereg regexp="eventlist" search_in="hdr" header="Require:" check_it="true" assign_to="1" />
- + </action>
- + </recv>
- +
- + <!-- Initial NOTIFY upon subscribing -->
- + <recv request="NOTIFY" crlf="true">
- + <action>
- + <ereg regexp="eventlist" search_in="hdr" header="Require:" check_it="true" assign_to="1" />
- + </action>
- + </recv>
- +
- + <send>
- + <![CDATA[
- +
- + SIP/2.0 200 OK
- + [last_Via:]
- + [last_From:]
- + [last_To:]
- + [last_Call-ID:]
- + [last_CSeq:]
- + Contact: <sip:[local_ip]:[local_port];transport=[transport]>
- + Content-Length: 0
- +
- + ]]>
- + </send>
- +
- + <send retrans="500" start_txn="howdy">
- + <![CDATA[
- +
- + SUBSCRIBE sip:[service]@[remote_ip]:[remote_port] SIP/2.0
- + Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]
- + From: sipp <sip:sipp@[local_ip]:[local_port]>;tag=[pid]SIPpTag00[call_number]
- + To: sut <sip:[service]@[remote_ip]:[remote_port]>[peer_tag_param]
- + Call-ID: [call_id]
- + CSeq: [cseq] SUBSCRIBE
- + Contact: sip:sipp@[local_ip]:[local_port]
- + Max-Forwards: 70
- + Subject: Performance Test
- + Event: presence
- + Supported: eventlist
- + Accept: application/rlmi+xml
- + Accept: application/pidf+xml
- + Accept: multipart/related
- + Expires: 0
- + Content-Length: 0
- +
- + ]]>
- + </send>
- +
- + <!-- NOTIFY upon termination -->
- + <recv request="NOTIFY" crlf="true">
- + <action>
- + <ereg regexp="eventlist" search_in="hdr" header="Require:" check_it="true" assign_to="1" />
- + </action>
- + </recv>
- +
- + <recv response="200" rtd="true">
- + <action>
- + <ereg regexp="eventlist" search_in="hdr" header="Require:" check_it="true" assign_to="1" />
- + </action>
- + </recv>
- +
- + <send>
- + <![CDATA[
- +
- + SIP/2.0 200 OK
- + [last_Via:]
- + [last_From:]
- + [last_To:]
- + [last_Call-ID:]
- + [last_CSeq:]
- + Contact: <sip:[local_ip]:[local_port];transport=[transport]>
- + Content-Length: 0
- +
- + ]]>
- + </send>
- +
- + <recv response="200" crlf="true" response_txn="howdy">
- + <action>
- + <ereg regexp="eventlist" search_in="hdr" header="Require:" check_it="true" assign_to="1" />
- + </action>
- + </recv>
- +
- + <Reference variables="1" />
- +
- Property changes on: tests/channels/pjsip/subscriptions/rls/lists/nominal/presence/termination_full_state/sipp/termination.xml
- ___________________________________________________________________
- Added: svn:mime-type
- + text/plain
- Added: svn:keywords
- + Author Date Id Revision
- Added: svn:eol-style
- + native
- Index: tests/channels/pjsip/subscriptions/rls/lists/nominal/presence/termination_full_state/termination.py
- ===================================================================
- --- tests/channels/pjsip/subscriptions/rls/lists/nominal/presence/termination_full_state/termination.py (revision 0)
- +++ tests/channels/pjsip/subscriptions/rls/lists/nominal/presence/termination_full_state/termination.py (revision 0)
- @@ -0,0 +1,77 @@
- +#/usr/bin/env python
- +
- +import sys
- +import logging
- +
- +sys.path.append('lib/python')
- +sys.path.append('tests/channels/pjsip/subscriptions/rls')
- +
- +from pcap import VOIPListener
- +from rls_integrity import RLSValidator
- +
- +LOGGER = logging.getLogger(__name__)
- +
- +LIST_NAME = 'pres_list'
- +RESOURCES = [
- + {
- + 'alice': {
- + 'type': 'PIDF',
- + 'state': 'active'
- + },
- + 'bob': {
- + 'type': 'PIDF',
- + 'state': 'active'
- + }
- + },
- + {
- + 'alice': {
- + 'type': 'PIDF',
- + 'state': 'terminated'
- + },
- + 'bob': {
- + 'type': 'PIDF',
- + 'state': 'terminated'
- + }
- + }
- +]
- +
- +
- +class IntegrityCheck(VOIPListener):
- +
- + def __init__(self, module_config, test_object):
- + """Create listener and add AMI observer/callbacks."""
- + VOIPListener.__init__(self, module_config, test_object)
- + self.test_object = test_object
- + self.token = test_object.create_fail_token("Haven't handled all "
- + "expected NOTIFY packets.")
- + self.version = 0
- + self.ami = None
- + self.add_callback('SIP', self.multipart_handler)
- +
- + def multipart_handler(self, packet):
- + """Checks multipart packets to see if NOTIFY messages have
- + anticipated data.
- + """
- + if 'NOTIFY' not in packet.request_line:
- + return
- +
- + if packet.body.packet_type != 'Multipart':
- + return
- +
- + if self.version > 1:
- + return
- +
- + validator = RLSValidator(test_object=self.test_object,
- + packet=packet,
- + version=self.version,
- + full_state=True,
- + list_name=LIST_NAME,
- + resources=RESOURCES[self.version])
- + validator.check_integrity()
- + self.version += 1
- +
- + if self.version > 1:
- + # We expect two NOTIFYs only. If we get them, things passed!
- + self.test_object.set_passed(True)
- + self.test_object.remove_fail_token(self.token)
- + self.test_object.stop_reactor()
- Property changes on: tests/channels/pjsip/subscriptions/rls/lists/nominal/presence/termination_full_state/termination.py
- ___________________________________________________________________
- Added: svn:mime-type
- + text/plain
- Added: svn:keywords
- + Author Date Id Revision
- Added: svn:eol-style
- + native
- Added: svn:executable
- + *
- Index: tests/channels/pjsip/subscriptions/rls/lists/nominal/presence/termination_full_state/test-config.yaml
- ===================================================================
- --- tests/channels/pjsip/subscriptions/rls/lists/nominal/presence/termination_full_state/test-config.yaml (revision 0)
- +++ tests/channels/pjsip/subscriptions/rls/lists/nominal/presence/termination_full_state/test-config.yaml (revision 0)
- @@ -0,0 +1,47 @@
- +testinfo:
- + summary: 'Test to ensure that full state is sent on resubscription'
- + description: |
- + 'This test uses SIPp to establish a subscription to a resource list.
- + The resource list is a presence list that contains two elements,
- + alice@default and bob@default. Once the subscription is established,
- + the scenario terminates its subscription to the list. A PCAP listener
- + is used to ensure that the NOTIFY bodies sent by Asterisk are valid.
- + Each of the two bodies should convey full resource state of the list,
- + even though the list is configured to receive partial state
- + notifications. The version number of the list should increment for
- + each NOTIFY body.'
- +
- +properties:
- + minversion: '13.0.0'
- + dependencies:
- + - python: 'twisted'
- + - python: 'starpy'
- + - python: 'yappcap'
- + - python: 'pyxb'
- + - asterisk: 'res_pjsip'
- + - asterisk: 'res_pjsip_pubsub'
- + tags:
- + - rls
- + - pjsip
- +
- +test-modules:
- + add-test-to-search-path: 'True'
- + test-object:
- + config-section: 'test-case-config'
- + typename: 'sipp.SIPpTestCase'
- + modules:
- + -
- + config-section: 'pcap-config'
- + typename: 'termination.IntegrityCheck'
- +
- +test-case-config:
- + test-iterations:
- + -
- + scenarios:
- + - { 'key-args': {'scenario': 'termination.xml', '-i': '127.0.0.1', '-p': '5061', '-s': 'pres_list'} }
- +
- +pcap-config:
- + bpf-filter: 'udp port 5061'
- + register-observer: True
- + debug-packets: True
- + device: 'lo'
- Property changes on: tests/channels/pjsip/subscriptions/rls/lists/nominal/presence/termination_full_state/test-config.yaml
- ___________________________________________________________________
- Added: svn:eol-style
- + native
- Added: svn:mime-type
- + text/plain
- Added: svn:keywords
- + Author Date Id Revision
- Index: tests/channels/pjsip/subscriptions/rls/lists/nominal/presence/partial_state/configs/ast1/pjsip.conf
- ===================================================================
- --- tests/channels/pjsip/subscriptions/rls/lists/nominal/presence/partial_state/configs/ast1/pjsip.conf (revision 0)
- +++ tests/channels/pjsip/subscriptions/rls/lists/nominal/presence/partial_state/configs/ast1/pjsip.conf (revision 0)
- @@ -0,0 +1,22 @@
- +[pres_list]
- +type = resource_list
- +event = presence
- +list_item = alice
- +list_item = bob
- +full_state = no
- +
- +[sipp]
- +type=aor
- +max_contacts=1
- +contact=sip:sipp@127.0.0.1:5061
- +
- +[sipp]
- +type = endpoint
- +context = default
- +aors=sipp
- +transport=local
- +
- +[local]
- +type=transport
- +protocol=udp
- +bind=0.0.0.0:5060
- Property changes on: tests/channels/pjsip/subscriptions/rls/lists/nominal/presence/partial_state/configs/ast1/pjsip.conf
- ___________________________________________________________________
- Added: svn:mime-type
- + text/plain
- Added: svn:keywords
- + Author Date Id Revision
- Added: svn:eol-style
- + native
- Index: tests/channels/pjsip/subscriptions/rls/lists/nominal/presence/partial_state/configs/ast1/extensions.conf
- ===================================================================
- --- tests/channels/pjsip/subscriptions/rls/lists/nominal/presence/partial_state/configs/ast1/extensions.conf (revision 0)
- +++ tests/channels/pjsip/subscriptions/rls/lists/nominal/presence/partial_state/configs/ast1/extensions.conf (revision 0)
- @@ -0,0 +1,3 @@
- +[default]
- +exten => alice,hint,Custom:alice
- +exten => bob,hint,Custom:bob
- Property changes on: tests/channels/pjsip/subscriptions/rls/lists/nominal/presence/partial_state/configs/ast1/extensions.conf
- ___________________________________________________________________
- Added: svn:eol-style
- + native
- Added: svn:mime-type
- + text/plain
- Added: svn:keywords
- + Author Date Id Revision
- Index: tests/channels/pjsip/subscriptions/rls/lists/nominal/presence/partial_state/sipp/list_subscribe.xml
- ===================================================================
- --- tests/channels/pjsip/subscriptions/rls/lists/nominal/presence/partial_state/sipp/list_subscribe.xml (revision 0)
- +++ tests/channels/pjsip/subscriptions/rls/lists/nominal/presence/partial_state/sipp/list_subscribe.xml (revision 0)
- @@ -0,0 +1,84 @@
- +<?xml version="1.0" encoding="ISO-8859-1" ?>
- +<!DOCTYPE scenario SYSTEM "sipp.dtd">
- +
- +<scenario name="Basic Sipstone UAC">
- + <send retrans="500">
- + <![CDATA[
- +
- + SUBSCRIBE sip:[service]@[remote_ip]:[remote_port] SIP/2.0
- + Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]
- + From: sipp <sip:sipp@[local_ip]:[local_port]>;tag=[pid]SIPpTag00[call_number]
- + To: sut <sip:[service]@[remote_ip]:[remote_port]>
- + Call-ID: [call_id]
- + CSeq: 1 SUBSCRIBE
- + Contact: sip:sipp@[local_ip]:[local_port]
- + Max-Forwards: 70
- + Subject: Performance Test
- + Event: presence
- + Supported: eventlist
- + Accept: application/rlmi+xml
- + Accept: application/pidf+xml
- + Accept: multipart/related
- + Expires: 3600
- + Content-Length: 0
- +
- + ]]>
- + </send>
- +
- + <recv response="100"
- + optional="true">
- + </recv>
- +
- + <recv response="200" rtd="true">
- + <action>
- + <ereg regexp="eventlist" search_in="hdr" header="Require:" check_it="true" assign_to="1" />
- + </action>
- + </recv>
- +
- + <recv request="NOTIFY" crlf="true">
- + <action>
- + <ereg regexp="eventlist" search_in="hdr" header="Require:" check_it="true" assign_to="1" />
- + </action>
- + </recv>
- +
- + <Reference variables="1" />
- +
- + <send>
- + <![CDATA[
- +
- + SIP/2.0 200 OK
- + [last_Via:]
- + [last_From:]
- + [last_To:]
- + [last_Call-ID:]
- + [last_CSeq:]
- + Contact: <sip:[local_ip]:[local_port];transport=[transport]>
- + Content-Length: 0
- +
- + ]]>
- + </send>
- +
- + <recv request="NOTIFY" crlf="true">
- + <action>
- + <ereg regexp="eventlist" search_in="hdr" header="Require:" check_it="true" assign_to="1" />
- + </action>
- + </recv>
- +
- + <Reference variables="1" />
- +
- + <send>
- + <![CDATA[
- +
- + SIP/2.0 200 OK
- + [last_Via:]
- + [last_From:]
- + [last_To:]
- + [last_Call-ID:]
- + [last_CSeq:]
- + Contact: <sip:[local_ip]:[local_port];transport=[transport]>
- + Content-Length: 0
- +
- + ]]>
- + </send>
- +
- +</scenario>
- Property changes on: tests/channels/pjsip/subscriptions/rls/lists/nominal/presence/partial_state/sipp/list_subscribe.xml
- ___________________________________________________________________
- Added: svn:mime-type
- + text/plain
- Added: svn:keywords
- + Author Date Id Revision
- Added: svn:eol-style
- + native
- Index: tests/channels/pjsip/subscriptions/rls/lists/nominal/presence/partial_state/test-config.yaml
- ===================================================================
- --- tests/channels/pjsip/subscriptions/rls/lists/nominal/presence/partial_state/test-config.yaml (revision 0)
- +++ tests/channels/pjsip/subscriptions/rls/lists/nominal/presence/partial_state/test-config.yaml (revision 0)
- @@ -0,0 +1,46 @@
- +testinfo:
- + summary: 'Test to ensure that the full_state=no option is honored in pjsip.conf'
- + description: |
- + 'This test uses SIPp to establish a subscription to a resource list.
- + The resource list is a presence list that contains two elements,
- + alice@default and bob@default. Once established, the test sends a state
- + change for the alice@default resource. A PCAP listener is used to
- + ensure that the NOTIFY bodies sent by Asterisk are valid. The initial
- + NOTIFY request should convey full state, and the second NOTIFY request
- + should convey partial state. The version number of the list should increment
- + for each NOTIFY body.'
- +
- +properties:
- + minversion: '13.0.0'
- + dependencies:
- + - python: 'twisted'
- + - python: 'starpy'
- + - python: 'yappcap'
- + - python: 'pyxb'
- + - asterisk: 'res_pjsip'
- + - asterisk: 'res_pjsip_pubsub'
- + tags:
- + - rls
- + - pjsip
- +
- +test-modules:
- + add-test-to-search-path: 'True'
- + test-object:
- + config-section: 'test-case-config'
- + typename: 'sipp.SIPpTestCase'
- + modules:
- + -
- + config-section: 'pcap-config'
- + typename: 'partial_state.IntegrityCheck'
- +
- +test-case-config:
- + test-iterations:
- + -
- + scenarios:
- + - { 'key-args': {'scenario': 'list_subscribe.xml', '-i': '127.0.0.1', '-p': '5061', '-s': 'pres_list'} }
- +
- +pcap-config:
- + bpf-filter: 'udp port 5061'
- + register-observer: True
- + debug-packets: True
- + device: 'lo'
- Property changes on: tests/channels/pjsip/subscriptions/rls/lists/nominal/presence/partial_state/test-config.yaml
- ___________________________________________________________________
- Added: svn:mime-type
- + text/plain
- Added: svn:keywords
- + Author Date Id Revision
- Added: svn:eol-style
- + native
- Index: tests/channels/pjsip/subscriptions/rls/lists/nominal/presence/partial_state/partial_state.py
- ===================================================================
- --- tests/channels/pjsip/subscriptions/rls/lists/nominal/presence/partial_state/partial_state.py (revision 0)
- +++ tests/channels/pjsip/subscriptions/rls/lists/nominal/presence/partial_state/partial_state.py (revision 0)
- @@ -0,0 +1,97 @@
- +#/usr/bin/env python
- +
- +import sys
- +import logging
- +
- +sys.path.append('lib/python')
- +sys.path.append('tests/channels/pjsip/subscriptions/rls')
- +
- +from pcap import VOIPListener
- +from rls_integrity import RLSValidator
- +
- +LOGGER = logging.getLogger(__name__)
- +
- +LIST_NAME = 'pres_list'
- +
- +RESOURCES = [
- + # First NOTIFY will have all resources present
- + {
- + 'alice': {
- + 'type': 'PIDF',
- + 'state': 'active'
- + },
- + 'bob': {
- + 'type': 'PIDF',
- + 'state': 'active'
- + }
- + },
- + # Second NOTIFY will only have the changed resource present
- + {
- + 'alice': {
- + 'type': 'PIDF',
- + 'state': 'active'
- + }
- + }
- +]
- +
- +
- +class IntegrityCheck(VOIPListener):
- + def __init__(self, module_config, test_object):
- + """Create listener and add AMI observer/callbacks."""
- + VOIPListener.__init__(self, module_config, test_object)
- + self.test_object = test_object
- + self.token = test_object.create_fail_token("Haven't handled all "
- + "expected NOTIFY packets.")
- + self.version = 0
- + self.ami = None
- + self.test_object.register_ami_observer(self.ami_connect)
- + self.test_object.register_scenario_started_observer(
- + self.scenario_started)
- + self.add_callback('SIP', self.multipart_handler)
- +
- + def multipart_handler(self, packet):
- + """Checks multipart packets to see if NOTIFY messages have
- + anticipated data.
- + """
- + if 'NOTIFY' not in packet.request_line:
- + return
- +
- + if packet.body.packet_type != 'Multipart':
- + return
- +
- + if self.version > 1:
- + return
- +
- + full_state = True if self.version == 0 else False
- +
- + validator = RLSValidator(test_object=self.test_object,
- + packet=packet,
- + version=self.version,
- + full_state=full_state,
- + list_name=LIST_NAME,
- + resources=RESOURCES[self.version])
- + validator.check_integrity()
- + self.version += 1
- +
- + if self.version > 1:
- + # We expect two NOTIFYs only. If we get them, things passed!
- + self.test_object.set_passed(True)
- + self.test_object.remove_fail_token(self.token)
- + self.test_object.stop_reactor()
- +
- + def ami_connect(self, ami):
- + """Callback when AMI connects. Sets test AMI instance."""
- + self.ami = ami
- +
- + def scenario_started(self, scenario):
- + """Callback when SIPp scenario has started.
- +
- + Once the scenario has started, we change the device state
- + of Alice. The result should be that Asterisk sends a NOTIFY.
- + """
- + message = {
- + 'Action': 'SetVar',
- + 'Variable': 'DEVICE_STATE(Custom:alice)',
- + 'Value': 'INUSE'
- + }
- + self.ami.sendMessage(message)
- Property changes on: tests/channels/pjsip/subscriptions/rls/lists/nominal/presence/partial_state/partial_state.py
- ___________________________________________________________________
- Added: svn:mime-type
- + text/plain
- Added: svn:keywords
- + Author Date Id Revision
- Added: svn:eol-style
- + native
- Added: svn:executable
- + *
- Index: tests/channels/pjsip/subscriptions/rls/lists/tests.yaml
- ===================================================================
- --- tests/channels/pjsip/subscriptions/rls/lists/tests.yaml (revision 0)
- +++ tests/channels/pjsip/subscriptions/rls/lists/tests.yaml (revision 0)
- @@ -0,0 +1,3 @@
- +tests:
- + - dir: 'nominal'
- + - dir: 'off-nominal'
- Property changes on: tests/channels/pjsip/subscriptions/rls/lists/tests.yaml
- ___________________________________________________________________
- Added: svn:mime-type
- + text/plain
- Added: svn:keywords
- + Author Date Id Revision
- Added: svn:eol-style
- + native
- Index: tests/channels/pjsip/subscriptions/rls/tests.yaml
- ===================================================================
- --- tests/channels/pjsip/subscriptions/rls/tests.yaml (revision 0)
- +++ tests/channels/pjsip/subscriptions/rls/tests.yaml (revision 0)
- @@ -0,0 +1,2 @@
- +tests:
- + - dir: 'lists'
- Property changes on: tests/channels/pjsip/subscriptions/rls/tests.yaml
- ___________________________________________________________________
- Added: svn:mime-type
- + text/plain
- Added: svn:keywords
- + Author Date Id Revision
- Added: svn:eol-style
- + native
- Index: tests/channels/pjsip/subscriptions/rls/rls_integrity.py
- ===================================================================
- --- tests/channels/pjsip/subscriptions/rls/rls_integrity.py (revision 0)
- +++ tests/channels/pjsip/subscriptions/rls/rls_integrity.py (revision 0)
- @@ -0,0 +1,232 @@
- +#/usr/bin/env python
- +
- +import logging
- +import xml.etree.ElementTree as ET
- +
- +LOGGER = logging.getLogger(__name__)
- +
- +
- +def count_parts(parts, packet_type):
- + """Count the number of parts of a particular type in a multipart body"""
- + return sum([1 for x in parts if x.body.packet_type == packet_type])
- +
- +
- +class RLSValidator(object):
- + """General class that validates a multipart RLS NOTIFY body"""
- + def __init__(self, test_object, packet, version, full_state, list_name,
- + resources):
- + """Initializer
- +
- + Keyword Arguments:
- + test_object The test object for the running test.
- + packet The Multipart NOTIFY body in full.
- + version The expected RLMI version attribute. Expressed as an integer.
- + full_state The expected RLMI fullState attribute. Expressed as a
- + boolean.
- + list_name The expected RLMI name element value.
- + packet_type The type of body parts to expect other than RLMI.
- + resources A dictionary of the resource names and their expected state.
- + """
- + super(RLSValidator, self).__init__()
- + self.test_object = test_object
- + self.packet = packet
- + self.version = version
- + self.full_state = full_state
- + self.list_name = list_name
- + self.resources = resources
- + self.rlmi_cids = {}
- + self.resource_cids = {}
- +
- + def check_integrity(self):
- + """Validates a multipart RLS body
- +
- + If the multipart body does not pass validation, then the test will
- + fail. If this method returns at all, it means that the body passed
- + validation.
- + """
- +
- + # Number of resources plus an RLMI part
- + if len(self.packet.body.parts) != len(self.resources) + 1:
- + self.fail_test("Unexpected number of parts (%d) in multipart body"
- + % len(self.packet.body.parts))
- +
- + rlmi_parts = count_parts(self.packet.body.parts, 'RLMI')
- + resource_parts = len(self.packet.body.parts) - 1
- +
- + if rlmi_parts != 1:
- + self.fail_test("Unexpected number of RLMI parts (%d) in multipart"
- + "body" % rlmi_parts)
- +
- + if resource_parts != len(self.resources):
- + self.fail_test("Unexpected number of parts (%d) in multipart"
- + "body" % resource_parts)
- +
- + for part in self.packet.body.parts:
- + if part.body.packet_type == 'RLMI':
- + self.validate_rlmi(part.body.list_elem, self.resources, self.list_name)
- + elif part.body.packet_type == 'PIDF':
- + self.validate_pidf(part.body, self.resources)
- + elif part.body.packet_type == 'Multipart':
- + self.validate_multipart(part, self.resources)
- +
- + if len(self.rlmi_cids) != len(self.resource_cids):
- + self.fail_test("Gathered mismatching number of Content IDs. RLMI"
- + "document has %d. Should have %d" %
- + (len(self.rlmi_cids), len(self.resource_cids)))
- +
- + for uri, cid in self.rlmi_cids.iteritems():
- + if uri not in self.resource_cids:
- + self.fail_test("URI not found in %s documents" %
- + (uri))
- + if self.resource_cids.get(uri) != cid:
- + self.fail_test("Mismatching Content ID for URI %s. RLMI"
- + "document has %s. Document has %s" %
- + (uri, cid, self.resource_cids.get(uri)))
- +
- + def validate_rlmi(self, list_elem, resources, list_name):
- + """Validate an RLMI document
- +
- + This method checks the integrity of the list element and calls
- + into a helper method to check the integrity of each resource
- + element in the list.
- +
- + Keyword Arguments:
- + list_elem The XML <list> element in the RLMI body, as parsed by pyxb
- + resources The expected resources dictionary relevant to this RLMI body
- + """
- + if list_elem.version != self.version:
- + self.fail_test("Unexpected RLMI version %d" % list_elem.version)
- +
- + if list_elem.fullState != self.full_state:
- + self.fail_test("Unexpected fullState value %s" %
- + str(list_elem.fullState))
- +
- + if len(list_elem.name) != 1:
- + self.fail_test("Unexpected number of names (%d) in RLMI list" %
- + len(list_elem.name))
- +
- + if len(list_elem.resource) != len(resources):
- + self.fail_test("Unexpected number of resources (%d) in RLMI list" %
- + len(list_elem.resource))
- +
- + if list_elem.name[0].value() != list_name:
- + self.fail_test("Unexpected list name: %s" %
- + list_elem.name[0].value())
- +
- + for resource in list_elem.resource:
- + self.validate_rlmi_resource(resource, resources)
- +
- + def validate_rlmi_resource(self, rlmi_resource, resources):
- + """Validate an RLMI resource
- +
- + This method checks the integrity of a resource XML element within an
- + RLMI list.
- +
- + Keyword Arguments:
- + rlmi_resource The XML <resource> element in the RLMI <list>, as parsed
- + by pyxb
- + resources The expected resources dictionary relevant to this RLMI
- + resource
- + """
- + if not rlmi_resource.uri:
- + self.fail_test("Resource is missing a URI")
- +
- + if len(rlmi_resource.name) != 1:
- + self.fail_test("Unexpected number of names (%d) in resource" %
- + len(rlmi_resource.name))
- +
- + if len(rlmi_resource.instance) != 1:
- + self.fail_test("Unexpeced number of instances (%d) in resource" %
- + len(rlmi_resource.instance))
- +
- + name = rlmi_resource.name[0].value()
- + if name not in resources:
- + self.fail_test("Unexpected resource name %s" % name)
- +
- + instance = rlmi_resource.instance[0]
- + if not instance.state:
- + self.fail_test("Resource instance has no state")
- + if not instance.id:
- + self.fail_test("Resource instance has no id")
- + if not instance.cid:
- + self.fail_test("Resource instance has no cid")
- +
- + if instance.state != resources[name]['state']:
- + self.fail_test("Unexpected instance state %s" % instance.state)
- +
- + self.rlmi_cids[rlmi_resource.uri] = rlmi_resource.instance[0].cid
- +
- + def validate_pidf(self, pidf_part, resources):
- + """Validates the integrity of a PIDF body
- +
- + This uses XML ElementTree to parse the PIDF body and ensures basic
- + structural elements (as they relate to RLS) are present.
- +
- + Keyword Arguments:
- + pidf_part The PIDF part from a multipart body.
- + resources The expected resources dictionary relevant to this PIDF body
- + """
- +
- + if not pidf_part.content_id:
- + self.fail_test("PIDF part does not have a Content-ID")
- +
- + try:
- + root = ET.fromstring(pidf_part.xml)
- + except Exception as ex:
- + self.fail_test("Exception when parsing PIDF XML: %s" % ex)
- +
- + entity = root.get('entity')
- + if not entity:
- + self.fail_test("PIDF document root has no entity")
- +
- + stripped_entity = entity.strip('<>')
- + self.resource_cids[stripped_entity] = pidf_part.content_id
- +
- + def validate_multipart(self, multi_part, resources):
- + """Validates the integrity of a Multipart body
- +
- + This filters down through parts within the multipart body
- + in order to recursively evaluate each element contained
- + within.
- +
- + Keyword Arguments:
- + multi_part The Multipart part from a multipart body.
- + resources The expected resources dictionary relevant for this
- + multipart body. May be the full list specified by the test
- + or a deeper node.
- + """
- + if not multi_part.content_id:
- + self.fail_test("Multipart does not have a Content-ID")
- +
- + for part in multi_part.body.parts:
- + if part.body.packet_type == 'RLMI':
- + name = part.body.list_elem.name[0].value()
- + uri = part.body.list_elem.uri
- +
- + self.resource_cids[uri] = multi_part.content_id
- +
- + next_resources = resources.get(name)
- + if not next_resources:
- + self.fail_test("Missing '%s'" % name)
- + return
- +
- + if next_resources['type'] != 'Multipart':
- + self.fail_test("Packet Type is wrong -- processing multipart, "
- + "but expected type is %s" % next_resources['type'])
- + return
- +
- + next_resources = next_resources['sublist']
- +
- + for part in multi_part.body.parts:
- + if part.body.packet_type == 'RLMI':
- + self.validate_rlmi(part.body.list_elem, next_resources, name)
- + elif part.body.packet_type == 'PIDF':
- + self.validate_pidf(part.body, next_resources)
- + elif part.body.packet_type == 'Multipart':
- + self.validate_multipart(part.body, next_resources)
- +
- + def fail_test(self, message):
- + """Fail the test and stop the reactor"""
- + LOGGER.error(message)
- + self.test_object.set_passed(False)
- + self.test_object.stop_reactor()
- Property changes on: tests/channels/pjsip/subscriptions/rls/rls_integrity.py
- ___________________________________________________________________
- Added: svn:executable
- + *
- Added: svn:mime-type
- + text/plain
- Added: svn:keywords
- + Author Date Id Revision
- Added: svn:eol-style
- + native
- Index: tests/channels/pjsip/subscriptions/tests.yaml
- ===================================================================
- --- tests/channels/pjsip/subscriptions/tests.yaml (revision 5316)
- +++ tests/channels/pjsip/subscriptions/tests.yaml (working copy)
- @@ -6,3 +6,4 @@
- - test: 'unknown_event_package'
- - test: 'unallowed'
- - test: 'below_min_expiry'
- + - dir: 'rls'
- Index: lib/python/asterisk/pcap.py
- ===================================================================
- --- lib/python/asterisk/pcap.py (revision 5316)
- +++ lib/python/asterisk/pcap.py (working copy)
- @@ -25,6 +25,8 @@
- except:
- PCAP_AVAILABLE = False
- +import rlmi
- +
- LOGGER = logging.getLogger(__name__)
- class PcapListener(object):
- @@ -57,7 +59,7 @@
- # Let exceptions propagate - if we can't create the pcap, this should
- # throw the exception to the pluggable module creation routines
- test_object.create_pcap_listener(
- - device=None,
- + device=device,
- bpf_filter=bpf_filter,
- dumpfile=filename)
- @@ -201,6 +203,87 @@
- self.rtcp_port = self.rtp_port + 1
- +class PIDFPacket(Packet):
- + '''A PIDF presence body. Owned by SIPPacket or a MultipartPacket.'''
- +
- + def __init__(self, ascii_packet, raw_packet, content_id):
- + Packet.__init__(self, packet_type="PIDF", raw_packet=raw_packet)
- + self.xml = ascii_packet.strip()
- + self.content_id = content_id
- +
- +
- +class RLMIPacket(Packet):
- + '''An RLMI body. Owned either by a SIPPacket or a MultipartPacket.'''
- +
- + def __init__(self, ascii_packet, raw_packet):
- + Packet.__init__(self, packet_type="RLMI", raw_packet=raw_packet)
- + self.list_elem = rlmi.CreateFromDocument(ascii_packet.strip())
- +
- +
- +class MultipartPart:
- + def __init__(self, part, raw_packet):
- + self.headers = {}
- +
- + last_pos = part.find('\r\n\r\n')
- + headers = part[:last_pos].split('\r\n')
- + body = part[last_pos:]
- +
- + for header in headers:
- + colon_pos = header.find(':')
- + self.headers[header[:colon_pos]] = header[colon_pos + 1:].strip()
- +
- + content_type = self.headers.get('Content-Type')
- + self.content_id = self.headers.get('Content-ID').strip('<>')
- +
- + self.body = BodyFactory.create_body(content_type, body.strip(),
- + raw_packet, self.content_id)
- +
- +
- +class MultipartPacket(Packet):
- + '''A multipart body. Owned either by a SIPPacket or a Multipartpacket.'''
- +
- + def __init__(self, content_type, ascii_packet, raw_packet):
- + Packet.__init__(self, packet_type="Multipart", raw_packet=raw_packet)
- + self.boundary = None
- + self.parts = []
- +
- + for part in content_type.split(';'):
- + param, equal, value = part.partition('=')
- + if param == 'boundary':
- + self.boundary = '--%s' % value.strip('"')
- +
- + if not self.boundary:
- + raise Exception
- +
- + parts = ascii_packet.split(self.boundary)
- +
- + # Start with the second part since the initial boundary has no content
- + # before it.
- + for part in parts[1:]:
- + stripped = part.strip('\r\n ')
- + # The final boundary in a multipart body is --boundary--
- + if stripped == '--':
- + break
- + self.parts.append(MultipartPart(stripped, raw_packet))
- +
- +
- +class BodyFactory(object):
- + @staticmethod
- + def create_body(content_type, ascii_packet, raw_packet, content_id=None):
- + body_type, _, _ = content_type.partition(';')
- + if (body_type == 'application/sdp'):
- + return SDPPacket(ascii_packet, raw_packet)
- + elif (body_type == 'multipart/related'):
- + return MultipartPacket(content_type, ascii_packet, raw_packet)
- + elif (body_type == 'application/rlmi+xml'):
- + return RLMIPacket(ascii_packet, raw_packet)
- + elif (body_type == 'application/pidf+xml'):
- + return PIDFPacket(ascii_packet, raw_packet, content_id)
- + else:
- + return Packet(body_type, raw_packet)
- + pass
- +
- +
- class SIPPacket(Packet):
- ''' A SIP packet '''
- @@ -213,7 +296,7 @@
- '''
- Packet.__init__(self, packet_type='SIP', raw_packet=raw_packet)
- - self.sdp_packet = None
- + self.body = None
- self.headers = {}
- self.request_line = ''
- self.ascii_packet = ascii_packet
- @@ -232,8 +315,11 @@
- colon_pos = header.find(':')
- self.headers[header[:colon_pos]] = header[colon_pos + 1:].strip()
- if int(self.headers.get('Content-Length')) > 0:
- - self.sdp_packet = SDPPacket(ascii_packet=remainder_packet,
- - raw_packet=raw_packet)
- + content_type = self.headers.get('Content-Type',
- + 'application/sdp').strip()
- + self.body = BodyFactory.create_body(content_type,
- + ascii_packet=remainder_packet,
- + raw_packet=raw_packet)
- class SIPPacketFactory():
- @@ -270,9 +356,10 @@
- # RTP port and RTCP port; then set that information for this particular
- # stream in the factory manager so that the factories for RTP can
- # interpret packets correctly
- - if ret_packet != None and ret_packet.sdp_packet != None and \
- - ret_packet.sdp_packet.rtp_port != 0 and \
- - ret_packet.sdp_packet.rtcp_port != 0:
- + if ret_packet and ret_packet.body and \
- + ret_packet.body.packet_type == 'SDP' and \
- + ret_packet.sdp_packet.rtp_port != 0 and \
- + ret_packet.sdp_packet.rtcp_port != 0:
- self._factory_manager.add_global_data(ret_packet.ip_layer.header.source,
- {'rtp': ret_packet.sdp_packet.rtp_port,
- 'rtcp': ret_packet.sdp_packet.rtcp_port})
- @@ -451,3 +538,6 @@
- if packet_type not in self._callbacks:
- self._callbacks[packet_type] = []
- self._callbacks[packet_type].append(callback)
- +
- + def remove_callbacks(self, packet_type):
- + del self._callbacks[packet_type]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement