Deleted Added
sdiff udiff text old ( 155506 ) new ( 155602 )
full compact
1/*
2 * Copyright (c) 2001-2003
3 * Fraunhofer Institute for Open Communication Systems (FhG Fokus).
4 * All rights reserved.
5 *
6 * Author: Harti Brandt <harti@freebsd.org>
7 *
8 * Redistribution and use in source and binary forms, with or without

--- 91 unchanged lines hidden (view full) ---

100uint64_t mibarpticks;
101
102/* info on system clocks */
103struct clockinfo clockinfo;
104
105/* list of all New if registrations */
106static struct newifreg_list newifreg_list = TAILQ_HEAD_INITIALIZER(newifreg_list);
107
108/*****************************/
109
110static const struct asn_oid oid_ifMIB = OIDX_ifMIB;
111static const struct asn_oid oid_ipMIB = OIDX_ipMIB;
112static const struct asn_oid oid_tcpMIB = OIDX_tcpMIB;
113static const struct asn_oid oid_udpMIB = OIDX_udpMIB;
114static const struct asn_oid oid_ipForward = OIDX_ipForward;
115static const struct asn_oid oid_linkDown = OIDX_linkDown;

--- 159 unchanged lines hidden (view full) ---

275 ifindex.var.subs[ifindex.var.len++] = ifp->index;
276 ifindex.syntax = SNMP_SYNTAX_INTEGER;
277 ifindex.v.integer = ifp->index;
278
279 snmp_send_trap(up ? &oid_linkUp : &oid_linkDown, &ifindex,
280 (struct snmp_value *)NULL);
281}
282
283/*
284 * Fetch new MIB data.
285 */
286int
287mib_fetch_ifmib(struct mibif *ifp)
288{
289 int name[6];
290 size_t len;
291 void *newmib;
292 struct ifmibdata oldmib = ifp->mib;
293
294 name[0] = CTL_NET;
295 name[1] = PF_LINK;
296 name[2] = NETLINK_GENERIC;
297 name[3] = IFMIB_IFDATA;
298 name[4] = ifp->sysindex;
299 name[5] = IFDATA_GENERAL;
300
301 len = sizeof(ifp->mib);
302 if (sysctl(name, 6, &ifp->mib, &len, NULL, 0) == -1) {
303 if (errno != ENOENT)
304 syslog(LOG_WARNING, "sysctl(ifmib, %s) failed %m",
305 ifp->name);
306 return (-1);
307 }
308
309 /*
310 * Quoting RFC2863, 3.1.15: "... LinkUp and linkDown traps are
311 * generated just after ifOperStatus leaves, or just before it
312 * enters, the down state, respectively;"
313 */
314 if (ifp->trap_enable && ifp->mib.ifmd_data.ifi_link_state !=
315 oldmib.ifmd_data.ifi_link_state &&
316 (ifp->mib.ifmd_data.ifi_link_state == LINK_STATE_DOWN ||
317 oldmib.ifmd_data.ifi_link_state == LINK_STATE_DOWN))
318 link_trap(ifp, ifp->mib.ifmd_data.ifi_link_state ==
319 LINK_STATE_UP ? 1 : 0);
320
321 ifp->flags &= ~(MIBIF_HIGHSPEED | MIBIF_VERYHIGHSPEED);
322 if (ifp->mib.ifmd_data.ifi_baudrate > 20000000) {
323 ifp->flags |= MIBIF_HIGHSPEED;
324 if (ifp->mib.ifmd_data.ifi_baudrate > 650000000)
325 ifp->flags |= MIBIF_VERYHIGHSPEED;
326 }
327
328 /*
329 * linkspecific MIB
330 */
331 name[5] = IFDATA_LINKSPECIFIC;
332 if (sysctl(name, 6, NULL, &len, NULL, 0) == -1) {
333 syslog(LOG_WARNING, "sysctl linkmib estimate (%s): %m",
334 ifp->name);
335 if (ifp->specmib != NULL) {
336 ifp->specmib = NULL;
337 ifp->specmiblen = 0;
338 }

--- 175 unchanged lines hidden (view full) ---

514}
515
516/*
517 * Free an interface
518 */
519static void
520mibif_free(struct mibif *ifp)
521{
522 struct mibindexmap *map;
523 struct mibifa *ifa, *ifa1;
524 struct mibrcvaddr *rcv, *rcv1;
525 struct mibarp *at, *at1;
526
527 if (ifp->xnotify != NULL)
528 (*ifp->xnotify)(ifp, MIBIF_NOTIFY_DESTROY, ifp->xnotify_data);
529
530 (void)mib_ifstack_delete(ifp, NULL);
531 (void)mib_ifstack_delete(NULL, ifp);
532
533 TAILQ_REMOVE(&mibif_list, ifp, link);
534 if (ifp->physaddr != NULL)
535 free(ifp->physaddr);
536 if (ifp->specmib != NULL)
537 free(ifp->specmib);
538
539 STAILQ_FOREACH(map, &mibindexmap_list, link)
540 if (map->mibif == ifp) {
541 map->mibif = NULL;

--- 42 unchanged lines hidden (view full) ---

584 struct mibif *ifp;
585 struct mibindexmap *map;
586
587 if ((ifp = malloc(sizeof(*ifp))) == NULL) {
588 syslog(LOG_WARNING, "%s: %m", __func__);
589 return (NULL);
590 }
591 memset(ifp, 0, sizeof(*ifp));
592 ifp->sysindex = sysindex;
593 strcpy(ifp->name, name);
594 strcpy(ifp->descr, name);
595 ifp->spec_oid = oid_zeroDotZero;
596
597 map = NULL;
598 if (!mib_if_is_dyn(ifp->name)) {
599 /* non-dynamic. look whether we know the interface */

--- 1043 unchanged lines hidden ---