arp.h 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. /*
  2. * arp data access header
  3. *
  4. * $Id$
  5. */
  6. #ifndef NETSNMP_ACCESS_ARP_H
  7. #define NETSNMP_ACCESS_ARP_H
  8. #ifdef __cplusplus
  9. extern "C" {
  10. #endif
  11. /**---------------------------------------------------------------------*/
  12. #if defined( NETSNMP_ENABLE_IPV6 )
  13. # define NETSNMP_ACCESS_ARP_IPADDR_BUF_SIZE 16
  14. #else
  15. # define NETSNMP_ACCESS_ARP_IPADDR_BUF_SIZE 4
  16. #endif
  17. /** MAC address is 6, InfiniBand uses more, 32 must be enough for near future.*/
  18. #define NETSNMP_ACCESS_ARP_PHYSADDR_BUF_SIZE 32
  19. /*************************************************************
  20. * constants for enums for the MIB node
  21. * inetNetToMediaType (INTEGER / ASN_INTEGER)
  22. *
  23. * since a Textual Convention may be referenced more than once in a
  24. * MIB, protect againt redefinitions of the enum values.
  25. */
  26. #ifndef inetNetToMediaType_ENUMS
  27. #define inetNetToMediaType_ENUMS
  28. #define INETNETTOMEDIATYPE_OTHER 1
  29. #define INETNETTOMEDIATYPE_INVALID 2
  30. #define INETNETTOMEDIATYPE_DYNAMIC 3
  31. #define INETNETTOMEDIATYPE_STATIC 4
  32. #define INETNETTOMEDIATYPE_LOCAL 5
  33. #endif /* inetNetToMediaType_ENUMS */
  34. /*************************************************************
  35. * constants for enums for the MIB node
  36. * inetNetToMediaState (INTEGER / ASN_INTEGER)
  37. *
  38. * since a Textual Convention may be referenced more than once in a
  39. * MIB, protect againt redifinitions of the enum values.
  40. */
  41. #ifndef inetNetToMediaState_ENUMS
  42. #define inetNetToMediaState_ENUMS
  43. #define INETNETTOMEDIASTATE_REACHABLE 1
  44. #define INETNETTOMEDIASTATE_STALE 2
  45. #define INETNETTOMEDIASTATE_DELAY 3
  46. #define INETNETTOMEDIASTATE_PROBE 4
  47. #define INETNETTOMEDIASTATE_INVALID 5
  48. #define INETNETTOMEDIASTATE_UNKNOWN 6
  49. #define INETNETTOMEDIASTATE_INCOMPLETE 7
  50. #endif /* inetNetToMediaState_ENUMS */
  51. /**---------------------------------------------------------------------*/
  52. /*
  53. * structure definitions
  54. */
  55. /*
  56. * netsnmp_arp_entry
  57. * - primary arp structure for both ipv4 & ipv6
  58. */
  59. typedef struct netsnmp_arp_s {
  60. netsnmp_index oid_index; /* MUST BE FIRST!! for container use */
  61. oid ns_arp_index; /* arbitrary index */
  62. int flags; /* for net-snmp use */
  63. unsigned generation;
  64. oid if_index;
  65. u_char arp_physaddress[NETSNMP_ACCESS_ARP_PHYSADDR_BUF_SIZE];
  66. u_char arp_ipaddress[NETSNMP_ACCESS_ARP_IPADDR_BUF_SIZE];
  67. u_char arp_physaddress_len;/* phys address len, max 32 */
  68. u_char arp_ipaddress_len; /* ip address len, 4 | 16 */
  69. u_char arp_type; /* inetNetToMediaType 1-5 */
  70. u_char arp_state; /* inetNetToMediaState 1-7 */
  71. u_long arp_last_updated; /* timeticks of last update */
  72. } netsnmp_arp_entry;
  73. #define NETSNMP_ACCESS_ARP_ENTRY_FLAG_DELETE 0x00000001
  74. /**---------------------------------------------------------------------*/
  75. /*
  76. * ACCESS function prototypes
  77. */
  78. struct netsnmp_arp_access_s;
  79. typedef struct netsnmp_arp_access_s netsnmp_arp_access;
  80. typedef void (NetsnmpAccessArpUpdate)(netsnmp_arp_access *, netsnmp_arp_entry*);
  81. typedef void (NetsnmpAccessArpGC) (netsnmp_arp_access *);
  82. struct netsnmp_arp_access_s {
  83. void *magic;
  84. void *arch_magic;
  85. int synchronized;
  86. unsigned generation;
  87. NetsnmpAccessArpUpdate *update_hook;
  88. NetsnmpAccessArpGC *gc_hook;
  89. char *cache_expired;
  90. };
  91. netsnmp_arp_access *
  92. netsnmp_access_arp_create(u_int init_flags,
  93. NetsnmpAccessArpUpdate *update_hook,
  94. NetsnmpAccessArpGC *gc_hook,
  95. int *cache_timeout, int *cache_flags,
  96. char *cache_expired);
  97. #define NETSNMP_ACCESS_ARP_CREATE_NOFLAGS 0x0000
  98. int netsnmp_access_arp_delete(netsnmp_arp_access *access);
  99. int netsnmp_access_arp_load(netsnmp_arp_access *access);
  100. int netsnmp_access_arp_unload(netsnmp_arp_access *access);
  101. /*
  102. * create/free a arp+entry
  103. */
  104. netsnmp_arp_entry *
  105. netsnmp_access_arp_entry_create(void);
  106. void netsnmp_access_arp_entry_free(netsnmp_arp_entry * entry);
  107. void netsnmp_access_arp_entry_update(netsnmp_arp_entry *entry,
  108. netsnmp_arp_entry *new_data);
  109. /*
  110. * find entry in container
  111. */
  112. /** not yet */
  113. /**---------------------------------------------------------------------*/
  114. #ifdef __cplusplus
  115. }
  116. #endif
  117. #endif /* NETSNMP_ACCESS_ARP_H */