route.h 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. /*
  2. * route data access header
  3. *
  4. * $Id$
  5. */
  6. #ifndef NETSNMP_ACCESS_ROUTE_H
  7. #define NETSNMP_ACCESS_ROUTE_H
  8. # ifdef __cplusplus
  9. extern "C" {
  10. #endif
  11. /**---------------------------------------------------------------------*/
  12. /*
  13. * structure definitions
  14. */
  15. #if defined( NETSNMP_ENABLE_IPV6 )
  16. # define NETSNMP_ACCESS_ROUTE_ADDR_BUF_SIZE 16
  17. #else
  18. # define NETSNMP_ACCESS_ROUTE_ADDR_BUF_SIZE 4
  19. #endif
  20. /*
  21. * netsnmp_route_entry
  22. * - primary route structure for both ipv4 & ipv6
  23. */
  24. typedef struct netsnmp_route_s {
  25. netsnmp_index oid_index; /* MUST BE FIRST!! for container use */
  26. oid ns_rt_index; /* arbitrary index */
  27. int flags; /* for net-snmp use */
  28. oid if_index;
  29. /*
  30. * addresses, in network byte order
  31. */
  32. u_char rt_dest[NETSNMP_ACCESS_ROUTE_ADDR_BUF_SIZE];
  33. u_char rt_nexthop[NETSNMP_ACCESS_ROUTE_ADDR_BUF_SIZE];
  34. #ifdef USING_IP_FORWARD_MIB_INETCIDRROUTETABLE_INETCIDRROUTETABLE_MODULE
  35. /*
  36. * define the maximum oid length for a policy, for use by the
  37. * inetCidrRouteTable. Must be at least 2, for default nullOid case.
  38. */
  39. #define NETSNMP_POLICY_OID_MAX_LEN 3
  40. oid *rt_policy; /* NULL should be interpreted as { 0, 0 } */
  41. u_char rt_policy_len; /* 0-128 oids */
  42. #endif
  43. u_char rt_dest_len; /* 4 | 16 since we only do ipv4|ipv6 */
  44. u_char rt_dest_type; /* InetAddressType 0-16 */
  45. u_char rt_nexthop_len; /* 4 | 16 since we only do ipv4|ipv6*/
  46. u_char rt_nexthop_type;/* InetAddressType 0-16 */
  47. u_char rt_pfx_len; /* 0-128 bits */
  48. u_char rt_type; /* ip(1-4) != inet(1-5) */
  49. u_char rt_proto; /* ip(enum 1-16) ?= inet(IANAipRouteProtocol 1-17) */
  50. #ifdef USING_IP_FORWARD_MIB_IPCIDRROUTETABLE_IPCIDRROUTETABLE_MODULE
  51. /** rt_info != inet_policy, because that would have made sense */
  52. uint8_t rt_info_len; /* 0-128 oids */
  53. oid *rt_info; /* NULL should be interpreted as { 0, 0 } */
  54. uint32_t rt_mask; /* ipv4 only */
  55. uint32_t rt_tos; /* Integer32 (0..2147483647) */
  56. #endif
  57. uint32_t rt_age; /* seconds (ip == inet) */
  58. int32_t rt_nexthop_as; /* ip(int32) == inet(InetAutonomousSystemNumber) */
  59. int32_t rt_metric1;
  60. int32_t rt_metric2;
  61. int32_t rt_metric3;
  62. int32_t rt_metric4;
  63. int32_t rt_metric5;
  64. } netsnmp_route_entry;
  65. /**---------------------------------------------------------------------*/
  66. /*
  67. * ACCESS function prototypes
  68. */
  69. /*
  70. * ifcontainer init
  71. */
  72. netsnmp_container * netsnmp_access_route_container_init(u_int init_flags);
  73. #define NETSNMP_ACCESS_ROUTE_INIT_NOFLAGS 0x0000
  74. #define NETSNMP_ACCESS_ROUTE_INIT_ADDL_IDX_BY_NAME 0x0001
  75. /*
  76. * ifcontainer load and free
  77. */
  78. netsnmp_container*
  79. netsnmp_access_route_container_load(netsnmp_container* container,
  80. u_int load_flags);
  81. #define NETSNMP_ACCESS_ROUTE_LOAD_NOFLAGS 0x0000
  82. #define NETSNMP_ACCESS_ROUTE_LOAD_IPV4_ONLY 0x0001
  83. void netsnmp_access_route_container_free(netsnmp_container *container,
  84. u_int free_flags);
  85. #define NETSNMP_ACCESS_ROUTE_FREE_NOFLAGS 0x0000
  86. #define NETSNMP_ACCESS_ROUTE_FREE_DONT_CLEAR 0x0001
  87. #define NETSNMP_ACCESS_ROUTE_FREE_KEEP_CONTAINER 0x0002
  88. /*
  89. * create/copy/free a route entry
  90. */
  91. netsnmp_route_entry *
  92. netsnmp_access_route_entry_create(void);
  93. void netsnmp_access_route_entry_free(netsnmp_route_entry * entry);
  94. int
  95. netsnmp_access_route_entry_copy(netsnmp_route_entry *lhs,
  96. netsnmp_route_entry *rhs);
  97. /*
  98. * find entry in container
  99. */
  100. /** not yet */
  101. /*
  102. * create/change/delete
  103. */
  104. int
  105. netsnmp_access_route_entry_set(netsnmp_route_entry * entry);
  106. /*
  107. * route flags
  108. * upper bits for internal use
  109. * lower bits indicate changed fields. see FLAG_INETCIDRROUTE* definitions in
  110. * inetCidrRouteTable_constants.h
  111. */
  112. #define NETSNMP_ACCESS_ROUTE_CREATE 0x80000000
  113. #define NETSNMP_ACCESS_ROUTE_DELETE 0x40000000
  114. #define NETSNMP_ACCESS_ROUTE_CHANGE 0x20000000
  115. #define NETSNMP_ACCESS_ROUTE_POLICY_STATIC 0x10000000
  116. #define NETSNMP_ACCESS_ROUTE_POLICY_DEEP_COPY 0x08000000
  117. /*
  118. * mask for change flag bits
  119. */
  120. #define NETSNMP_ACCESS_ROUTE_RESERVED_BITS 0x000001ff
  121. /**---------------------------------------------------------------------*/
  122. # ifdef __cplusplus
  123. }
  124. #endif
  125. #endif /* NETSNMP_ACCESS_ROUTE_H */