mgcp: Be able to parse a Osmocom transaction ID
the namespace nat-NUMBER is not valid according to the grammar. Add an optional extension for it and add a testcase. In case we get too many extensions we might introduce a MGCPGrammar subclass for osmocom.
This commit is contained in:
parent
da6b556696
commit
2b5089d84d
|
@ -361,6 +361,13 @@ PP.PPCompositeParserTest subclass: MGCPParserTest [
|
|||
nextPutAll: 'M: recvonly'; cr; nl]
|
||||
]
|
||||
|
||||
MGCPParserTest class >> natDLCXMessage [
|
||||
^String streamContents: [:stream |
|
||||
stream
|
||||
nextPutAll: 'DLCX nat-0 1@mgw MGCP 1.0'; cr; nl]
|
||||
|
||||
]
|
||||
|
||||
parserClass [
|
||||
^MGCPParser
|
||||
]
|
||||
|
@ -374,6 +381,14 @@ PP.PPCompositeParserTest subclass: MGCPParserTest [
|
|||
self assert: crcx asDatagram equals: self class crcxMessage.
|
||||
]
|
||||
|
||||
testParseDLCX [
|
||||
| dlcx |
|
||||
dlcx := self parse: self class natDLCXMessage.
|
||||
|
||||
self assert: dlcx class verb equals: 'DLCX'.
|
||||
self assert: dlcx asDatagram equals: self class natDLCXMessage.
|
||||
]
|
||||
|
||||
testRespParse [
|
||||
| nl res sdp |
|
||||
nl := Character cr asString, Character nl asString.
|
||||
|
|
|
@ -71,7 +71,9 @@ PP.PPCompositeParser subclass: MGCPGrammar [
|
|||
|
||||
transaction_id [
|
||||
<category: 'grammar-cmd'>
|
||||
^ ((#digit asParser) min: 1 max: 9) flatten
|
||||
"Add Osmocom extension that starts with 'nat-'"
|
||||
^ ((#digit asParser) min: 1 max: 9) flatten /
|
||||
('nat-' asParser, (#digit asParser) min: 1 max: 9) flatten
|
||||
]
|
||||
|
||||
endpointName [
|
||||
|
|
Reference in New Issue