View | Details | Raw Unified | Return to bug 83643
Collapse All | Expand All

(-)Makefile (-3 lines)
Lines 16-24 Link Here
16
MAINTAINER=	kuriyama@FreeBSD.org
16
MAINTAINER=	kuriyama@FreeBSD.org
17
COMMENT=	An extendable SNMP implementation
17
COMMENT=	An extendable SNMP implementation
18
18
19
.if defined(WITH_INETADDRESS_HACK)
20
EXTRA_PATCHES+=	${PATCHDIR}/extra-patch-snmplib::mib.c
21
.endif
22
.if !defined(WITH_TKMIB)
19
.if !defined(WITH_TKMIB)
23
EXTRA_PATCHES+=	${PATCHDIR}/extra-patch-local:Makefile.in
20
EXTRA_PATCHES+=	${PATCHDIR}/extra-patch-local:Makefile.in
24
.endif
21
.endif
(-)files/extra-patch-snmplib::mib.c (-136 lines)
Removed Link Here
1
--- snmplib/mib.c.orig	Sun Nov  2 12:50:39 2003
2
+++ snmplib/mib.c	Sat Jan  3 03:08:38 2004
3
@@ -167,6 +167,14 @@
4
     {NULL, 0}                   /* end of list */
5
 };
6
 
7
+enum inet_address_type {
8
+    IPV4 = 1,
9
+    IPV6 = 2,
10
+    IPV4Z = 3,
11
+    IPV6Z = 4,
12
+    DNS = 16
13
+};
14
+
15
 
16
 /**
17
  * @internal
18
@@ -3734,6 +3742,80 @@
19
     return SNMPERR_SUCCESS;
20
 }
21
 
22
+/*
23
+ * dump_realloc_oid_to_inetaddress:
24
+ *   return 1 for success,
25
+ *   return 0 for failure,
26
+ *   return 2 for not handled
27
+ */
28
+
29
+int 
30
+dump_realloc_oid_to_inetaddress(const int addr_type, const oid * objid, size_t objidlen, 
31
+                                u_char ** buf, size_t * buf_len,
32
+                                size_t * out_len, int allow_realloc, 
33
+                                char quotechar)
34
+{
35
+    if (buf) {
36
+        int             i, len;
37
+        char            intbuf[64], * p;
38
+        u_int32_t       zone;
39
+
40
+        memset(intbuf, 0, 64);
41
+
42
+        p = intbuf;
43
+        *p = quotechar;
44
+        p++;
45
+        switch (addr_type) {
46
+            case IPV4:
47
+            case IPV4Z:
48
+                if ((addr_type == IPV4 && objidlen != 4) ||
49
+                    (addr_type == IPV4Z && objidlen != 8))
50
+                    return 2;
51
+
52
+                len = sprintf(p, "%lu.%lu.%lu.%lu", objid[0], objid[1], objid[2], objid[3]);
53
+                p += len;
54
+                if (addr_type == IPV4Z) {
55
+                    zone = ntohl(*((u_int32_t *) objid[4]));
56
+                    len = sprintf(p, "\%%lu", zone);
57
+                    p += len;
58
+                }
59
+
60
+                break;
61
+
62
+            case IPV6:
63
+            case IPV6Z:
64
+                if ((addr_type == IPV6 && objidlen != 16) ||
65
+                    (addr_type == IPV6Z && objidlen != 20))
66
+                    return 2;
67
+
68
+                len = 0;
69
+                for (i = 0; i < 16; i ++) {
70
+                    len += snprintf(p, 4, "%02x:", objid[i]);
71
+                    p += 3;
72
+                }
73
+                p-- ; /* do not include the last ':' */
74
+
75
+                if (addr_type == IPV6Z) {
76
+                    zone = ntohl(*((u_int32_t *) objid[4]));
77
+                    len = sprintf(p, "\%%lu", zone);
78
+                    p += len;
79
+                }
80
+
81
+                break;
82
+
83
+            case DNS:
84
+            default: 
85
+                /* DNS can just be handled by dump_realloc_oid_to_string() */
86
+                return 2;
87
+        }
88
+
89
+        *p = quotechar;
90
+        return snmp_strcat(buf, buf_len, out_len, allow_realloc, 
91
+                                               (const u_char *) intbuf);
92
+    }
93
+    return 1;
94
+}
95
+
96
 int
97
 dump_realloc_oid_to_string(const oid * objid, size_t objidlen,
98
                            u_char ** buf, size_t * buf_len,
99
@@ -4043,7 +4125,36 @@
100
                     }
101
                 } else {
102
                     if (!*buf_overflow) {
103
-                        if (!dump_realloc_oid_to_string
104
+                        struct tree * next_peer;
105
+                        int normal_handling = 1;
106
+
107
+                        if (tp->next_peer) {
108
+                            next_peer = tp->next_peer;
109
+                        }
110
+
111
+                        /* Try handling the InetAddress in the OID, in case of failure,
112
+                         * use the normal_handling. 
113
+                         */
114
+                        if (tp->next_peer &&
115
+                            strcmp(get_tc_descriptor(tp->tc_index), "InetAddress") == 0 &&
116
+                            strcmp(get_tc_descriptor(next_peer->tc_index), 
117
+                                    "InetAddressType") == 0 ) {
118
+
119
+                            int ret;
120
+                            int addr_type = *(objid - 1);
121
+
122
+                            ret = dump_realloc_oid_to_inetaddress(addr_type, 
123
+                                        objid + 1, numids - 1, buf, buf_len, out_len,
124
+                                        allow_realloc, '"');
125
+                            if (ret != 2) {
126
+                                normal_handling = 0;
127
+                                if (ret == 0) {
128
+                                    *buf_overflow = 1;
129
+                                }
130
+
131
+                            }
132
+                        } 
133
+                        if (normal_handling && !dump_realloc_oid_to_string
134
                             (objid + 1, numids - 1, buf, buf_len, out_len,
135
                              allow_realloc, '"')) {
136
                             *buf_overflow = 1;

Return to bug 83643