1 /* 2 * ipaddress data access header 3 * 4 * $Id$ 5 */ 6 #ifndef NETSNMP_ACCESS_IPADDRESS_H 7 #define NETSNMP_ACCESS_IPADDRESS_H 8 9 # ifdef __cplusplus 10 extern "C" { 11 #endif 12 13 /**---------------------------------------------------------------------*/ 14 /* 15 * structure definitions 16 */ 17 #if defined( NETSNMP_ENABLE_IPV6 ) 18 # define NETSNMP_ACCESS_IPADDRESS_BUF_SIZE 16 /* xxx-rks: 20, for ip6z? */ 19 #else 20 # define NETSNMP_ACCESS_IPADDRESS_BUF_SIZE 4 21 #endif 22 23 24 /* 25 * netsnmp_ipaddress_entry 26 * - primary ipaddress structure for both ipv4 & ipv6 27 */ 28 typedef struct netsnmp_ipaddress_s { 29 30 netsnmp_index oid_index; /* MUST BE FIRST!! for container use */ 31 oid ns_ia_index; /* arbitrary index */ 32 33 int flags; /* for net-snmp use */ 34 35 /* 36 * mib related data (considered for 37 * netsnmp_access_ipaddress_entry_update) 38 */ 39 40 u_char ia_address[NETSNMP_ACCESS_IPADDRESS_BUF_SIZE]; 41 42 oid if_index; 43 44 u_char ia_address_len;/* address len, 4 | 16 */ 45 u_char ia_prefix_len; /* 1-128 bits */ 46 u_char ia_type; /* 1-3 */ 47 u_char ia_status; /* IpAddressStatus (1-7) */ 48 u_char ia_origin; /* IpAddressOrigin (1-6) */ 49 u_char ia_storagetype; /* IpAddressStorageType (1-5) */ 50 u_char ia_onlink_flag; /* IpOnlinkFlag */ 51 u_char ia_autonomous_flag; /*IpAutonomousFlag */ 52 u_long ia_prefered_lifetime;/*IpPreferedLifeTime*/ 53 u_long ia_valid_lifetime;/*IpValidLifeTime*/ 54 netsnmp_data_list *arch_data; /* arch specific data */ 55 56 } netsnmp_ipaddress_entry; 57 58 59 /**---------------------------------------------------------------------*/ 60 /* 61 * ACCESS function prototypes 62 */ 63 /* 64 * ifcontainer init 65 */ 66 netsnmp_container * netsnmp_access_ipaddress_container_init(u_int init_flags); 67 #define NETSNMP_ACCESS_IPADDRESS_INIT_NOFLAGS 0x0000 68 #define NETSNMP_ACCESS_IPADDRESS_INIT_ADDL_IDX_BY_ADDR 0x0001 69 70 /* 71 * ifcontainer load and free 72 */ 73 netsnmp_container* 74 netsnmp_access_ipaddress_container_load(netsnmp_container* container, 75 u_int load_flags); 76 #define NETSNMP_ACCESS_IPADDRESS_LOAD_NOFLAGS 0x0000 77 #define NETSNMP_ACCESS_IPADDRESS_LOAD_IPV4_ONLY 0x0001 78 #define NETSNMP_ACCESS_IPADDRESS_LOAD_IPV6_ONLY 0x0002 79 #define NETSNMP_ACCESS_IPADDRESS_LOAD_ADDL_IDX_BY_ADDR 0x0004 80 81 void netsnmp_access_ipaddress_container_free(netsnmp_container *container, 82 u_int free_flags); 83 #define NETSNMP_ACCESS_IPADDRESS_FREE_NOFLAGS 0x0000 84 #define NETSNMP_ACCESS_IPADDRESS_FREE_DONT_CLEAR 0x0001 85 #define NETSNMP_ACCESS_IPADDRESS_FREE_KEEP_CONTAINER 0x0002 86 87 88 /* 89 * create/free a ipaddress+entry 90 */ 91 netsnmp_ipaddress_entry * 92 netsnmp_access_ipaddress_entry_create(void); 93 94 void netsnmp_access_ipaddress_entry_free(netsnmp_ipaddress_entry * entry); 95 96 /* 97 * copy 98 */ 99 int 100 netsnmp_access_ipaddress_entry_copy(netsnmp_ipaddress_entry *old, 101 netsnmp_ipaddress_entry *new_val); 102 103 /* 104 * update/compare 105 */ 106 int 107 netsnmp_access_ipaddress_entry_update(netsnmp_ipaddress_entry *old, 108 netsnmp_ipaddress_entry *new_val); 109 110 /* 111 * find entry in container 112 */ 113 /** not yet */ 114 115 /* 116 * create/change/delete 117 */ 118 int 119 netsnmp_access_ipaddress_entry_set(netsnmp_ipaddress_entry * entry); 120 121 122 /* 123 * ipaddress flags 124 * upper bits for internal use 125 * lower bits indicate changed fields. see FLAG_IPADDRESS* definitions in 126 * ipAddressTable_constants.h 127 */ 128 #define NETSNMP_ACCESS_IPADDRESS_CREATE 0x80000000 129 #define NETSNMP_ACCESS_IPADDRESS_DELETE 0x40000000 130 #define NETSNMP_ACCESS_IPADDRESS_CHANGE 0x20000000 131 132 #define NETSNMP_ACCESS_IPADDRESS_ISALIAS 0x10000000 133 134 /* 135 * mask for change flag bits 136 */ 137 #define NETSNMP_ACCESS_IPADDRESS_RESERVED_BITS 0x0000001f 138 139 140 /* 141 * utility routines 142 */ 143 int netsnmp_ipaddress_prefix_copy(u_char *dst, u_char *src, 144 int addr_len, int pfx_len); 145 146 int netsnmp_ipaddress_ipv4_prefix_len(in_addr_t mask); 147 in_addr_t netsnmp_ipaddress_ipv4_mask(int len); 148 int netsnmp_ipaddress_ipv6_prefix_len(struct in6_addr mask); 149 150 int netsnmp_ipaddress_flags_copy(u_long *ipAddressPrefixAdvPreferredLifetime, 151 u_long *ipAddressPrefixAdvValidLifetime, 152 u_long *ipAddressPrefixOnLinkFlag, 153 u_long *ipAddressPrefixAutonomousFlag, 154 u_long *ia_prefered_lifetime, 155 u_long *ia_valid_lifetime, 156 u_char *ia_onlink_flag, 157 u_char *ia_autonomous_flag); 158 159 int netsnmp_ipaddress_prefix_origin_copy(u_long *ipAddressPrefixOrigin, 160 u_char ia_origin, 161 int flags, 162 u_long ipAddressAddrType); 163 164 /**---------------------------------------------------------------------*/ 165 166 # ifdef __cplusplus 167 } 168 #endif 169 170 #endif /* NETSNMP_ACCESS_IPADDRESS_H */ 171