along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- $Id: route.c,v 1.1.2.53 2003/07/06 17:49:49 guus Exp $
+ $Id: route.c,v 1.1.2.54 2003/07/06 22:11:33 guus Exp $
*/
#include "config.h"
#include <netinet/if_ether.h>
#include <utils.h>
#include <xalloc.h>
-#include <syslog.h>
#include <string.h>
#ifdef HAVE_INTTYPES_H
#include <inttypes.h>
#include "route.h"
#include "protocol.h"
#include "device.h"
+#include "logger.h"
#include "system.h"
/* If we don't know this MAC address yet, store it */
if(!subnet || subnet->owner != myself) {
- if(debug_lvl >= DEBUG_TRAFFIC)
- syslog(LOG_INFO, _("Learned new MAC address %hx:%hx:%hx:%hx:%hx:%hx"),
+ logger(DEBUG_TRAFFIC, LOG_INFO, _("Learned new MAC address %hx:%hx:%hx:%hx:%hx:%hx"),
address->x[0], address->x[1], address->x[2], address->x[3],
address->x[4], address->x[5]);
next = node->next;
s = (subnet_t *) node->data;
if(s->type == SUBNET_MAC && s->net.mac.lastseen && s->net.mac.lastseen + macexpire < now) {
- if(debug_lvl >= DEBUG_TRAFFIC)
- syslog(LOG_INFO, _("MAC address %hx:%hx:%hx:%hx:%hx:%hx expired"),
+ logger(DEBUG_TRAFFIC, LOG_INFO, _("MAC address %hx:%hx:%hx:%hx:%hx:%hx expired"),
s->net.mac.address.x[0], s->net.mac.address.x[1],
s->net.mac.address.x[2], s->net.mac.address.x[3],
s->net.mac.address.x[4], s->net.mac.address.x[5]);
subnet = lookup_subnet_ipv4((ipv4_t *) & packet->data[30]);
if(!subnet) {
- if(debug_lvl >= DEBUG_TRAFFIC) {
- syslog(LOG_WARNING, _("Cannot route packet: unknown IPv4 destination address %d.%d.%d.%d"),
+ logger(DEBUG_TRAFFIC, LOG_WARNING, _("Cannot route packet: unknown IPv4 destination address %d.%d.%d.%d"),
packet->data[30], packet->data[31], packet->data[32],
packet->data[33]);
- }
route_ipv4_unreachable(packet, ICMP_NET_UNKNOWN);
return NULL;
subnet = lookup_subnet_ipv6((ipv6_t *) & packet->data[38]);
if(!subnet) {
- if(debug_lvl >= DEBUG_TRAFFIC) {
- syslog(LOG_WARNING, _("Cannot route packet: unknown IPv6 destination address %hx:%hx:%hx:%hx:%hx:%hx:%hx:%hx"),
+ logger(DEBUG_TRAFFIC, LOG_WARNING, _("Cannot route packet: unknown IPv6 destination address %hx:%hx:%hx:%hx:%hx:%hx:%hx:%hx"),
ntohs(*(uint16_t *) & packet->data[38]),
ntohs(*(uint16_t *) & packet->data[40]),
ntohs(*(uint16_t *) & packet->data[42]),
ntohs(*(uint16_t *) & packet->data[48]),
ntohs(*(uint16_t *) & packet->data[50]),
ntohs(*(uint16_t *) & packet->data[52]));
- }
#ifdef HAVE_NETINET_IP6_H
route_ipv6_unreachable(packet, ICMP6_DST_UNREACH_ADDR);
#endif
if(ns->nd_ns_hdr.icmp6_type != ND_NEIGHBOR_SOLICIT ||
opt->nd_opt_type != ND_OPT_SOURCE_LINKADDR) {
- if(debug_lvl > DEBUG_TRAFFIC) {
- syslog(LOG_WARNING, _("Cannot route packet: received unknown type neighbor solicitation request"));
- }
+ logger(DEBUG_TRAFFIC, LOG_WARNING, _("Cannot route packet: received unknown type neighbor solicitation request"));
return;
}
checksum = inet_checksum(ns, sizeof(*ns) + 8, checksum);
if(checksum) {
- if(debug_lvl >= DEBUG_TRAFFIC)
- syslog(LOG_WARNING, _("Cannot route packet: checksum error for neighbor solicitation request"));
+ logger(DEBUG_TRAFFIC, LOG_WARNING, _("Cannot route packet: checksum error for neighbor solicitation request"));
return;
}
subnet = lookup_subnet_ipv6((ipv6_t *) & ns->nd_ns_target);
if(!subnet) {
- if(debug_lvl >= DEBUG_TRAFFIC) {
- syslog(LOG_WARNING, _("Cannot route packet: neighbor solicitation request for unknown address %hx:%hx:%hx:%hx:%hx:%hx:%hx:%hx"),
+ logger(DEBUG_TRAFFIC, LOG_WARNING, _("Cannot route packet: neighbor solicitation request for unknown address %hx:%hx:%hx:%hx:%hx:%hx:%hx:%hx"),
ntohs(((uint16_t *) & ns->nd_ns_target)[0]),
ntohs(((uint16_t *) & ns->nd_ns_target)[1]),
ntohs(((uint16_t *) & ns->nd_ns_target)[2]),
ntohs(((uint16_t *) & ns->nd_ns_target)[5]),
ntohs(((uint16_t *) & ns->nd_ns_target)[6]),
ntohs(((uint16_t *) & ns->nd_ns_target)[7]));
- }
return;
}
if(ntohs(arp->arp_hrd) != ARPHRD_ETHER || ntohs(arp->arp_pro) != ETHERTYPE_IP ||
arp->arp_hln != ETHER_ADDR_LEN || arp->arp_pln != 4 || ntohs(arp->arp_op) != ARPOP_REQUEST) {
- if(debug_lvl > DEBUG_TRAFFIC) {
- syslog(LOG_WARNING, _("Cannot route packet: received unknown type ARP request"));
- }
+ logger(DEBUG_TRAFFIC, LOG_WARNING, _("Cannot route packet: received unknown type ARP request"));
return;
}
subnet = lookup_subnet_ipv4((ipv4_t *) arp->arp_tpa);
if(!subnet) {
- if(debug_lvl >= DEBUG_TRAFFIC) {
- syslog(LOG_WARNING, _("Cannot route packet: ARP request for unknown address %d.%d.%d.%d"),
+ logger(DEBUG_TRAFFIC, LOG_WARNING, _("Cannot route packet: ARP request for unknown address %d.%d.%d.%d"),
arp->arp_tpa[0], arp->arp_tpa[1], arp->arp_tpa[2],
arp->arp_tpa[3]);
- }
-
return;
}
return;
default:
- if(debug_lvl >= DEBUG_TRAFFIC)
- syslog(LOG_WARNING, _("Cannot route packet: unknown type %hx"), type);
+ logger(DEBUG_TRAFFIC, LOG_WARNING, _("Cannot route packet: unknown type %hx"), type);
return;
}
if(n)