svn commit: r311281 - projects/bsnmp-ipv6-mib/usr.sbin/bsnmpd/modules/snmp_ipv6
Ngie Cooper
ngie at FreeBSD.org
Wed Jan 4 10:03:26 UTC 2017
Author: ngie
Date: Wed Jan 4 10:03:25 2017
New Revision: 311281
URL: https://svnweb.freebsd.org/changeset/base/311281
Log:
Remove util.[ch]; start stubbing in bits from snmp_mibII
Deleted:
projects/bsnmp-ipv6-mib/usr.sbin/bsnmpd/modules/snmp_ipv6/util.c
projects/bsnmp-ipv6-mib/usr.sbin/bsnmpd/modules/snmp_ipv6/util.h
Modified:
projects/bsnmp-ipv6-mib/usr.sbin/bsnmpd/modules/snmp_ipv6/Makefile
projects/bsnmp-ipv6-mib/usr.sbin/bsnmpd/modules/snmp_ipv6/ipv6.c
projects/bsnmp-ipv6-mib/usr.sbin/bsnmpd/modules/snmp_ipv6/ipv6.h
projects/bsnmp-ipv6-mib/usr.sbin/bsnmpd/modules/snmp_ipv6/ipv6_ifTable.c
Modified: projects/bsnmp-ipv6-mib/usr.sbin/bsnmpd/modules/snmp_ipv6/Makefile
==============================================================================
--- projects/bsnmp-ipv6-mib/usr.sbin/bsnmpd/modules/snmp_ipv6/Makefile Wed Jan 4 09:38:08 2017 (r311280)
+++ projects/bsnmp-ipv6-mib/usr.sbin/bsnmpd/modules/snmp_ipv6/Makefile Wed Jan 4 10:03:25 2017 (r311281)
@@ -10,7 +10,6 @@ SRCS+= ipv6_ifStatsTable.c
SRCS+= ipv6_ifTable.c
SRCS+= ipv6_netToMediaTable.c
SRCS+= ipv6_routeTable.c
-SRCS+= util.c
XSYM= ${MOD}
Modified: projects/bsnmp-ipv6-mib/usr.sbin/bsnmpd/modules/snmp_ipv6/ipv6.c
==============================================================================
--- projects/bsnmp-ipv6-mib/usr.sbin/bsnmpd/modules/snmp_ipv6/ipv6.c Wed Jan 4 09:38:08 2017 (r311280)
+++ projects/bsnmp-ipv6-mib/usr.sbin/bsnmpd/modules/snmp_ipv6/ipv6.c Wed Jan 4 10:03:25 2017 (r311281)
@@ -38,75 +38,11 @@ __FBSDID("$FreeBSD$");
static struct lmodule *module;
-struct ipv6_interface_list ipv6_interfaces =
- TAILQ_HEAD_INITIALIZER(ipv6_interfaces);
-
static const struct asn_oid oid_ipv6MIB = OIDX_ipv6MIB;
static u_int ipv6_reg;
int
-load_ipv6_interface_table(void)
-{
- struct ipv6_interface *ip = NULL;
- struct if_nameindex *p = NULL, *ifnames = NULL;
-
- ifnames = if_nameindex();
-
- for (p = ifnames; p != NULL && p->if_index; p++) {
- ip = calloc(1, sizeof(struct ipv6_interface));
- if (ip == NULL) {
- free_ipv6_interface_table();
- if_freenameindex(ifnames);
- return (-1);
- }
-
- ip->index = p->if_index;
-
- if ((ip->name = strdup(p->if_name)) == NULL) {
- free_ipv6_interface_table();
- if_freenameindex(ifnames);
- return (-1);
- }
-
- INSERT_OBJECT_INT(ip, &ipv6_interfaces);
- }
-
- if_freenameindex(ifnames);
-
- return (0);
-}
-
-void
-free_ipv6_interface_table(void)
-{
- struct ipv6_interface *ip;
-
- /*
- * XXX (ngie): TAILQ_FOREACH_SAFE would be better, but using mibII
- * would be the best
- */
- while ((ip = TAILQ_FIRST(&ipv6_interfaces)) != NULL) {
- TAILQ_REMOVE(&ipv6_interfaces, ip, link);
- free(ip->name);
- free(ip);
- ip = NULL;
- }
-}
-
-static int
-if_countifindex(void)
-{
- struct ipv6_interface *ip;
- int count = 0;
-
- TAILQ_FOREACH(ip, &ipv6_interfaces, link) {
- count++;
- }
- return count;
-}
-
-int
op_ipv6MIBObjects(struct snmp_context *ctx __unused, struct snmp_value *value,
u_int sub, u_int iidx __unused, enum snmp_op op)
{
@@ -156,7 +92,7 @@ op_ipv6MIBObjects(struct snmp_context *c
* XXX (ngie): this incorrectly assumes that all interfaces
* are IPv6 enabled.
*/
- value->v.integer = if_countifindex();
+ /*value->v.integer = if_countifindex()*/;
break;
default:
return (SNMP_ERR_NOSUCHNAME);
@@ -167,7 +103,6 @@ op_ipv6MIBObjects(struct snmp_context *c
static void
ipv6MIB_start(void)
{
- load_ipv6_interface_table();
ipv6_reg = or_register(&oid_ipv6MIB,
"The (incomplete) MIB module for RFC 2465.", module);
@@ -184,7 +119,6 @@ ipv6MIB_init(struct lmodule *mod, int ar
static int
ipv6MIB_fini(void)
{
- free_ipv6_interface_table();
or_unregister(ipv6_reg);
Modified: projects/bsnmp-ipv6-mib/usr.sbin/bsnmpd/modules/snmp_ipv6/ipv6.h
==============================================================================
--- projects/bsnmp-ipv6-mib/usr.sbin/bsnmpd/modules/snmp_ipv6/ipv6.h Wed Jan 4 09:38:08 2017 (r311280)
+++ projects/bsnmp-ipv6-mib/usr.sbin/bsnmpd/modules/snmp_ipv6/ipv6.h Wed Jan 4 10:03:25 2017 (r311281)
@@ -52,17 +52,4 @@ __FBSDID("$FreeBSD$");
#include "ipv6MIB_tree.h"
-struct ipv6_interface {
- TAILQ_ENTRY(ipv6_interface) link;
-
- char *name; /* The interface name */
- int index; /* The interface number */
-};
-TAILQ_HEAD(ipv6_interface_list, ipv6_interface);
-
-extern struct ipv6_interface_list ipv6_interfaces;
-
-int load_ipv6_interface_table(void);
-void free_ipv6_interface_table(void);
-
#endif
Modified: projects/bsnmp-ipv6-mib/usr.sbin/bsnmpd/modules/snmp_ipv6/ipv6_ifTable.c
==============================================================================
--- projects/bsnmp-ipv6-mib/usr.sbin/bsnmpd/modules/snmp_ipv6/ipv6_ifTable.c Wed Jan 4 09:38:08 2017 (r311280)
+++ projects/bsnmp-ipv6-mib/usr.sbin/bsnmpd/modules/snmp_ipv6/ipv6_ifTable.c Wed Jan 4 10:03:25 2017 (r311281)
@@ -29,31 +29,38 @@
__FBSDID("$FreeBSD$");
#include <sys/types.h>
+#include <net/if.h>
+#include <net/if_mib.h>
#include <netinet/in.h>
#include <netinet/ip6.h>
+#include <bsnmp/snmpmod.h>
+#include <bsnmp/snmp_mibII.h>
+
#include "ipv6.h"
-#include "util.h"
int
op_ipv6IfTable(struct snmp_context *ctx __unused, struct snmp_value *value,
u_int sub, u_int iidx __unused, enum snmp_op op)
{
- struct ipv6_interface *ip;
asn_subid_t which;
switch (op) {
case SNMP_OP_GETNEXT:
+#if 0
ip = NEXT_OBJECT_INT(&ipv6_interfaces, &value->var, sub);
if (ip == NULL)
return SNMP_ERR_NOSUCHNAME;
value->var.len = sub + 1;
value->var.subs[sub] = ip->index;
+#endif
break;
case SNMP_OP_GET:
+#if 0
ip = FIND_OBJECT_INT(&ipv6_interfaces, &value->var, sub);
if (ip == NULL)
return (SNMP_ERR_NOSUCHNAME);
+#endif
break;
case SNMP_OP_SET:
case SNMP_OP_COMMIT:
@@ -67,7 +74,9 @@ op_ipv6IfTable(struct snmp_context *ctx
switch (which) {
case LEAF_ipv6IfDescr:
+#if 0
string_get(value, ip->name, strlen(ip->name));
+#endif
break;
case LEAF_ipv6IfLowerLayer:
/*
@@ -81,6 +90,7 @@ op_ipv6IfTable(struct snmp_context *ctx
break;
case LEAF_ipv6IfEffectiveMtu:
{
+#if 0
struct ifreq ifr;
int s;
@@ -95,6 +105,7 @@ op_ipv6IfTable(struct snmp_context *ctx
value->v.uint32 = ifr.ifr_mtu;
close(s);
+#endif
break;
}
case LEAF_ipv6IfIdentifier:
@@ -106,62 +117,18 @@ op_ipv6IfTable(struct snmp_context *ctx
break;
case LEAF_ipv6IfPhysicalAddress:
{
- char *c, *tmp = NULL;
- struct ifaddrs *ifap, *ifa;
- struct sockaddr_dl sdl;
-
- if (getifaddrs(&ifap) == -1) {
- string_get(value, "", 0);
- break;
- }
-
- for (ifa = ifap; ifa != NULL; ifa = ifa->ifa_next) {
-
- if (strcmp(ifa->ifa_name, ip->name) != 0)
- continue;
-
- if (ifa->ifa_addr->sa_family != AF_LINK)
- continue;
-
- /*
- * XXX (ngie): the following string manipulation seems
- * really hacky. This should emulate what ifconfig(8)
- * does by opening a socket and throbbing a few ioctls
- * to get the MAC address for an interface.
- */
- memcpy(&sdl, ifa->ifa_addr,
- sizeof(*(ifa->ifa_addr)));
-
- tmp = link_ntoa(&sdl);
-
- /*
- * link_ntoa returns a string with the follow format
- * <interface>:<mac-address-period-separated-octets>,
- * e.g. "em0:0.50.56.30.1.26".
- *
- * We need the MAC address in colon-separated octet
- * format.
- */
- tmp = strchr(tmp, ':');
- if (tmp == NULL)
- break;
- tmp++;
- /* convert the '.' to ':' */
- while ((c = strchr(tmp, '.')) != NULL)
- *c = ':';
- /* now tmp == "0:50:56:30:1:26" */
- break;
- }
+#if 0
+ get_physaddr();
if (tmp == NULL)
string_get(value, "", 0);
else
string_get(value, tmp, strlen(tmp));
-
- freeifaddrs(ifap);
+#endif
break;
}
case LEAF_ipv6IfAdminStatus:
{
+#if 0
struct ifaddrs *ifap, *ifa;
if (getifaddrs(&ifap) == -1) {
@@ -180,10 +147,12 @@ op_ipv6IfTable(struct snmp_context *ctx
break;
}
freeifaddrs(ifap);
+#endif
break;
}
case LEAF_ipv6IfOperStatus:
{
+#if 0
struct ifaddrs *ifap, *ifa;
if (getifaddrs(&ifap) == -1) {
value->v.integer = 4; /* Unknown */
@@ -201,10 +170,12 @@ op_ipv6IfTable(struct snmp_context *ctx
break;
}
freeifaddrs(ifap);
+#endif
break;
}
case LEAF_ipv6IfLastChange:
{
+#if 0
/*
* XXX (ngie): not checking for error code from
* gettimeofday(2).
@@ -223,6 +194,7 @@ op_ipv6IfTable(struct snmp_context *ctx
(uint32_t)((now.tv_sec - lastchange.tv_sec) * 100);
value->v.uint32 +=
(uint32_t)((now.tv_usec - lastchange.tv_usec) / 10000);
+#endif
break;
}
default:
More information about the svn-src-projects
mailing list