jart / gosip

Public Switched Telecommunications Network Unleashed
Apache License 2.0
488 stars 118 forks source link

Support Wildcard Contact #12

Open autoexpect opened 4 years ago

autoexpect commented 4 years ago

The following message parsing failed: Error in SIP message at line 0 offset 0:

Thanks!

SIP Message ( does not contain [ and ] ):

[REGISTER sip:34020000002000000001@1.2.3.4:5060 SIP/2.0 Via: SIP/2.0/UDP 172.16.1.36:5060;rport;branch=z9hG4bK1585760165 From: sip:34020000001320000360@172.16.1.36:5060;tag=1882859352 To: sip:34020000001320000360@172.16.1.36:5060 Call-ID: f3g4h5366947196@172.16.1.36 CSeq: 3 REGISTER Contact: * Authorization: Digest username="34020000001320000360", realm="3402000000", nonce="MTYwMzM2NDU0MA==", uri="sip:34020000002000000001@1.2.3.4:5060", response="39c7240195630f0b26124c00db7cfa5c", algorithm=MD5, cnonce="0a4f113b", qop=auth, nc=00000002 Max-Forwards: 70 User-Agent: VCP MWARE Expires: 0 RegMode: DEVICE;Describe=IPC-S642-IR;Register;DevVer=CIPC-B2301.5.21.200528 ReplaceDescribe: IPC-S642-IR;ProductId=defaultProductId;RegionCode=NONE;Vendor=UNIVIEW;Resolve=HIC1080P;Ptzfg=1;;SnmpVer=v3;DescribeAssy=PAU-X5;ReplaceNameAssy=PAU-X5 Ability: UCSStore=0 Content-Length: 0

]

negbie commented 4 years ago

Look at your contact header.

negbie commented 4 years ago

It's not a valid URI.

Edit: It's valid

negbie commented 4 years ago

Oh just checked the abnf and seems to be valid

Contact = ( "Contact" \ "m" ) ":" ( "*" \ ( 1#( ( name-addr \  addr-spec ) *( ";" contact-params ) ) ) )
negbie commented 4 years ago

Related to this:

Registrations expire as described above or may be removed explicitly by setting the expires parameter for an existing registration to zero or including an Expires: 0 header field. Registrations are matched based on the user, host, port and maddr parameters. A client can remove all registrations by including a single Contact header field with the wildcard address "*". This usage is only allowed in REGISTER requests when a Expires header with value of zero is present.

negbie commented 4 years ago

Since Expire is 0 in your case Contact: * is correct.

jart commented 4 years ago

Indeed. Thanks for the report @umbrellary. This sounds like a simple fix. Would you like to send us a pull request adding a special case for star contact? We should be able to merge that right away. Otherwise we can fix it for you in the next round of changes.