hep.h 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. /*
  2. * $Id$
  3. *
  4. * hep related structure
  5. *
  6. * Copyright (C) 2011-14 Alexandr Dubovikov <[email protected]>
  7. *
  8. * This file is part of Kamailio, a free SIP server.
  9. *
  10. * Kamailio is free software; you can redistribute it and/or modify
  11. * it under the terms of the GNU General Public License as published by
  12. * the Free Software Foundation; either version 2 of the License, or
  13. * (at your option) any later version
  14. *
  15. * Kamailio is distributed in the hope that it will be useful,
  16. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. * GNU General Public License for more details.
  19. *
  20. * You should have received a copy of the GNU General Public License
  21. * along with this program; if not, write to the Free Software
  22. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  23. *
  24. */
  25. #ifndef _hep_h
  26. #define _hep_h
  27. #ifdef __OS_solaris
  28. typedef uint8_t u_int8_t;
  29. typedef uint16_t u_int16_t;
  30. typedef uint32_t u_int32_t;
  31. #define IPPROTO_IPIP IPPROTO_ENCAP /* Solaris IPIP protocol has name ENCAP */
  32. #endif
  33. extern int hep_capture_on;
  34. extern int hep_offset;
  35. extern char *authkey;
  36. extern char *correlation_id;
  37. /* int hep_msg_received(char * buf, unsigned int len, struct receive_info * ri);*/
  38. int hep_msg_received(void *data);
  39. struct hep_hdr{
  40. u_int8_t hp_v; /* version */
  41. u_int8_t hp_l; /* length */
  42. u_int8_t hp_f; /* family */
  43. u_int8_t hp_p; /* protocol */
  44. u_int16_t hp_sport; /* source port */
  45. u_int16_t hp_dport; /* destination port */
  46. };
  47. struct hep_iphdr{
  48. struct in_addr hp_src;
  49. struct in_addr hp_dst; /* source and dest address */
  50. };
  51. struct hep_timehdr{
  52. u_int32_t tv_sec; /* seconds */
  53. u_int32_t tv_usec; /* useconds */
  54. u_int16_t captid; /* Capture ID node */
  55. };
  56. struct hep_ip6hdr {
  57. struct in6_addr hp6_src; /* source address */
  58. struct in6_addr hp6_dst; /* destination address */
  59. };
  60. /* HEPv3 types */
  61. struct hep_chunk {
  62. u_int16_t vendor_id;
  63. u_int16_t type_id;
  64. u_int16_t length;
  65. } __attribute__((packed));
  66. typedef struct hep_chunk hep_chunk_t;
  67. struct hep_chunk_uint8 {
  68. hep_chunk_t chunk;
  69. u_int8_t data;
  70. } __attribute__((packed));
  71. typedef struct hep_chunk_uint8 hep_chunk_uint8_t;
  72. struct hep_chunk_uint16 {
  73. hep_chunk_t chunk;
  74. u_int16_t data;
  75. } __attribute__((packed));
  76. typedef struct hep_chunk_uint16 hep_chunk_uint16_t;
  77. struct hep_chunk_uint32 {
  78. hep_chunk_t chunk;
  79. u_int32_t data;
  80. } __attribute__((packed));
  81. typedef struct hep_chunk_uint32 hep_chunk_uint32_t;
  82. struct hep_chunk_str {
  83. hep_chunk_t chunk;
  84. char *data;
  85. } __attribute__((packed));
  86. typedef struct hep_chunk_str hep_chunk_str_t;
  87. struct hep_chunk_ip4 {
  88. hep_chunk_t chunk;
  89. struct in_addr data;
  90. } __attribute__((packed));
  91. typedef struct hep_chunk_ip4 hep_chunk_ip4_t;
  92. struct hep_chunk_ip6 {
  93. hep_chunk_t chunk;
  94. struct in6_addr data;
  95. } __attribute__((packed));
  96. typedef struct hep_chunk_ip6 hep_chunk_ip6_t;
  97. struct hep_chunk_payload {
  98. hep_chunk_t chunk;
  99. char *data;
  100. } __attribute__((packed));
  101. typedef struct hep_chunk_payload hep_chunk_payload_t;
  102. struct hep_ctrl {
  103. char id[4];
  104. u_int16_t length;
  105. } __attribute__((packed));
  106. typedef struct hep_ctrl hep_ctrl_t;
  107. /* Structure of HEP */
  108. struct hep_generic_recv {
  109. hep_ctrl_t *header;
  110. hep_chunk_uint8_t *ip_family;
  111. hep_chunk_uint8_t *ip_proto;
  112. hep_chunk_uint16_t *src_port;
  113. hep_chunk_uint16_t *dst_port;
  114. hep_chunk_uint32_t *time_sec;
  115. hep_chunk_uint32_t *time_usec;
  116. hep_chunk_ip4_t *hep_src_ip4;
  117. hep_chunk_ip4_t *hep_dst_ip4;
  118. hep_chunk_ip6_t *hep_src_ip6;
  119. hep_chunk_ip6_t *hep_dst_ip6;
  120. hep_chunk_uint8_t *proto_t;
  121. hep_chunk_uint32_t *capt_id;
  122. hep_chunk_uint16_t *keep_tm;
  123. hep_chunk_str_t *auth_key;
  124. hep_chunk_str_t *correlation_id;
  125. hep_chunk_t *payload_chunk;
  126. } __attribute__((packed));
  127. typedef struct hep_generic_recv hep_generic_recv_t;
  128. #endif