socsvn commit: r272175 - in soc2014/shonali/head: contrib/bsnmp/lib contrib/bsnmp/snmpd usr.sbin/bsnmpd/tools/bsnmptools usr.sbin/bsnmpd/tools/libbsnmptools
shonali at FreeBSD.org
shonali at FreeBSD.org
Sun Aug 10 18:51:07 UTC 2014
Author: shonali
Date: Sun Aug 10 18:51:05 2014
New Revision: 272175
URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=272175
Log:
Added SNMP_SYNTAX_IP6ADDRESS to snmp_syntax, added calls to ipv6 functions
Modified:
soc2014/shonali/head/contrib/bsnmp/lib/snmp.h
soc2014/shonali/head/contrib/bsnmp/snmpd/export.c
soc2014/shonali/head/usr.sbin/bsnmpd/tools/bsnmptools/bsnmpget.c
soc2014/shonali/head/usr.sbin/bsnmpd/tools/libbsnmptools/bsnmptools.c
Modified: soc2014/shonali/head/contrib/bsnmp/lib/snmp.h
==============================================================================
--- soc2014/shonali/head/contrib/bsnmp/lib/snmp.h Sun Aug 10 17:08:28 2014 (r272174)
+++ soc2014/shonali/head/contrib/bsnmp/lib/snmp.h Sun Aug 10 18:51:05 2014 (r272175)
@@ -57,6 +57,7 @@
SNMP_SYNTAX_COUNTER,
SNMP_SYNTAX_GAUGE, /* == UNSIGNED32 */
SNMP_SYNTAX_TIMETICKS,
+ SNMP_SYNTAX_IP6ADDRESS,
/* v2 additions */
SNMP_SYNTAX_COUNTER64,
Modified: soc2014/shonali/head/contrib/bsnmp/snmpd/export.c
==============================================================================
--- soc2014/shonali/head/contrib/bsnmp/snmpd/export.c Sun Aug 10 17:08:28 2014 (r272174)
+++ soc2014/shonali/head/contrib/bsnmp/snmpd/export.c Sun Aug 10 18:51:05 2014 (r272175)
@@ -366,8 +366,8 @@
switch (oid->len) {
- case 4:
- if (sub + 4 > oid->len)
+ case SNMP_IPv4_ADDR_SIZ:
+ if (sub + SNMP_IPv4_ADDR_SIZ > oid->len)
goto err;
pval = va_arg(ap, u_int8_t *);
for (i = 0; i < 4; i++) {
@@ -376,8 +376,8 @@
pval[i] = oid->subs[sub++];
}
- case 16:
- if (sub + 16 > oid->len)
+ case SNMP_IPv6_ADDR_SIZ:
+ if (sub + SNMP_IPv6_ADDR_SIZ > oid->len)
goto err;
pval = va_arg(ap, u_int8_t *);
for (i = 0; i < 16; i++) {
Modified: soc2014/shonali/head/usr.sbin/bsnmpd/tools/bsnmptools/bsnmpget.c
==============================================================================
--- soc2014/shonali/head/usr.sbin/bsnmpd/tools/bsnmptools/bsnmpget.c Sun Aug 10 17:08:28 2014 (r272174)
+++ soc2014/shonali/head/usr.sbin/bsnmpd/tools/bsnmptools/bsnmpget.c Sun Aug 10 18:51:05 2014 (r272175)
@@ -775,6 +775,8 @@
return (parse_int(value, val));
case SNMP_SYNTAX_IPADDRESS:
return (parse_ip(value, val));
+ case SNMP_SYNTAX_IP6ADDRESS:
+ return (parse_ip6(value, val));
case SNMP_SYNTAX_COUNTER:
return (parse_counter(value, val));
case SNMP_SYNTAX_GAUGE:
@@ -898,6 +900,8 @@
return (parse_int_string(object, str + len));
case SNMP_SYNTAX_IPADDRESS:
return (parse_ip(&(object->val), str + len));
+ case SNMP_SYNTAX_IP6ADDRESS:
+ return (parse_ip6(&(object->val), str + len));
case SNMP_SYNTAX_COUNTER:
return (parse_counter(&(object->val), str + len));
case SNMP_SYNTAX_GAUGE:
@@ -977,7 +981,7 @@
{
int8_t i;
- dst->syntax = src->syntax;
+ dst->syntax = SNMP_SYNTAX_IP6ADDRESS;
for (i = 0; i < 16; i++)
dst->v.ipaddress6[i] = src->v.ipaddress6[i];
@@ -1050,6 +1054,9 @@
case SNMP_SYNTAX_IPADDRESS:
add_ip_syntax(dst, src);
break;
+ case SNMP_SYNTAX_IP6ADDRESS:
+ add_ip6_syntax(dst, src);
+ break;
case SNMP_SYNTAX_OCTETSTRING:
add_octstring_syntax(dst, src);
break;
Modified: soc2014/shonali/head/usr.sbin/bsnmpd/tools/libbsnmptools/bsnmptools.c
==============================================================================
--- soc2014/shonali/head/usr.sbin/bsnmpd/tools/libbsnmptools/bsnmptools.c Sun Aug 10 17:08:28 2014 (r272174)
+++ soc2014/shonali/head/usr.sbin/bsnmpd/tools/libbsnmptools/bsnmptools.c Sun Aug 10 18:51:05 2014 (r272175)
@@ -1246,6 +1246,8 @@
&(object->val.var)));
case SNMP_SYNTAX_IPADDRESS:
return (snmp_ip2asn_oid(ptr, &(object->val.var)));
+ case SNMP_SYNTAX_IP6ADDRESS:
+ return (snmp_ipv62asn_oid(ptr, &(object->val.var)));
case SNMP_SYNTAX_COUNTER:
/* FALLTHROUGH */
case SNMP_SYNTAX_GAUGE:
@@ -1849,6 +1851,10 @@
case SNMP_SYNTAX_IPADDRESS:
snmp_output_ipaddress(snmptoolctx, val->v.ipaddress);
break;
+
+ case SNMP_SYNTAX_IP6ADDRESS:
+ snmp_output_ip6address(snmptoolctx, val->v.ipaddress6);
+ break;
case SNMP_SYNTAX_COUNTER:
snmp_output_counter(snmptoolctx, val->v.uint32);
@@ -1926,6 +1932,7 @@
snmp_output_index(struct snmp_toolinfo *snmptoolctx, struct index *stx,
struct asn_oid *oid)
{
+ uint8_t *ip;
uint32_t bytes = 1;
uint64_t cnt64;
struct asn_oid temp, out;
@@ -1963,25 +1970,22 @@
case SNMP_SYNTAX_IPADDRESS:
if (temp.len < 4)
return (-1);
- uint8_t *ip;
- switch (temp.len) {
- case 4:
- ip = malloc(sizeof(u_int8_t)*4);
- for (bytes = 0; bytes < 4; bytes++)
- ip[bytes] = temp.subs[bytes];
- snmp_output_ipaddress(snmptoolctx, ip);
- bytes = 4;
- case 16:
- ip = malloc(sizeof(u_int8_t)*16);
- for (bytes = 0; bytes < 16; bytes++)
- ip[bytes] = temp.subs[bytes];
- snmp_output_ipaddress(snmptoolctx, ip);
- bytes = 16;
-
- default:
- return (NULL);
- }
- break;
+ ip = malloc(sizeof(u_int8_t)*SNMP_IPv4_ADDR_SIZ);
+ for (bytes = 0; bytes < 4; bytes++)
+ ip[bytes] = temp.subs[bytes];
+ snmp_output_ipaddress(snmptoolctx, ip);
+ bytes = 4;
+ break;
+
+ case SNMP_SYNTAX_IP6ADDRESS:
+ if (temp.len < 16)
+ return (-1);
+ ip = malloc(sizeof(u_int8_t)*SNMP_IPv6_ADDR_SIZ);
+ for (bytes = 0; bytes < 16; bytes++)
+ ip[bytes] = temp.subs[bytes];
+ snmp_output_ip6address(snmptoolctx, ip);
+ bytes = 16;
+ break;
case SNMP_SYNTAX_COUNTER:
snmp_output_counter(snmptoolctx, temp.subs[0]);
More information about the svn-soc-all
mailing list