Output from SNMPwalk after this patch:
KAMAILIO-SIP-COMMON-MIB::kamailioSIPTransportRcv.ipv6."20:01:DB:80:21:2e:00:00:00:00:00:00:00:00:00:22".5080 = BITS: 40 udp(1)
... | ... |
@@ -28,7 +28,7 @@ |
28 | 28 |
* History: |
29 | 29 |
* -------- |
30 | 30 |
* 2006-11-23 initial version (jmagder) |
31 |
- * 2013-02-24 Added WS, WSS and SCTP support (oej) |
|
31 |
+ * 2013-02-24 Added SCTP support (oej) |
|
32 | 32 |
* |
33 | 33 |
* Originally Generated with mib2c using mib2c.array-user.conf |
34 | 34 |
* |
... | ... |
@@ -65,18 +65,21 @@ size_t kamailioSIPPortTable_oid_len = OID_LENGTH(kamailioSIPPortTable_oid); |
65 | 65 |
* Note: This function returns a newly allocated block of memory. Make sure to |
66 | 66 |
* deallocate the memory when you no longer need it. |
67 | 67 |
*/ |
68 |
-oid *createIndex(int ipType, int *ipAddress, int *sizeOfOID) |
|
68 |
+static oid *createIndex(int ipType, int *ipAddress, int *sizeOfOID) |
|
69 | 69 |
{ |
70 | 70 |
oid *currentOIDIndex; |
71 | 71 |
int i; |
72 |
+ int family = ipType == 1 ? AF_INET : AF_INET6; |
|
73 |
+ int num_octets = family == AF_INET ? NUM_IP_OCTETS : NUM_IPV6_OCTETS; |
|
72 | 74 |
|
73 | 75 |
/* The size needs to be large enough such that it can store the ipType |
74 | 76 |
* (one octet), the prefixed length (one octet), the number of |
75 | 77 |
* octets to the IP Address (NUM_IP_OCTETS), and the port. */ |
76 |
- *sizeOfOID = NUM_IP_OCTETS + 3; |
|
78 |
+ *sizeOfOID = num_octets + 3; |
|
77 | 79 |
|
78 | 80 |
/* Allocate space for the OID Index. */ |
79 | 81 |
currentOIDIndex = pkg_malloc((*sizeOfOID) * sizeof(oid)); |
82 |
+ LM_DBG("----> Size of OID %d \n", *sizeOfOID); |
|
80 | 83 |
|
81 | 84 |
if (currentOIDIndex == NULL) { |
82 | 85 |
LM_ERR("failed to create a row for kamailioSIPPortTable\n"); |
... | ... |
@@ -86,14 +89,15 @@ oid *createIndex(int ipType, int *ipAddress, int *sizeOfOID) |
86 | 89 |
|
87 | 90 |
/* Assign the OID Index */ |
88 | 91 |
currentOIDIndex[0] = ipType; |
89 |
- currentOIDIndex[1] = NUM_IP_OCTETS; |
|
92 |
+ currentOIDIndex[1] = num_octets; |
|
90 | 93 |
|
91 |
- for (i = 0; i < NUM_IP_OCTETS; i++) { |
|
94 |
+ for (i = 0; i < num_octets; i++) { |
|
92 | 95 |
currentOIDIndex[i+2] = ipAddress[i]; |
93 | 96 |
} |
94 | 97 |
|
95 | 98 |
/* Extract out the port number */ |
96 |
- currentOIDIndex[NUM_IP_OCTETS+2] = ipAddress[NUM_IP_OCTETS]; |
|
99 |
+ currentOIDIndex[num_octets + 2] = ipAddress[num_octets]; |
|
100 |
+ LM_DBG("----> Port number %d Family %s \n", ipAddress[num_octets], ipType == 1 ? "IPv4" : "IPv6"); |
|
97 | 101 |
|
98 | 102 |
return currentOIDIndex; |
99 | 103 |
} |
... | ... |
@@ -105,23 +109,22 @@ oid *createIndex(int ipType, int *ipAddress, int *sizeOfOID) |
105 | 109 |
* |
106 | 110 |
* Note: NULL will be returned on an error |
107 | 111 |
*/ |
108 |
-kamailioSIPPortTable_context *getRow(int ipType, int *ipAddress) |
|
112 |
+kamailioSIPPortTable_context *getRow(int ipType, int *ipAddress) |
|
109 | 113 |
{ |
110 | 114 |
int lengthOfOID; |
111 | 115 |
oid *currentOIDIndex = createIndex(ipType, ipAddress, &lengthOfOID); |
116 |
+ netsnmp_index theIndex; |
|
117 |
+ kamailioSIPPortTable_context *rowToReturn; |
|
118 |
+ int num_octets = ipType == 1 ? NUM_IP_OCTETS : NUM_IPV6_OCTETS; |
|
112 | 119 |
|
113 | 120 |
if (currentOIDIndex == NULL) |
114 | 121 |
{ |
115 | 122 |
return NULL; |
116 | 123 |
} |
117 | 124 |
|
118 |
- netsnmp_index theIndex; |
|
119 |
- |
|
120 | 125 |
theIndex.oids = currentOIDIndex; |
121 | 126 |
theIndex.len = lengthOfOID; |
122 | 127 |
|
123 |
- kamailioSIPPortTable_context *rowToReturn; |
|
124 |
- |
|
125 | 128 |
/* Lets check to see if there is an existing row. */ |
126 | 129 |
rowToReturn = CONTAINER_FIND(cb.container, &theIndex); |
127 | 130 |
|
... | ... |
@@ -149,8 +152,8 @@ kamailioSIPPortTable_context *getRow(int ipType, int *ipAddress) |
149 | 152 |
rowToReturn->index.len = lengthOfOID; |
150 | 153 |
rowToReturn->index.oids = currentOIDIndex; |
151 | 154 |
|
152 |
- memcpy(rowToReturn->kamailioSIPStringIndex, currentOIDIndex, NUM_IP_OCTETS + 3); |
|
153 |
- rowToReturn->kamailioSIPStringIndex_len = NUM_IP_OCTETS + 3; |
|
155 |
+ memcpy(rowToReturn->kamailioSIPStringIndex, currentOIDIndex, num_octets + 3); |
|
156 |
+ rowToReturn->kamailioSIPStringIndex_len = num_octets + 3; |
|
154 | 157 |
|
155 | 158 |
/* Insert the new row into the table */ |
156 | 159 |
CONTAINER_INSERT(cb.container, rowToReturn); |
... | ... |
@@ -167,7 +170,7 @@ kamailioSIPPortTable_context *getRow(int ipType, int *ipAddress) |
167 | 170 |
* 'protocol', we can continue from the last index. |
168 | 171 |
*/ |
169 | 172 |
void createRowsFromIPList(int *theList, int listSize, int protocol, |
170 |
- int *snmpIndex) { |
|
173 |
+ int *snmpIndex, int family) { |
|
171 | 174 |
|
172 | 175 |
kamailioSIPPortTable_context *currentRow; |
173 | 176 |
|
... | ... |
@@ -210,8 +213,10 @@ void createRowsFromIPList(int *theList, int listSize, int protocol, |
210 | 213 |
curIndexOfIP = (NUM_IP_OCTETS + 1) * curSocketIdx; |
211 | 214 |
|
212 | 215 |
/* Retrieve an existing row, or a new row if one doesn't |
213 |
- * allready exist. */ |
|
214 |
- currentRow = getRow(1, &theList[curIndexOfIP]); |
|
216 |
+ * already exist. |
|
217 |
+ * RFC 4001 defined IPv4 as 1, IPv6 as 2 |
|
218 |
+ */ |
|
219 |
+ currentRow = getRow(family == AF_INET? 1 : 2, &theList[curIndexOfIP]); |
|
215 | 220 |
|
216 | 221 |
if (currentRow == NULL) { |
217 | 222 |
LM_ERR("failed to create all the " |
... | ... |
@@ -240,43 +245,55 @@ void init_kamailioSIPPortTable(void) |
240 | 245 |
int *UDPList = NULL; |
241 | 246 |
int *TCPList = NULL; |
242 | 247 |
int *TLSList = NULL; |
243 |
- int *WSList = NULL; |
|
244 |
- int *WSSList = NULL; |
|
245 | 248 |
int *SCTPList = NULL; |
246 | 249 |
|
250 |
+ int *UDP6List = NULL; |
|
251 |
+ int *TCP6List = NULL; |
|
252 |
+ int *TLS6List = NULL; |
|
253 |
+ int *SCTP6List = NULL; |
|
254 |
+ |
|
247 | 255 |
int numUDPSockets; |
248 | 256 |
int numTCPSockets; |
249 | 257 |
int numTLSSockets; |
250 |
- int numWSSockets; |
|
251 |
- int numWSSSockets; |
|
252 | 258 |
int numSCTPSockets; |
259 |
+ |
|
260 |
+ int numUDP6Sockets; |
|
261 |
+ int numTCP6Sockets; |
|
262 |
+ int numTLS6Sockets; |
|
263 |
+ int numSCTP6Sockets; |
|
253 | 264 |
|
254 | 265 |
/* Retrieve the list of the number of UDP and TCP sockets. */ |
255 |
- numUDPSockets = get_socket_list_from_proto(&UDPList, PROTO_UDP); |
|
256 |
- numTCPSockets = get_socket_list_from_proto(&TCPList, PROTO_TCP); |
|
257 |
- numTLSSockets = get_socket_list_from_proto(&TLSList, PROTO_TLS); |
|
258 |
- numWSSockets = get_socket_list_from_proto(&WSList, PROTO_WS); |
|
259 |
- numWSSSockets = get_socket_list_from_proto(&WSSList, PROTO_WSS); |
|
260 |
- numSCTPSockets = get_socket_list_from_proto(&SCTPList, PROTO_SCTP); |
|
266 |
+ numUDPSockets = get_socket_list_from_proto_and_family(&UDPList, PROTO_UDP, AF_INET); |
|
267 |
+ numUDP6Sockets = get_socket_list_from_proto_and_family(&UDP6List, PROTO_UDP, AF_INET6); |
|
268 |
+ numTCPSockets = get_socket_list_from_proto_and_family(&TCPList, PROTO_TCP, AF_INET); |
|
269 |
+ numTCP6Sockets = get_socket_list_from_proto_and_family(&TCP6List, PROTO_TCP, AF_INET6); |
|
270 |
+ numTLSSockets = get_socket_list_from_proto_and_family(&TLSList, PROTO_TLS, AF_INET); |
|
271 |
+ numTLS6Sockets = get_socket_list_from_proto_and_family(&TLS6List, PROTO_TLS, AF_INET6); |
|
272 |
+ numSCTPSockets = get_socket_list_from_proto_and_family(&SCTPList, PROTO_SCTP, AF_INET); |
|
273 |
+ numSCTP6Sockets = get_socket_list_from_proto_and_family(&SCTP6List, PROTO_SCTP, AF_INET6); |
|
274 |
+ |
|
275 |
+ LM_DBG("-----> Sockets UDP %d UDP6 %d TCP %d TCP6 %d TLS %d TLS6 %d SCTP %d SCTP6 %d\n", |
|
276 |
+ numUDPSockets, numUDP6Sockets, numTCPSockets, numTCP6Sockets, numTLSSockets, numTLS6Sockets, numSCTPSockets, numSCTP6Sockets); |
|
261 | 277 |
|
262 | 278 |
/* Generate all rows, using all retrieved interfaces. */ |
263 |
- createRowsFromIPList(UDPList, numUDPSockets, PROTO_UDP, &curSNMPIndex); |
|
264 |
- |
|
279 |
+ createRowsFromIPList(UDPList, numUDPSockets, PROTO_UDP, &curSNMPIndex, AF_INET); |
|
265 | 280 |
curSNMPIndex = 0; |
266 |
- |
|
267 |
- createRowsFromIPList(TCPList, numTCPSockets, PROTO_TCP, &curSNMPIndex); |
|
281 |
+ createRowsFromIPList(UDP6List, numUDP6Sockets, PROTO_UDP, &curSNMPIndex, AF_INET6); |
|
268 | 282 |
|
269 | 283 |
curSNMPIndex = 0; |
270 |
- createRowsFromIPList(TLSList, numTLSSockets, PROTO_TLS, &curSNMPIndex); |
|
271 |
- |
|
284 |
+ createRowsFromIPList(TCPList, numTCPSockets, PROTO_TCP, &curSNMPIndex, AF_INET); |
|
272 | 285 |
curSNMPIndex = 0; |
273 |
- createRowsFromIPList(WSList, numWSSockets, PROTO_WS, &curSNMPIndex); |
|
286 |
+ createRowsFromIPList(TCP6List, numTCP6Sockets, PROTO_TCP, &curSNMPIndex, AF_INET6); |
|
274 | 287 |
|
275 | 288 |
curSNMPIndex = 0; |
276 |
- createRowsFromIPList(WSSList, numWSSSockets, PROTO_WSS, &curSNMPIndex); |
|
289 |
+ createRowsFromIPList(TLSList, numTLSSockets, PROTO_TLS, &curSNMPIndex, AF_INET); |
|
290 |
+ curSNMPIndex = 0; |
|
291 |
+ createRowsFromIPList(TLS6List, numTLS6Sockets, PROTO_TLS, &curSNMPIndex, AF_INET6); |
|
277 | 292 |
|
278 | 293 |
curSNMPIndex = 0; |
279 |
- createRowsFromIPList(SCTPList, numSCTPSockets, PROTO_SCTP, &curSNMPIndex); |
|
294 |
+ createRowsFromIPList(SCTPList, numSCTPSockets, PROTO_SCTP, &curSNMPIndex, AF_INET); |
|
295 |
+ curSNMPIndex = 0; |
|
296 |
+ createRowsFromIPList(SCTP6List, numSCTP6Sockets, PROTO_SCTP, &curSNMPIndex, AF_INET6); |
|
280 | 297 |
} |
281 | 298 |
|
282 | 299 |
|
... | ... |
@@ -47,7 +47,8 @@ extern "C" { |
47 | 47 |
|
48 | 48 |
#include "../../config.h" |
49 | 49 |
|
50 |
-#define SIP_PORT_TABLE_STR_INDEX_SIZE 10 |
|
50 |
+// OLD #define SIP_PORT_TABLE_STR_INDEX_SIZE 10 |
|
51 |
+#define SIP_PORT_TABLE_STR_INDEX_SIZE 50 |
|
51 | 52 |
|
52 | 53 |
/* This strucutre represents a single row in the table. */ |
53 | 54 |
typedef struct kamailioSIPPortTable_context_s |
... | ... |
@@ -87,11 +88,9 @@ void initialize_table_kamailioSIPPortTable(void); |
87 | 88 |
int kamailioSIPPortTable_get_value(netsnmp_request_info *, netsnmp_index *, |
88 | 89 |
netsnmp_table_request_info *); |
89 | 90 |
|
90 |
-const kamailioSIPPortTable_context * kamailioSIPPortTable_get_by_idx( |
|
91 |
- netsnmp_index *); |
|
91 |
+const kamailioSIPPortTable_context *kamailioSIPPortTable_get_by_idx(netsnmp_index *); |
|
92 | 92 |
|
93 |
-const kamailioSIPPortTable_context * kamailioSIPPortTable_get_by_idx_rs( |
|
94 |
- netsnmp_index *, int row_status); |
|
93 |
+const kamailioSIPPortTable_context * kamailioSIPPortTable_get_by_idx_rs(netsnmp_index *, int row_status); |
|
95 | 94 |
|
96 | 95 |
/* |
97 | 96 |
* oid declarations |
... | ... |
@@ -108,7 +107,7 @@ extern size_t kamailioSIPPortTable_oid_len; |
108 | 107 |
#define COLUMN_KAMAILIOSIPTRANSPORTRCV 4 |
109 | 108 |
|
110 | 109 |
#define kamailioSIPPortTable_COL_MIN 4 |
111 |
-#define kamailioSIPPortTable_COL_MAX 4 |
|
110 |
+#define kamailioSIPPortTable_COL_MAX 12 |
|
112 | 111 |
|
113 | 112 |
|
114 | 113 |
#ifdef __cplusplus |