Mon, 28 Jan 2013 17:37:18 +0100
Correct socket error reporting improvement with IPv6 portable code,
after helpful recommendation by Saúl Ibarra Corretgé on OSips devlist.
1 Index: agent/mibgroup/ip-mib/data_access/ipaddress_common.c
2 --- agent/mibgroup/ip-mib/data_access/ipaddress_common.c.orig 2011-09-28 06:53:47.000000000 +0200
3 +++ agent/mibgroup/ip-mib/data_access/ipaddress_common.c 2012-02-18 21:20:51.943118452 +0100
4 @@ -452,6 +452,7 @@
5 {
6 const netsnmp_ipaddress_entry *lh = (const netsnmp_ipaddress_entry *)lhs;
7 const netsnmp_ipaddress_entry *rh = (const netsnmp_ipaddress_entry *)rhs;
8 + int rc;
10 netsnmp_assert(NULL != lhs);
11 netsnmp_assert(NULL != rhs);
12 @@ -467,7 +468,19 @@
13 /*
14 * length equal, compare address
15 */
16 - return memcmp(lh->ia_address, rh->ia_address, lh->ia_address_len);
17 + rc = memcmp(lh->ia_address, rh->ia_address, lh->ia_address_len);
18 + if (rc)
19 + return rc;
20 +
21 + /*
22 + * address same, compare ifIndex
23 + */
24 + if (lh->if_index < rh->if_index)
25 + return -1;
26 + else if (lh->if_index > rh->if_index)
27 + return 1;
28 +
29 + return 0;
30 }
32 #ifndef NETSNMP_FEATURE_REMOVE_IPADDRESS_COMMON_COPY_UTILITIES
33 Index: agent/mibgroup/ip-mib/ipAddressTable/ipAddressTable_constants.h
34 --- agent/mibgroup/ip-mib/ipAddressTable/ipAddressTable_constants.h.orig 2011-09-28 06:53:47.000000000 +0200
35 +++ agent/mibgroup/ip-mib/ipAddressTable/ipAddressTable_constants.h 2012-02-18 21:20:51.939850024 +0100
36 @@ -106,7 +106,9 @@
37 * simplistic map of address length to type
38 */
39 #define INTERNAL_IPADDRESSTABLE_IPADDRESSADDRTYPE_IPV4 4
40 +#define INTERNAL_IPADDRESSTABLE_IPADDRESSADDRTYPE_IPV4Z 5
41 #define INTERNAL_IPADDRESSTABLE_IPADDRESSADDRTYPE_IPV6 16
42 +#define INTERNAL_IPADDRESSTABLE_IPADDRESSADDRTYPE_IPV6Z 17
45 /*************************************************************
46 Index: agent/mibgroup/ip-mib/ipAddressTable/ipAddressTable_data_access.c
47 --- agent/mibgroup/ip-mib/ipAddressTable/ipAddressTable_data_access.c.orig 2012-02-18 21:02:55.315118127 +0100
48 +++ agent/mibgroup/ip-mib/ipAddressTable/ipAddressTable_data_access.c 2012-02-18 21:20:51.933373869 +0100
49 @@ -262,9 +262,10 @@
50 if ((NULL != rowreq_ctx) &&
51 (MFD_SUCCESS ==
52 ipAddressTable_indexes_set(rowreq_ctx,
53 - ipaddress_entry->ia_address_len,
54 + ipaddress_entry->ia_address_len + 1,
55 ipaddress_entry->ia_address,
56 - ipaddress_entry->ia_address_len))) {
57 + ipaddress_entry->ia_address_len,
58 + ipaddress_entry->if_index))) {
59 if (CONTAINER_INSERT(container, rowreq_ctx) < 0) {
60 DEBUGMSGTL (("ipAddressTable:access","container insert failed for new entry\n"));
61 ipAddressTable_release_rowreq_ctx(rowreq_ctx);
62 Index: agent/mibgroup/ip-mib/ipAddressTable/ipAddressTable.c
63 --- agent/mibgroup/ip-mib/ipAddressTable/ipAddressTable.c.orig 2011-09-28 06:53:47.000000000 +0200
64 +++ agent/mibgroup/ip-mib/ipAddressTable/ipAddressTable.c 2012-02-18 21:24:03.877503380 +0100
65 @@ -355,10 +355,18 @@
66 *mib_ipAddressAddrType_val_ptr = INETADDRESSTYPE_IPV4;
67 break;
69 + case INTERNAL_IPADDRESSTABLE_IPADDRESSADDRTYPE_IPV4Z:
70 + *mib_ipAddressAddrType_val_ptr = INETADDRESSTYPE_IPV4Z;
71 + break;
72 +
73 case INTERNAL_IPADDRESSTABLE_IPADDRESSADDRTYPE_IPV6:
74 *mib_ipAddressAddrType_val_ptr = INETADDRESSTYPE_IPV6;
75 break;
77 + case INTERNAL_IPADDRESSTABLE_IPADDRESSADDRTYPE_IPV6Z:
78 + *mib_ipAddressAddrType_val_ptr = INETADDRESSTYPE_IPV6Z;
79 + break;
80 +
81 default:
82 snmp_log(LOG_ERR, "couldn't map value %ld for ipAddressAddrType\n",
83 raw_ipAddressAddrType_val);
84 @@ -389,8 +397,10 @@
85 ipAddressTable_indexes_set_tbl_idx(ipAddressTable_mib_index * tbl_idx,
86 long ipAddressAddrType_val,
87 u_char *ipAddressAddr_val_ptr,
88 - size_t ipAddressAddr_val_ptr_len)
89 + size_t ipAddressAddr_val_ptr_len,
90 + long ipAddressAddr_ifIndex)
91 {
92 + uint32_t zone = htonl(ipAddressAddr_ifIndex);
93 DEBUGMSGTL(("verbose:ipAddressTable:ipAddressTable_indexes_set_tbl_idx", "called\n"));
95 /*
96 @@ -416,6 +426,11 @@
97 memcpy(tbl_idx->ipAddressAddr, ipAddressAddr_val_ptr,
98 ipAddressAddr_val_ptr_len * sizeof(ipAddressAddr_val_ptr[0]));
100 + /** zone */
101 + tbl_idx->ipAddressAddr_len += sizeof(zone);
102 + memcpy(&tbl_idx->ipAddressAddr[ipAddressAddr_val_ptr_len *
103 + sizeof(ipAddressAddr_val_ptr[0])],
104 + &zone, sizeof(zone));
106 return MFD_SUCCESS;
107 } /* ipAddressTable_indexes_set_tbl_idx */
108 @@ -437,7 +452,8 @@
109 ipAddressTable_indexes_set(ipAddressTable_rowreq_ctx * rowreq_ctx,
110 u_long ipAddressAddrType_val,
111 u_char *ipAddressAddr_val_ptr,
112 - size_t ipAddressAddr_val_ptr_len)
113 + size_t ipAddressAddr_val_ptr_len,
114 + long ipAddressAddr_ifIndex)
115 {
116 DEBUGMSGTL(("verbose:ipAddressTable:ipAddressTable_indexes_set",
117 "called\n"));
118 @@ -446,7 +462,8 @@
119 ipAddressTable_indexes_set_tbl_idx(&rowreq_ctx->tbl_idx,
120 ipAddressAddrType_val,
121 ipAddressAddr_val_ptr,
122 - ipAddressAddr_val_ptr_len))
123 + ipAddressAddr_val_ptr_len,
124 + ipAddressAddr_ifIndex))
125 return MFD_ERROR;
127 /*
128 Index: agent/mibgroup/ip-mib/ipAddressTable/ipAddressTable.h
129 --- agent/mibgroup/ip-mib/ipAddressTable/ipAddressTable.h.orig 2011-09-28 06:53:47.000000000 +0200
130 +++ agent/mibgroup/ip-mib/ipAddressTable/ipAddressTable.h 2012-02-18 21:25:15.751422674 +0100
131 @@ -273,14 +273,16 @@
132 long ipAddressAddrType_val,
133 u_char *ipAddressAddr_val_ptr,
134 size_t
135 - ipAddressAddr_val_ptr_len);
136 + ipAddressAddr_val_ptr_len,
137 + long ipAddressAddr_ifIndex);
138 int ipAddressTable_indexes_set(ipAddressTable_rowreq_ctx *
139 rowreq_ctx,
140 u_long
141 ipAddressAddrType_val,
142 u_char *ipAddressAddr_val_ptr,
143 size_t
144 - ipAddressAddr_val_ptr_len);
145 + ipAddressAddr_val_ptr_len,
146 + long ipAddressAddr_ifIndex);