3
0

d6_common.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. /* vi: set sw=4 ts=4: */
  2. /*
  3. * Copyright (C) 2011 Denys Vlasenko.
  4. *
  5. * Licensed under GPLv2, see file LICENSE in this source tree.
  6. */
  7. #ifndef UDHCP_D6_COMMON_H
  8. #define UDHCP_D6_COMMON_H 1
  9. #include <netinet/ip6.h>
  10. PUSH_AND_SET_FUNCTION_VISIBILITY_TO_HIDDEN
  11. /*** DHCPv6 packet ***/
  12. /* DHCPv6 protocol. See RFC 3315 */
  13. #define D6_MSG_SOLICIT 1
  14. #define D6_MSG_ADVERTISE 2
  15. #define D6_MSG_REQUEST 3
  16. #define D6_MSG_CONFIRM 4
  17. #define D6_MSG_RENEW 5
  18. #define D6_MSG_REBIND 6
  19. #define D6_MSG_REPLY 7
  20. #define D6_MSG_RELEASE 8
  21. #define D6_MSG_DECLINE 9
  22. #define D6_MSG_RECONFIGURE 10
  23. #define D6_MSG_INFORMATION_REQUEST 11
  24. #define D6_MSG_RELAY_FORW 12
  25. #define D6_MSG_RELAY_REPL 13
  26. struct d6_packet {
  27. union {
  28. uint8_t d6_msg_type;
  29. uint32_t d6_xid32;
  30. } d6_u;
  31. uint8_t d6_options[576 - sizeof(struct iphdr) - sizeof(struct udphdr) - 4
  32. + CONFIG_UDHCPC_SLACK_FOR_BUGGY_SERVERS];
  33. } PACKED;
  34. #define d6_msg_type d6_u.d6_msg_type
  35. #define d6_xid32 d6_u.d6_xid32
  36. struct ip6_udp_d6_packet {
  37. struct ip6_hdr ip6;
  38. struct udphdr udp;
  39. struct d6_packet data;
  40. } PACKED;
  41. struct udp_d6_packet {
  42. struct udphdr udp;
  43. struct d6_packet data;
  44. } PACKED;
  45. /*** Options ***/
  46. struct d6_option {
  47. uint8_t code_hi;
  48. uint8_t code;
  49. uint8_t len_hi;
  50. uint8_t len;
  51. uint8_t data[1];
  52. } PACKED;
  53. #define D6_OPT_CLIENTID 1
  54. #define D6_OPT_SERVERID 2
  55. #define D6_OPT_IA_NA 3
  56. #define D6_OPT_IA_TA 4
  57. #define D6_OPT_IAADDR 5
  58. #define D6_OPT_ORO 6
  59. #define D6_OPT_PREFERENCE 7
  60. #define D6_OPT_ELAPSED_TIME 8
  61. #define D6_OPT_RELAY_MSG 9
  62. #define D6_OPT_AUTH 11
  63. #define D6_OPT_UNICAST 12
  64. #define D6_OPT_STATUS_CODE 13
  65. #define D6_OPT_RAPID_COMMIT 14
  66. #define D6_OPT_USER_CLASS 15
  67. #define D6_OPT_VENDOR_CLASS 16
  68. #define D6_OPT_VENDOR_OPTS 17
  69. #define D6_OPT_INTERFACE_ID 18
  70. #define D6_OPT_RECONF_MSG 19
  71. #define D6_OPT_RECONF_ACCEPT 20
  72. #define D6_OPT_IA_PD 25
  73. #define D6_OPT_IAPREFIX 26
  74. /*** Other shared functions ***/
  75. struct client6_data_t {
  76. struct d6_option *server_id;
  77. struct d6_option *ia_na;
  78. char **env_ptr;
  79. unsigned env_idx;
  80. };
  81. #define client6_data (*(struct client6_data_t*)(&bb_common_bufsiz1[COMMON_BUFSIZE - sizeof(struct client6_data_t)]))
  82. int FAST_FUNC d6_listen_socket(int port, const char *inf);
  83. int FAST_FUNC d6_recv_kernel_packet(
  84. struct in6_addr *peer_ipv6,
  85. struct d6_packet *packet, int fd
  86. );
  87. int FAST_FUNC d6_send_raw_packet(
  88. struct d6_packet *d6_pkt, unsigned d6_pkt_size,
  89. struct in6_addr *src_ipv6, int source_port,
  90. struct in6_addr *dst_ipv6, int dest_port, const uint8_t *dest_arp,
  91. int ifindex
  92. );
  93. int FAST_FUNC d6_send_kernel_packet(
  94. struct d6_packet *d6_pkt, unsigned d6_pkt_size,
  95. struct in6_addr *src_ipv6, int source_port,
  96. struct in6_addr *dst_ipv6, int dest_port
  97. );
  98. #if defined CONFIG_UDHCP_DEBUG && CONFIG_UDHCP_DEBUG >= 2
  99. void FAST_FUNC d6_dump_packet(struct d6_packet *packet);
  100. #else
  101. # define d6_dump_packet(packet) ((void)0)
  102. #endif
  103. POP_SAVED_FUNCTION_VISIBILITY
  104. #endif