iax2-parser.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. /*
  2. * Asterisk -- A telephony toolkit for Linux.
  3. *
  4. * Implementation of Inter-Asterisk eXchange
  5. *
  6. * Copyright (C) 2003, Digium
  7. *
  8. * Mark Spencer <markster@linux-support.net>
  9. *
  10. * This program is free software, distributed under the terms of
  11. * the GNU General Public License
  12. */
  13. #ifndef _IAX2_PARSER_H
  14. #define _IAX2_PARSER_H
  15. struct iax_ies {
  16. char *called_number;
  17. char *calling_number;
  18. char *calling_ani;
  19. char *calling_name;
  20. char *called_context;
  21. char *username;
  22. char *password;
  23. unsigned int capability;
  24. unsigned int format;
  25. char *language;
  26. int version;
  27. unsigned short adsicpe;
  28. char *dnid;
  29. char *rdnis;
  30. unsigned int authmethods;
  31. char *challenge;
  32. char *md5_result;
  33. char *rsa_result;
  34. struct sockaddr_in *apparent_addr;
  35. unsigned short refresh;
  36. unsigned short dpstatus;
  37. unsigned short callno;
  38. char *cause;
  39. unsigned char iax_unknown;
  40. int msgcount;
  41. int autoanswer;
  42. int musiconhold;
  43. unsigned int transferid;
  44. unsigned int datetime;
  45. char *devicetype;
  46. char *serviceident;
  47. int firmwarever;
  48. unsigned int fwdesc;
  49. unsigned char *fwdata;
  50. unsigned char fwdatalen;
  51. unsigned int provver;
  52. int provverpres;
  53. };
  54. #define DIRECTION_INGRESS 1
  55. #define DIRECTION_OUTGRESS 2
  56. struct iax_frame {
  57. #ifdef LIBIAX
  58. struct iax_session *session;
  59. struct iax_event *event;
  60. #endif
  61. /* /Our/ call number */
  62. unsigned short callno;
  63. /* /Their/ call number */
  64. unsigned short dcallno;
  65. /* Start of raw frame (outgoing only) */
  66. void *data;
  67. /* Length of frame (outgoing only) */
  68. int datalen;
  69. /* How many retries so far? */
  70. int retries;
  71. /* Outgoing relative timestamp (ms) */
  72. unsigned int ts;
  73. /* How long to wait before retrying */
  74. int retrytime;
  75. /* Are we received out of order? */
  76. int outoforder;
  77. /* Have we been sent at all yet? */
  78. int sentyet;
  79. /* Outgoing Packet sequence number */
  80. int oseqno;
  81. /* Next expected incoming packet sequence number */
  82. int iseqno;
  83. /* Non-zero if should be sent to transfer peer */
  84. int transfer;
  85. /* Non-zero if this is the final message */
  86. int final;
  87. /* Ingress or outgres */
  88. int direction;
  89. /* Retransmission ID */
  90. int retrans;
  91. /* Easy linking */
  92. struct iax_frame *next;
  93. struct iax_frame *prev;
  94. /* Actual, isolated frame header */
  95. struct ast_frame af;
  96. unsigned char unused[AST_FRIENDLY_OFFSET];
  97. unsigned char afdata[0]; /* Data for frame */
  98. };
  99. struct iax_ie_data {
  100. unsigned char buf[1024];
  101. int pos;
  102. };
  103. /* Choose a different function for output */
  104. extern void iax_set_output(void (*output)(const char *data));
  105. /* Choose a different function for errors */
  106. extern void iax_set_error(void (*output)(const char *data));
  107. extern void iax_showframe(struct iax_frame *f, struct ast_iax2_full_hdr *fhi, int rx, struct sockaddr_in *sin, int datalen);
  108. extern const char *iax_ie2str(int ie);
  109. extern int iax_ie_append_raw(struct iax_ie_data *ied, unsigned char ie, void *data, int datalen);
  110. extern int iax_ie_append_addr(struct iax_ie_data *ied, unsigned char ie, struct sockaddr_in *sin);
  111. extern int iax_ie_append_int(struct iax_ie_data *ied, unsigned char ie, unsigned int value);
  112. extern int iax_ie_append_short(struct iax_ie_data *ied, unsigned char ie, unsigned short value);
  113. extern int iax_ie_append_str(struct iax_ie_data *ied, unsigned char ie, unsigned char *str);
  114. extern int iax_ie_append_byte(struct iax_ie_data *ied, unsigned char ie, unsigned char dat);
  115. extern int iax_ie_append(struct iax_ie_data *ied, unsigned char ie);
  116. extern int iax_parse_ies(struct iax_ies *ies, unsigned char *data, int datalen);
  117. extern int iax_get_frames(void);
  118. extern int iax_get_iframes(void);
  119. extern int iax_get_oframes(void);
  120. extern void iax_frame_wrap(struct iax_frame *fr, struct ast_frame *f);
  121. extern struct iax_frame *iax_frame_new(int direction, int datalen);
  122. extern void iax_frame_free(struct iax_frame *fr);
  123. #endif