PageRenderTime 41ms CodeModel.GetById 14ms RepoModel.GetById 0ms app.codeStats 0ms

/openbsd/sys/netinet/ip_carp.h

https://github.com/kame/kame
C Header | 130 lines | 78 code | 14 blank | 38 comment | 2 complexity | 90acc3b3d13cc90c9ecfdd1f3e67d221 MD5 | raw file
Possible License(s): BSD-3-Clause, GPL-2.0
  1. /* $OpenBSD: ip_carp.h,v 1.4 2003/11/16 20:30:07 avsm Exp $ */
  2. /*
  3. * Copyright (c) 2002 Michael Shalayeff. All rights reserved.
  4. * Copyright (c) 2003 Ryan McBride. All rights reserved.
  5. *
  6. * Redistribution and use in source and binary forms, with or without
  7. * modification, are permitted provided that the following conditions
  8. * are met:
  9. * 1. Redistributions of source code must retain the above copyright
  10. * notice, this list of conditions and the following disclaimer.
  11. * 2. Redistributions in binary form must reproduce the above copyright
  12. * notice, this list of conditions and the following disclaimer in the
  13. * documentation and/or other materials provided with the distribution.
  14. *
  15. * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
  16. * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  17. * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  18. * IN NO EVENT SHALL THE AUTHOR OR HIS RELATIVES BE LIABLE FOR ANY DIRECT,
  19. * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  20. * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
  21. * SERVICES; LOSS OF MIND, USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  22. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
  23. * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
  24. * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
  25. * THE POSSIBILITY OF SUCH DAMAGE.
  26. */
  27. struct carp_header {
  28. #if BYTE_ORDER == LITTLE_ENDIAN
  29. u_int8_t carp_type:4,
  30. carp_version:4;
  31. #endif
  32. #if BYTE_ORDER == BIG_ENDIAN
  33. u_int8_t carp_version:4,
  34. carp_type:4;
  35. #endif
  36. u_int8_t carp_vhid; /* virtual host id */
  37. u_int8_t carp_advskew; /* advertisement skew */
  38. u_int8_t carp_authlen; /* size of counter+md, 32bit chunks */
  39. u_int8_t carp_pad1; /* reserved */
  40. u_int8_t carp_advbase; /* advertisement interval */
  41. u_int16_t carp_cksum;
  42. u_int32_t carp_counter[2];
  43. unsigned char carp_md[20]; /* sha1 message digest */
  44. } __packed;
  45. #define CARP_DFLTTL 255
  46. /* carp_version */
  47. #define CARP_VERSION 2
  48. /* carp_type */
  49. #define CARP_ADVERTISEMENT 0x01
  50. #define CARP_LEAVE_GROUP 0x02
  51. #define CARP_KEY_LEN 20 /* a sha1 hash of a passphrase */
  52. /* carp_advbase */
  53. #define CARP_DFLTINTV 1
  54. /*
  55. * Statistics.
  56. */
  57. struct carpstats {
  58. u_long carps_ipackets; /* total input packets, IPv4 */
  59. u_long carps_ipackets6; /* total input packets, IPv6 */
  60. u_long carps_badif; /* wrong interface */
  61. u_long carps_badttl; /* TTL is not CARP_DFLTTL */
  62. u_long carps_hdrops; /* packets shorter than header */
  63. u_long carps_badsum; /* bad checksum */
  64. u_long carps_badver; /* bad (incl unsupp) version */
  65. u_long carps_badlen; /* data length does not match */
  66. u_long carps_badauth; /* bad authentication */
  67. u_long carps_badvhid; /* bad VHID */
  68. u_long carps_badaddrs; /* bad address list */
  69. u_long carps_opackets; /* total output packets, IPv4 */
  70. u_long carps_opackets6; /* total output packets, IPv6 */
  71. u_long carps_onomem; /* no memory for an mbuf for a send */
  72. u_long carps_ostates; /* total state updates sent */
  73. u_long carps_preempt; /* if enabled, high-pri preemptions */
  74. };
  75. /*
  76. * Configuration structure for SIOCSVH SIOCGVH
  77. */
  78. struct carpreq {
  79. int carpr_state;
  80. #define CARP_STATES "INIT", "BACKUP", "MASTER"
  81. #define CARP_MAXSTATE 2
  82. int carpr_vhid;
  83. int carpr_advskew;
  84. int carpr_advbase;
  85. unsigned char carpr_key[CARP_KEY_LEN];
  86. };
  87. #define SIOCSVH _IOWR('i', 245, struct ifreq)
  88. #define SIOCGVH _IOWR('i', 246, struct ifreq)
  89. /*
  90. * Names for CARP sysctl objects
  91. */
  92. #define CARPCTL_ALLOW 1 /* accept incoming CARP packets */
  93. #define CARPCTL_PREEMPT 2 /* high-pri backup preemption mode */
  94. #define CARPCTL_LOG 3 /* log bad packets */
  95. #define CARPCTL_ARPBALANCE 4 /* balance arp responses */
  96. #define CARPCTL_MAXID 5
  97. #define CARPCTL_NAMES { \
  98. { 0, 0 }, \
  99. { "allow", CTLTYPE_INT }, \
  100. { "preempt", CTLTYPE_INT }, \
  101. { "log", CTLTYPE_INT }, \
  102. { "arpbalance", CTLTYPE_INT }, \
  103. }
  104. #ifdef _KERNEL
  105. void carp_ifdetach (struct ifnet *);
  106. void carp_input (struct mbuf *, ...);
  107. int carp6_input (struct mbuf **, int *, int);
  108. int carp_output (struct ifnet *, struct mbuf *, struct sockaddr *,
  109. struct rtentry *);
  110. int carp_iamatch (void *, struct in_ifaddr *, struct in_addr *,
  111. u_int8_t **);
  112. struct ifaddr *carp_iamatch6(void *, struct in6_addr *);
  113. void *carp_macmatch6(void *, struct mbuf *, struct in6_addr *);
  114. struct ifnet *carp_forus (void *, void *);
  115. int carp_sysctl (int *, u_int, void *, size_t *, void *, size_t);
  116. #endif