dundi-parser.h 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. /*
  2. * Distributed Universal Number Discovery (DUNDi)
  3. *
  4. * Copyright (C) 2004 - 2005, Digium Inc.
  5. *
  6. * Written by Mark Spencer <markster@digium.com>
  7. *
  8. * This program is Free Software distributed under the terms of
  9. * of the GNU General Public License.
  10. */
  11. #ifndef _DUNDI_PARSER_H
  12. #define _DUNDI_PARSER_H
  13. #include "asterisk/dundi.h"
  14. #include "asterisk/crypto.h"
  15. #define DUNDI_MAX_STACK 512
  16. #define DUNDI_MAX_ANSWERS 100
  17. struct dundi_ies {
  18. dundi_eid *eids[DUNDI_MAX_STACK + 1];
  19. int eid_direct[DUNDI_MAX_STACK + 1];
  20. dundi_eid *reqeid;
  21. int eidcount;
  22. char *called_context;
  23. char *called_number;
  24. struct dundi_answer *answers[DUNDI_MAX_ANSWERS + 1];
  25. struct dundi_hint *hint;
  26. int anscount;
  27. int ttl;
  28. int version;
  29. int expiration;
  30. int unknowncmd;
  31. unsigned char *pubkey;
  32. int cause;
  33. char *q_dept;
  34. char *q_org;
  35. char *q_locality;
  36. char *q_stateprov;
  37. char *q_country;
  38. char *q_email;
  39. char *q_phone;
  40. char *q_ipaddr;
  41. char *causestr;
  42. unsigned char *encsharedkey;
  43. unsigned char *encsig;
  44. unsigned long keycrc32;
  45. struct dundi_encblock *encblock;
  46. int enclen;
  47. int cbypass;
  48. };
  49. struct dundi_ie_data {
  50. int pos;
  51. unsigned char buf[8192];
  52. };
  53. /* Choose a different function for output */
  54. extern void dundi_set_output(void (*output)(const char *data));
  55. /* Choose a different function for errors */
  56. extern void dundi_set_error(void (*output)(const char *data));
  57. extern void dundi_showframe(struct dundi_hdr *fhi, int rx, struct sockaddr_in *sin, int datalen);
  58. extern const char *dundi_ie2str(int ie);
  59. extern int dundi_ie_append_raw(struct dundi_ie_data *ied, unsigned char ie, void *data, int datalen);
  60. extern int dundi_ie_append_addr(struct dundi_ie_data *ied, unsigned char ie, struct sockaddr_in *sin);
  61. extern int dundi_ie_append_int(struct dundi_ie_data *ied, unsigned char ie, unsigned int value);
  62. extern int dundi_ie_append_short(struct dundi_ie_data *ied, unsigned char ie, unsigned short value);
  63. extern int dundi_ie_append_str(struct dundi_ie_data *ied, unsigned char ie, char *str);
  64. extern int dundi_ie_append_eid(struct dundi_ie_data *ied, unsigned char ie, dundi_eid *eid);
  65. extern int dundi_ie_append_cause(struct dundi_ie_data *ied, unsigned char ie, unsigned char cause, char *desc);
  66. extern int dundi_ie_append_hint(struct dundi_ie_data *ied, unsigned char ie, unsigned short flags, char *data);
  67. extern int dundi_ie_append_answer(struct dundi_ie_data *ied, unsigned char ie, dundi_eid *eid, unsigned char protocol, unsigned short flags, unsigned short weight, char *desc);
  68. extern int dundi_ie_append_encdata(struct dundi_ie_data *ied, unsigned char ie, unsigned char *iv, void *data, int datalen);
  69. extern int dundi_ie_append_byte(struct dundi_ie_data *ied, unsigned char ie, unsigned char dat);
  70. extern int dundi_ie_append(struct dundi_ie_data *ied, unsigned char ie);
  71. extern int dundi_parse_ies(struct dundi_ies *ies, unsigned char *data, int datalen);
  72. extern char *dundi_eid_to_str_short(char *s, int maxlen, dundi_eid *eid);
  73. extern int dundi_str_short_to_eid(dundi_eid *eid, const char *s);
  74. extern int dundi_eid_zero(dundi_eid *eid);
  75. extern char *dundi_flags2str(char *s, int maxlen, int flags);
  76. extern char *dundi_hint2str(char *s, int maxlen, int flags);
  77. #endif