tsip_machine_message.rl 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. /*
  2. * Copyright (C) 2010-2011 Mamadou Diop.
  3. *
  4. * Contact: Mamadou Diop <diopmamadou(at)doubango[dot]org>
  5. *
  6. * This file is part of Open Source Doubango Framework.
  7. *
  8. * DOUBANGO is free software: you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation, either version 3 of the License, or
  11. * (at your option) any later version.
  12. *
  13. * DOUBANGO is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with DOUBANGO.
  20. *
  21. */
  22. /**@file tsip_machine_message.rl
  23. * @brief Ragel file.
  24. *
  25. * @author Mamadou Diop <diopmamadou(at)doubango[dot]org>
  26. *
  27. */
  28. %%{
  29. machine tsip_machine_message;
  30. #message_body = OCTET*;
  31. message_body = any*;
  32. SIP_Version = ("SIP"i "/" DIGIT+ "." DIGIT+) >tag %parse_sipversion;
  33. action prev_not_comma{
  34. prev_not_comma(p)
  35. }
  36. message_header = any+>tag :>(CRLF when prev_not_comma) %parse_header;
  37. # SIP RESPONSE
  38. Reason_Phrase = (( reserved | unreserved | escaped | UTF8_NONASCII | UTF8_CONT | SP | HTAB )*)>tag %parse_reason_phrase;
  39. Status_Line = SIP_Version :>SP Status_Code>tag %parse_status_code :>SP Reason_Phrase :>CRLF;
  40. Response = Status_Line (message_header* :>CRLF);
  41. # SIP REQUEST
  42. URI = (scheme HCOLON any+)>tag %parse_requesturi;
  43. Request_URI = URI;
  44. Request_Line = Method>tag %parse_method :>SP Request_URI :>SP SIP_Version :>CRLF;
  45. Request = Request_Line (message_header* :>CRLF);
  46. # SIP MESSAGE
  47. SIP_message = (Response | Request)>1 @eoh message_body?>0;
  48. }%%