static const size_t icmp6_size = sizeof(struct icmp6_hdr);
static const size_t ns_size = sizeof(struct nd_neighbor_solicit);
static const size_t opt_size = sizeof(struct nd_opt_hdr);
-#define max(a, b) ((a) > (b) ? (a) : (b))
+
+#ifndef MAX
+#define MAX(a, b) ((a) > (b) ? (a) : (b))
+#endif
static struct event age_subnets_event;
memcpy(&packet->data[6], &tmp, sizeof tmp);
}
-static void age_subnets(int fd, short events, void *data) {
+static void age_subnets(void *data) {
subnet_t *s;
connection_t *c;
splay_node_t *node, *next, *node2;
}
}
- if(left)
- event_add(&age_subnets_event, &(struct timeval){10, 0});
+ if(left) {
+ age_subnets_event.time = time(NULL) + 10;
+ event_add(&age_subnets_event);
+ }
}
static void learn_mac(mac_t *address) {
send_add_subnet(c, subnet);
}
- if(!timeout_initialized(&age_subnets_event))
- timeout_set(&age_subnets_event, age_subnets, NULL);
- event_add(&age_subnets_event, &(struct timeval){10, 0});
+ age_subnets_event.handler = age_subnets;
+ age_subnets_event.time = time(NULL) + 10;
+ event_add(&age_subnets_event);
} else {
if(subnet->expires)
subnet->expires = time(NULL) + macexpire;
if(directonly && subnet->owner != via)
return route_ipv4_unreachable(source, packet, ICMP_DEST_UNREACH, ICMP_NET_ANO);
- if(via && packet->len > max(via->mtu, 590) && via != myself) {
+ if(via && packet->len > MAX(via->mtu, 590) && via != myself) {
ifdebug(TRAFFIC) logger(LOG_INFO, "Packet for %s (%s) length %d larger than MTU %d", subnet->owner->name, subnet->owner->hostname, packet->len, via->mtu);
if(packet->data[20] & 0x40) {
- packet->len = max(via->mtu, 590);
+ packet->len = MAX(via->mtu, 590);
route_ipv4_unreachable(source, packet, ICMP_DEST_UNREACH, ICMP_FRAG_NEEDED);
} else {
fragment_ipv4_packet(via, packet);
if(directonly && subnet->owner != via)
return route_ipv6_unreachable(source, packet, ICMP6_DST_UNREACH, ICMP6_DST_UNREACH_ADMIN);
- if(via && packet->len > max(via->mtu, 1294) && via != myself) {
+ if(via && packet->len > MAX(via->mtu, 1294) && via != myself) {
ifdebug(TRAFFIC) logger(LOG_INFO, "Packet for %s (%s) length %d larger than MTU %d", subnet->owner->name, subnet->owner->hostname, packet->len, via->mtu);
- packet->len = max(via->mtu, 1294);
+ packet->len = MAX(via->mtu, 1294);
route_ipv6_unreachable(source, packet, ICMP6_PACKET_TOO_BIG, 0);
return;
}