Hi, I've used a BNF_to_RegExp converter to get all the RFC 3261 BNF code as 
Ruby RegExp. This could seem nice, but now I'm not sure if I should use these 
RegExp or not since they are very very long...

For example:

SIP-URI as RegExp is:
---------------------------------------------------------------------------------------------------------------
/[Ss][Ii][Pp]:(?:(?:[!'-\x2a\x2d\x2e0-9A-Z_a-z~]|%[0-9A-Fa-f][0-9A-Fa-f]|
[\x24&\x2b,\/;=\x3f])+(?::(?:[!'-\x2a\x2d\x2e0-9A-Z_a-z~]|%[0-9A-Fa-f]
[0-9A-Fa-f]|[\x24&\x2b,=])*)?@)?(?:(?:(?:[0-9A-Za-z]|[0-9A-Za-z]
[\x2d0-9A-Za-z]*[0-9A-Za-z])\x2e)*(?:[A-Za-z]|[A-Za-z]
[\x2d0-9A-Za-z]*[0-9A-Za-z])\x2e?|\d{1,3}\x2e\d{1,3}\x2e\d{1,3}\x2e\d{1,3}|
\x5b(?:[0-9A-Fa-f]{1,4}(?::[0-9A-Fa-f]{1,4})*|[0-9A-Fa-f]{1,4}(?::[0-9A-Fa-f]
{1,4})*::(?:[0-9A-Fa-f]{1,4}(?::[0-9A-Fa-f]{1,4})*)?|::(?:[0-9A-Fa-f]{1,4}
(?::[0-9A-Fa-f]{1,4})*)?)(?::\d{1,3}\x2e\d{1,3}\x2e\d{1,3}\x2e\d{1,3})?\x5d)
(?::\d+)?(?:;(?:[Tt][Rr][Aa][Nn][Ss][Pp][Oo][Rr][Tt]=(?:[Uu][Dd][Pp]|[Tt][Cc]
[Pp]|[Ss][Cc][Tt][Pp]|[Tt][Ll][Ss]|[!%'\x2a\x2b\x2d\x2e0-9A-Z_-z~]+)|[Uu][Ss]
[Ee][Rr]=(?:[Pp][Hh][Oo][Nn][Ee]|[Ii][Pp]|[!%'\x2a\x2b\x2d\x2e0-9A-Z_-z~]+)|
[Mm][Ee][Tt][Hh][Oo][Dd]=(?:INVITE|ACK|OPTIONS|BYE|CANCEL|REGISTER|
[!%'\x2a\x2b\x2d\x2e0-9A-Z_-z~]+)|[Tt][Tt][Ll]=\d{1,3}|[Mm][Aa][Dd][Dd]
[Rr]=(?:(?:(?:[0-9A-Za-z]|[0-9A-Za-z][\x2d0-9A-Za-z]*[0-9A-Za-z])\x2e)*(?:
[A-Za-z]|[A-Za-z][\x2d0-9A-Za-z]*[0-9A-Za-z])\x2e?|
\d{1,3}\x2e\d{1,3}\x2e\d{1,3}\x2e\d{1,3}|\x5b(?:[0-9A-Fa-f]{1,4}(?::
[0-9A-Fa-f]{1,4})*|[0-9A-Fa-f]{1,4}(?::[0-9A-Fa-f]{1,4})*::(?:[0-9A-Fa-f]
{1,4}(?::[0-9A-Fa-f]{1,4})*)?|::(?:[0-9A-Fa-f]{1,4}(?::[0-9A-Fa-f]{1,4})*)?)
(?::\d{1,3}\x2e\d{1,3}\x2e\d{1,3}\x2e\d{1,3})?\x5d)|[Ll][Rr]|(?:[!
\x24&-\x2b\x2d-:A-\x5b\x5d_a-z~]|%[0-9A-Fa-f][0-9A-Fa-f])+(?:=(?:[!
\x24&-\x2b\x2d-:A-\x5b\x5d_a-z~]|%[0-9A-Fa-f][0-9A-Fa-f])+)?))*(?:\x3f(?:[!
\x24'-\x2b\x2d-:\x3fA-\x5b\x5d_a-z~]|%[0-9A-Fa-f][0-9A-Fa-f])+=(?:[!
\x24'-\x2b\x2d-:\x3fA-\x5b\x5d_a-z~]|%[0-9A-Fa-f][0-9A-Fa-f])*(?:&(?:[!
\x24'-\x2b\x2d-:\x3fA-\x5b\x5d_a-z~]|%[0-9A-Fa-f][0-9A-Fa-f])+=(?:[!
\x24'-\x2b\x2d-:\x3fA-\x5b\x5d_a-z~]|%[0-9A-Fa-f][0-9A-Fa-f])*)*)?/
---------------------------------------------------------------------------------------------------------------

and Request-Line is 3 times longer that the above RegExp !!!


So if my SIP stack runs as UAS, should I really match the incoming request 
line/SIP-URI against those long RegExp? I think it would eat lots of CPU 
resources.

Do other SIP stacks use those RegExp?

In fact, even if I use those RegExp they are just valid to match but not to 
extract the parts (user, host, port...) since I can't know how many ( ) are 
inside the the regular expression (to get the fragment matches with $1, $2, 
$3...) so really I'm not sure if those RegExp are useful or not in my case.

Thanks a lot for any orientation and best regards.



-- 
Iñaki Baz Castillo

_______________________________________________
Sip-implementors mailing list
[email protected]
https://lists.cs.columbia.edu/cucslists/listinfo/sip-implementors

Reply via email to