diff --git a/callagent/parser/SIPParser.st b/callagent/parser/SIPParser.st index 3471412..fb9c71c 100644 --- a/callagent/parser/SIPParser.st +++ b/callagent/parser/SIPParser.st @@ -57,6 +57,10 @@ SIPGrammar subclass: SIPParser [ ^ super SIPSURI => [:nodes | self class combineUri: nodes] ] + URI [ + ^super URI flatten + ] + via_ttl [ ^ super via_ttl => [:nodes | SIPGenericParam fromMandatory: nodes] diff --git a/callagent/tests/SIPParserTest.st b/callagent/tests/SIPParserTest.st index 5322c88..13fcab3 100644 --- a/callagent/tests/SIPParserTest.st +++ b/callagent/tests/SIPParserTest.st @@ -20,6 +20,22 @@ PP.PPCompositeParserTest subclass: SIPParserTest [ + SIPParserTest class >> exampleYateBye [ + ^String streamContents: [:stream | + stream + nextPutAll: 'SIP/2.0 401 Unauthorized'; cr; nl; + nextPutAll: 'Via: SIP/2.0/UDP 0.0.0.0:5061;branch=z9hG4bKMzU3OTE4OTQ0Niw5NjM5Nw__;rport=5061;received=1.2.3.4'; cr; nl; + nextPutAll: 'From: ;tag=MzU3OTE5NjYzOTMyODExMDEwOTE_'; cr; nl; + nextPutAll: 'To: ;tag=1176641923'; cr; nl; + nextPutAll: 'Call-ID: NTQ5MzM3NzA4@xiaoyu'; cr; nl; + nextPutAll: 'CSeq: 2 BYE'; cr; nl; + nextPutAll: 'WWW-Authenticate: Digest realm="Yate", domain="1.2.3.4", nonce="b787f1fbc9a864af6975d9f59ac49ef1.1401736687", stale=FALSE, algorithm=MD5'; cr; nl; + nextPutAll: 'Server: YATE/4.3.0'; cr; nl; + nextPutAll: 'Allow: ACK, INVITE, BYE, CANCEL, REGISTER, REFER, OPTIONS, INFO'; cr; nl; + nextPutAll: 'Content-Length: 0'; cr; nl; + cr; nl] + ] + parserClass [ ^ SIPParser @@ -228,4 +244,11 @@ PP.PPCompositeParserTest subclass: SIPParserTest [ self assert: auth uri equals: 'sip:127.0.0.1'. self assert: auth response equals: 'bc8dfaa413e897863dbab4c622e4b9b4'. ] + + testYateBye [ + | res | + + res := self parse: self class exampleYateBye. + "Just check it can be parsed." + ] ] diff --git a/grammar/SIPGrammar.st b/grammar/SIPGrammar.st index ddde629..0226182 100644 --- a/grammar/SIPGrammar.st +++ b/grammar/SIPGrammar.st @@ -19,7 +19,7 @@ PP.PPCompositeParser subclass: SIPGrammar [ | Response StatusLine message_header CRLF SP HTAB HCOLON SWS LWS WSP COMMA SEMI SLASH COLON EQUAL - LAQUOT RAQUOT LDQUOT RDQUOT DQUOTE STAR + LAQUOT RAQUOT LDQUOT RDQUOT DQUOTE STAR URI message_body SIPVersion StatusCode ReasonPhrase extension_header header_name header_value Request RequestLine Method extension_method @@ -44,6 +44,13 @@ PP.PPCompositeParser subclass: SIPGrammar [ ^ $ asParser ] + URI [ + "TODO: URI should be parsed properly but yate seems to already + violate the RFC" + ^(#digit asParser / #word asParser) star + "^absoluteURI / abs-path" + ] + Request [ ^ RequestLine, message_header star, CRLF, message_body optional