socsvn commit: r271786 - soc2014/shonali/head/usr.sbin/bsnmpd/tools/bsnmptools
shonali at FreeBSD.org
shonali at FreeBSD.org
Sun Aug 3 10:47:40 UTC 2014
Author: shonali
Date: Sun Aug 3 10:47:38 2014
New Revision: 271786
URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=271786
Log:
Added separate ipv6 function for parse_ip & add_ip_syntax in bsnmpget.c
Modified:
soc2014/shonali/head/usr.sbin/bsnmpd/tools/bsnmptools/bsnmpget.c
Modified: soc2014/shonali/head/usr.sbin/bsnmpd/tools/bsnmptools/bsnmpget.c
==============================================================================
--- soc2014/shonali/head/usr.sbin/bsnmpd/tools/bsnmptools/bsnmpget.c Sun Aug 3 09:53:34 2014 (r271785)
+++ soc2014/shonali/head/usr.sbin/bsnmpd/tools/bsnmptools/bsnmpget.c Sun Aug 3 10:47:38 2014 (r271786)
@@ -603,40 +603,42 @@
static int32_t
parse_ip(struct snmp_value * value, char * val)
{
- uint32_t v;
- int32_t i;
- char *endptr, *str;
-
- str = val;
-
- switch (sizeof(*addrs)) {
-
- case 4:
- for (i = 0; i < 4; i++) {
- v = strtoul(str, &endptr, 10);
- if (v > 0xff)
- return (-1);
- if (*endptr != '.' && *endptr != '\0' && i != 3)
- break;
- str = endptr + 1;
- value->v.ipaddress[i] = (uint8_t) v;
- }
- case 16:
- for (i = 0; i < 16; i++) {
- v = strtoul(str, &endptr, 16);
- if (v > 0xff)
- return (-1);
- if (*endptr != ':' && *endptr != '\0' && i != 15)
- break;
- str = endptr + 1;
- value->v.ipaddress[i] = (uint8_t) v;
- }
-
- default:
- return (NULL);
- }
- value->syntax = SNMP_SYNTAX_IPADDRESS;
- return (0);
+ uint32_t v;
+ int32_t i;
+ char *endptr, *str;
+
+ str = val;
+ for (i = 0; i < 4; i++) {
+ v = strtoul(str, &endptr, 10);
+ if (v > 0xff)
+ return (-1);
+ if (*endptr != '.' && *endptr != '\0' && i != 3)
+ break;
+ str = endptr + 1;
+ value->v.ipaddress[i] = (uint8_t) v;
+ }
+ value->syntax = SNMP_SYNTAX_IPADDRESS;
+ return (0);
+}
+
+static int32_t
+parse_ip6(struct snmp_value * value, char * val)
+{
+ uint32_t v;
+ int32_t i;
+ char *endptr, *str;
+
+ str = val;
+ for (i = 0; i < 16; i++) {
+ v = strtoul(str, &endptr, 16);
+ if (*endptr != ':' && *endptr != '\0' && i != 15)
+ break;
+ str = endptr + 1;
+ value->v.ipaddress6[i] = (uint8_t) v;
+ }
+
+ value->syntax = SNMP_SYNTAX_IPADDRESS;
+ return (0);
}
static int32_t
@@ -960,25 +962,30 @@
static int32_t
add_ip_syntax(struct snmp_value *dst, struct snmp_value *src)
{
- int8_t i;
+ int8_t i;
- dst->syntax = SNMP_SYNTAX_IPADDRESS;
-
- switch (sizeof(src->v.ipaddress)) {
-
- case 4:
- for (i = 0; i < 4; i++)
- dst->v.ipaddress[i] = src->v.ipaddress[i];
- case 16:
- for (i = 0; i < 16; i++)
- dst->v.ipaddress[i] = src->v.ipaddress[i];
- default:
- return (NULL);
- }
- return (1);
+ dst->syntax = SNMP_SYNTAX_IPADDRESS;
+
+ for (i = 0; i < 4; i++)
+ dst->v.ipaddress[i] = src->v.ipaddress[i];
+
+ return (1);
}
static int32_t
+add_ip6_syntax(struct snmp_value *dst, struct snmp_value *src)
+{
+ int8_t i;
+
+ dst->syntax = src->syntax;
+
+ for (i = 0; i < 16; i++)
+ dst->v.ipaddress6[i] = src->v.ipaddress6[i];
+
+ return (1);
+}
+
+static int32_t
add_octstring_syntax(struct snmp_value *dst, struct snmp_value *src)
{
if (src->v.octetstring.len > ASN_MAXOCTETSTRING) {
More information about the svn-soc-all
mailing list