Index: tests/channels/SIP/sip_unregister/configs/ast1/sip.conf
===================================================================
--- tests/channels/SIP/sip_unregister/configs/ast1/sip.conf	(revision 0)
+++ tests/channels/SIP/sip_unregister/configs/ast1/sip.conf	(working copy)
@@ -0,0 +1,38 @@
+[general]
+bindaddr=[::]:5060
+
+[ipv4]
+type=friend
+host=dynamic
+
+[ipv6]
+type=friend
+host=dynamic
+
+[ipv42]
+type=friend
+host=dynamic
+
+[ipv62]
+type=friend
+host=dynamic
+
+[ipv4-auth1]
+type=friend
+host=dynamic
+secret=test1234
+
+[ipv6-auth1]
+type=friend
+host=dynamic
+secret=test12345
+
+[ipv4-auth2]
+type=friend
+host=dynamic
+secret=test1234
+
+[ipv6-auth2]
+type=friend
+host=dynamic
+secret=test12345
Index: tests/channels/SIP/sip_unregister/sipp/registerv4-auth.xml
===================================================================
--- tests/channels/SIP/sip_unregister/sipp/registerv4-auth.xml	(revision 0)
+++ tests/channels/SIP/sip_unregister/sipp/registerv4-auth.xml	(working copy)
@@ -0,0 +1,101 @@
+<?xml version="1.0" encoding="ISO-8859-1" ?>
+<!DOCTYPE scenario SYSTEM "sipp.dtd">
+
+<scenario name="IPv4 register with authentication">
+    <!-- register -->
+    <send retrans="500">
+        <![CDATA[
+
+        REGISTER sip:[service]@[remote_ip]:[remote_port] SIP/2.0
+        Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]
+        From: "[service]" <sip:[service]@[local_ip]:[local_port]>;tag=[pid]SIPpTag00[call_number]
+        To: "[service]" <sip:[service]@[remote_ip]:[remote_port]>
+        Call-ID: [call_id]
+        CSeq: [cseq] REGISTER
+        Max-Forwards: 70
+        Contact: <sip:[service]@127.0.0.2:5062>;transport=[transport]
+        Subject: Performance Test
+        Expires: 3600
+        Content-Length: 0
+
+        ]]>
+    </send>
+
+    <recv response="401" auth="true"></recv>
+
+    <send retrans="500">
+        <![CDATA[
+
+        REGISTER sip:[service]@[remote_ip]:[remote_port] SIP/2.0
+        Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]
+        From: "[service]" <sip:[service]@[local_ip]:[local_port]>;tag=[pid]SIPpTag00[call_number]
+        To: "[service]" <sip:[service]@[remote_ip]:[remote_port]>
+        Call-ID: [call_id]
+        CSeq: [cseq] REGISTER
+        Max-Forwards: 70
+        Contact: <sip:[service]@127.0.0.2:5062>;transport=[transport]
+        [authentication]
+        Subject: Performance Test
+        Expires: 3600
+        Content-Length: 0
+
+        ]]>
+    </send>
+
+    <recv response="200" rtd="true">
+        <action>
+            <ereg regexp="Contact: <sip:ipv4-auth(1|2)@127.0.0.2:5062>;expires=(3600|5[5-9])" search_in="msg" check_it="true" assign_to="1" />
+        </action>
+    </recv>
+
+    <!-- unregister -->
+    <send retrans="500">
+        <![CDATA[
+
+        REGISTER sip:[service]@[remote_ip]:[remote_port] SIP/2.0
+        Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]
+        From: "[service]" <sip:[service]@[local_ip]:[local_port]>;tag=[pid]SIPpTag00[call_number]
+        To: "[service]" <sip:[service]@[remote_ip]:[remote_port]>
+        Call-ID: [call_id]
+        CSeq: [cseq] REGISTER
+        Max-Forwards: 70
+        Contact: [contact1]
+        Subject: Performance Test
+        Expires: 0
+        Content-Length: 0
+
+        ]]>
+    </send>
+
+    <recv response="401" auth="true"></recv>
+
+    <send retrans="500">
+        <![CDATA[
+
+        REGISTER sip:[service]@[remote_ip]:[remote_port] SIP/2.0
+        Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]
+        From: "[service]" <sip:[service]@[local_ip]:[local_port]>;tag=[pid]SIPpTag00[call_number]
+        To: "[service]" <sip:[service]@[remote_ip]:[remote_port]>
+        Call-ID: [call_id]
+        CSeq: [cseq] REGISTER
+        Max-Forwards: 70
+        Contact: [contact1]
+        [authentication]
+        Subject: Performance Test
+        Expires: 0
+        Content-Length: 0
+
+        ]]>
+    </send>
+
+    <recv response="200" rtd="true">
+        <action>
+            <ereg regexp="Contact" search_in="msg" check_it_inverse="true" assign_to="2" />
+            <ereg regexp="Expires: 0" search_in="msg" check_it="true" assign_to="3" />
+	</action>
+    </recv>
+
+    <Reference variables="1" />
+    <Reference variables="2" />
+    <Reference variables="3" />
+</scenario>
Index: tests/channels/SIP/sip_unregister/sipp/registerv4.xml
===================================================================
--- tests/channels/SIP/sip_unregister/sipp/registerv4.xml	(revision 0)
+++ tests/channels/SIP/sip_unregister/sipp/registerv4.xml	(working copy)
@@ -0,0 +1,60 @@
+<?xml version="1.0" encoding="ISO-8859-1" ?>
+<!DOCTYPE scenario SYSTEM "sipp.dtd">
+
+<scenario name="IPv4 register without authentication">
+    <!-- register -->
+    <send retrans="500">
+        <![CDATA[
+
+        REGISTER sip:[service]@[remote_ip]:[remote_port] SIP/2.0
+        Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]
+        From: "[service]" <sip:[service]@[local_ip]:[local_port]>;tag=[pid]SIPpTag00[call_number]
+        To: "[service]" <sip:[service]@[remote_ip]:[remote_port]>
+        Call-ID: [call_id]
+        CSeq: [cseq] REGISTER
+        Max-Forwards: 70
+        Contact: <sip:[service]@127.0.0.2:5062>;transport=[transport]
+        Subject: Performance Test
+        Expires: 3600
+        Content-Length: 0
+
+        ]]>
+    </send>
+
+    <recv response="200" rtd="true">
+        <action>
+            <ereg regexp="Contact: <sip:(ipv4|ipv42)@127.0.0.2:5062>;expires=(3600|5[5-9])" search_in="msg" check_it="true" assign_to="1" />
+        </action>
+    </recv>
+ 
+    <!-- unregister -->
+    <send retrans="500">
+        <![CDATA[
+
+        REGISTER sip:[service]@[remote_ip]:[remote_port] SIP/2.0
+        Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]
+        From: "[service]" <sip:[service]@[local_ip]:[local_port]>;tag=[pid]SIPpTag00[call_number]
+        To: "[service]" <sip:[service]@[remote_ip]:[remote_port]>
+        Call-ID: [call_id]
+        CSeq: [cseq] REGISTER
+        Max-Forwards: 70
+        Contact: [contact1]
+        Subject: Performance Test
+        Expires: 0
+        Content-Length: 0
+
+        ]]>
+    </send>
+
+    <recv response="200" rtd="true">
+        <action>
+            <ereg regexp="Contact" search_in="msg" check_it_inverse="true" assign_to="2" />
+            <ereg regexp="Expires: 0" search_in="msg" check_it="true" assign_to="3" />
+	</action>
+    </recv>
+
+    <Reference variables="1" />
+    <Reference variables="2" />
+    <Reference variables="3" />
+
+</scenario>
Index: tests/channels/SIP/sip_unregister/sipp/registerv6-auth.xml
===================================================================
--- tests/channels/SIP/sip_unregister/sipp/registerv6-auth.xml	(revision 0)
+++ tests/channels/SIP/sip_unregister/sipp/registerv6-auth.xml	(working copy)
@@ -0,0 +1,102 @@
+<?xml version="1.0" encoding="ISO-8859-1" ?>
+<!DOCTYPE scenario SYSTEM "sipp.dtd">
+
+<scenario name="IPv6 register with authentication">
+    <!-- register -->
+    <send retrans="500">
+        <![CDATA[
+
+        REGISTER sip:[service]@[remote_ip]:[remote_port] SIP/2.0
+        Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]
+        From: "[service]" <sip:[service]@[local_ip]:[local_port]>;tag=[pid]SIPpTag00[call_number]
+        To: "[service]" <sip:[service]@[remote_ip]:[remote_port]>
+        Call-ID: [call_id]
+        CSeq: [cseq] REGISTER
+        Max-Forwards: 70
+        Contact: <sip:[service]@[customip1]:5062>;transport=[transport]
+        Subject: Performance Test
+        Expires: 3600
+        Content-Length: 0
+
+        ]]>
+    </send>
+
+    <recv response="401" auth="true"></recv>
+
+    <send retrans="500">
+        <![CDATA[
+
+        REGISTER sip:[service]@[remote_ip]:[remote_port] SIP/2.0
+        Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]
+        From: "[service]" <sip:[service]@[local_ip]:[local_port]>;tag=[pid]SIPpTag00[call_number]
+        To: "[service]" <sip:[service]@[remote_ip]:[remote_port]>
+        Call-ID: [call_id]
+        CSeq: [cseq] REGISTER
+        Max-Forwards: 70
+        Contact: <sip:[service]@[customip1]:5062>;transport=[transport]
+        [authentication]
+        Subject: Performance Test
+        Expires: 3600
+        Content-Length: 0
+
+        ]]>
+    </send>
+
+    <recv response="200" rtd="true">
+        <action>
+            <ereg regexp="Contact: <sip:ipv6-auth(1|2)@\[::2\]:5062>;expires=(3600|5[5-9])" search_in="msg" check_it="true" assign_to="1" />
+        </action>
+    </recv>
+
+    <!-- unregister -->
+    <send retrans="500">
+        <![CDATA[
+
+        REGISTER sip:[service]@[remote_ip]:[remote_port] SIP/2.0
+        Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]
+        From: "[service]" <sip:[service]@[local_ip]:[local_port]>;tag=[pid]SIPpTag00[call_number]
+        To: "[service]" <sip:[service]@[remote_ip]:[remote_port]>
+        Call-ID: [call_id]
+        CSeq: [cseq] REGISTER
+        Max-Forwards: 70
+        Contact: [contact1]
+        Subject: Performance Test
+        Expires: 0
+        Content-Length: 0
+
+        ]]>
+    </send>
+
+    <recv response="401" auth="true"></recv>
+
+    <send retrans="500">
+        <![CDATA[
+
+        REGISTER sip:[service]@[remote_ip]:[remote_port] SIP/2.0
+        Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]
+        From: "[service]" <sip:[service]@[local_ip]:[local_port]>;tag=[pid]SIPpTag00[call_number]
+        To: "[service]" <sip:[service]@[remote_ip]:[remote_port]>
+        Call-ID: [call_id]
+        CSeq: [cseq] REGISTER
+        Max-Forwards: 70
+        Contact: [contact1]
+        [authentication]
+        Subject: Performance Test
+        Expires: 0
+        Content-Length: 0
+
+        ]]>
+    </send>
+
+    <recv response="200" rtd="true">
+        <action>
+            <ereg regexp="Contact" search_in="msg" check_it_inverse="true" assign_to="2" />
+            <ereg regexp="Expires: 0" search_in="msg" check_it="true" assign_to="3" />
+	</action>
+    </recv>
+
+    <Reference variables="1" />
+    <Reference variables="2" />
+    <Reference variables="3" />
+
+</scenario>
Index: tests/channels/SIP/sip_unregister/sipp/registerv6.xml
===================================================================
--- tests/channels/SIP/sip_unregister/sipp/registerv6.xml	(revision 0)
+++ tests/channels/SIP/sip_unregister/sipp/registerv6.xml	(working copy)
@@ -0,0 +1,58 @@
+<?xml version="1.0" encoding="ISO-8859-1" ?>
+<!DOCTYPE scenario SYSTEM "sipp.dtd">
+
+<scenario name="IPv6 register without authentication">
+    <!-- register -->
+    <send retrans="500">
+        <![CDATA[
+
+        REGISTER sip:[service]@[remote_ip]:[remote_port] SIP/2.0
+        Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]
+        From: "[service]" <sip:[service]@[local_ip]:[local_port]>;tag=[pid]SIPpTag00[call_number]
+        To: "[service]" <sip:[service]@[remote_ip]:[remote_port]>
+        Call-ID: [call_id]
+        CSeq: [cseq] REGISTER
+        Max-Forwards: 70
+        Contact: "[service]" <sip:[service]@[customip1]:5062>;transport=[transport]
+        Subject: Performance Test
+        Expires: 3600
+        Content-Length: 0
+
+        ]]>
+    </send>
+
+    <recv response="200" rtd="true">
+        <action>
+            <ereg regexp="Contact: <sip:(ipv6|ipv62)@.::2.:5062>;expires=(3600|5[5-9])" search_in="msg" check_it="true" assign_to="1" />
+        </action>
+    </recv>
+ 
+    <!-- unregister -->
+    <send retrans="500">
+        <![CDATA[
+
+        REGISTER sip:[service]@[remote_ip]:[remote_port] SIP/2.0
+        Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]
+        From: "[service]" <sip:[service]@[local_ip]:[local_port]>;tag=[pid]SIPpTag00[call_number]
+        To: "[service]" <sip:[service]@[remote_ip]:[remote_port]>
+        Call-ID: [call_id]
+        CSeq: [cseq] REGISTER
+        Max-Forwards: 70
+        Contact: [contact1]
+        Subject: Performance Test
+        Expires: 0
+        Content-Length: 0
+
+        ]]>
+    </send>
+
+    <recv response="200" rtd="true">
+        <action>
+            <ereg regexp="Contact" search_in="msg" check_it_inverse="true" assign_to="2" />
+	</action>
+    </recv>
+
+    <Reference variables="1" />
+    <Reference variables="2" />
+
+</scenario>
Index: tests/channels/SIP/sip_unregister/test-config.yaml
===================================================================
--- tests/channels/SIP/sip_unregister/test-config.yaml	(revision 0)
+++ tests/channels/SIP/sip_unregister/test-config.yaml	(working copy)
@@ -0,0 +1,71 @@
+testinfo:
+    summary:     'Tests the handling of a peer sending an un-REGISTER.'
+    description: |
+        'Tests having a peer register using IPv4 / IPv6 and then un-registering.  The
+         tests cover authenticated REGISTER and non-authenticated REGISTER.  They
+         also cover using Contact: * with Expires: 0 and Contact: <sip uri> and
+         Expires: 0.'
+
+test-modules:
+    test-object:
+        config-section: test-object-config
+        typename: 'sipp.SIPpTestCase'
+
+test-object-config:
+    fail-on-any: False
+    test-iterations:
+        -
+            scenarios:
+                # IPv4, Expire: 0, & Unregister Contact: *
+                - { 'key-args': {'scenario': 'registerv4.xml', '-i': '127.0.0.1',
+                                    '-p': '5061', '-s': 'ipv4'},
+                    'ordered-args': ['-key', 'contact1', '*'] }
+
+                # IPv4, Expire: 0, & Unregister Contact: <sip_uri>
+                - { 'key-args': {'scenario': 'registerv4.xml', '-i': '127.0.0.1',
+                                    '-p': '5062', '-s': 'ipv42'},
+                    'ordered-args': ['-key', 'contact1', '"ipv42" <sip:ipv42@127.0.0.2:5062>;transport=udp'] }
+
+                # IPv4 Auth, Expire: 0, Unregister Contact: *
+                - { 'key-args': {'scenario': 'registerv4-auth.xml', '-i': '127.0.0.1',
+                                    '-p': '5063', '-s': 'ipv4-auth1', '-ap': 'test1234'},
+                    'ordered-args': ['-key', 'contact1', '*'] }
+
+                # IPv4 Auth, Expire: 0, & Unregister Contact: <sip_uri>
+                - { 'key-args': {'scenario': 'registerv4-auth.xml', '-i': '127.0.0.1',
+                                    '-p': '5064', '-s': 'ipv4-auth2', '-ap': 'test1234'},
+                    'ordered-args': ['-key', 'contact1', '"ipv4-auth2" <sip:ipv4-auth2@127.0.0.2:5064>;transport=udp'] }
+
+                # IPv6, Expire: 0, & Unregister Contact: *
+                - { 'key-args': {'scenario': 'registerv6.xml', 'target': '[::1]',
+                                    '-i': '[::1]', '-p': '5061', '-s': 'ipv6'},
+                    'ordered-args': ['-key', 'customip1', '[::2]', '-key', 'contact1', '*'] }
+
+                # IPv6, Expire: 0, & Unregister Contact: <sip_uri>
+                - { 'key-args': {'scenario': 'registerv6.xml', 'target': '[::1]',
+                                    '-i': '[::1]', '-p': '5062', '-s': 'ipv62'},
+                    'ordered-args': ['-key', 'customip1', '[::2]',
+                                        '-key', 'contact1', '"ipv62" <sip:ipv62@[::2]:5062>;transport=udp'] }
+
+                # IPv6 Auth, Expire: 0, & Unregister Contact: *
+                - { 'key-args': {'scenario': 'registerv6-auth.xml', 'target': '[::1]',
+                                    '-i': '[::1]', '-p': '5063', '-s': 'ipv6-auth1', '-ap': 'test12345'},
+                    'ordered-args': ['-key', 'customip1', '[::2]', '-key', 'contact1', '*'] }
+
+                # IPv6 Auth, Expire: 0, & Unregister Contact: <sip_uri>
+                - { 'key-args': {'scenario': 'registerv6-auth.xml', 'target': '[::1]',
+                                    '-i': '[::1]', '-p': '5064', '-s': 'ipv6-auth2', '-ap': 'test12345'},
+                    'ordered-args': ['-key', 'customip1', '[::2]',
+                                        '-key', 'contact1', '"ipv6-auth2" <sip:ipv6-auth2@[::2]:5064>;transport=udp'] }
+
+properties:
+    minversion: '1.8.0.0'
+    dependencies:
+        - buildoption: 'TEST_FRAMEWORK'
+        - python : 'twisted'
+        - python : 'starpy'
+        - sipp :
+            version : 'v3.3'
+        - asterisk: 'chan_sip'
+    tags:
+        - SIP
Index: tests/channels/SIP/tests.yaml
===================================================================
--- tests/channels/SIP/tests.yaml	(revision 4200)
+++ tests/channels/SIP/tests.yaml	(working copy)
@@ -17,6 +17,7 @@
     - test: 'sip_one_legged_transfer_v6'
     - test: 'sip_register'
     - test: 'sip_register_domain_acl'
+    - test: 'sip_unregister'
     - test: 'sip_channel_params'
     - test: 'sip_tls_call'
     - test: 'sip_tls_register'
