-/* $OpenBSD: packet.c,v 1.1 2016/07/19 16:54:26 reyk Exp $ */
+/* $OpenBSD: packet.c,v 1.2 2016/07/20 20:07:02 reyk Exp $ */
/*
* Copyright (c) 2013-2016 Reyk Floeter <reyk@openbsd.org>
return (0);
}
-long
-packet_input(struct switchd *sc, struct switch_control *sw, long port,
+uint32_t
+packet_input(struct switchd *sc, struct switch_control *sw, uint32_t port,
struct ibuf *ibuf, size_t len, struct packet *pkt)
{
struct ether_header *eh;
else
dst = switch_cached(sw, eh->ether_dhost);
- log_debug("%s: %s -> %s, port %ld -> %ld", __func__,
+ log_debug("%s: %s -> %s, port %u -> %u", __func__,
print_ether(eh->ether_shost),
print_ether(eh->ether_dhost),
src->mac_port,
- dst == NULL ? -1 : dst->mac_port);
+ dst == NULL ? OFP_PORT_ANY : dst->mac_port);
- return (dst == NULL ? -1 : dst->mac_port);
+ return (dst == NULL ? OFP_PORT_ANY : dst->mac_port);
}
-/* $OpenBSD: switch.c,v 1.1 2016/07/19 16:54:26 reyk Exp $ */
+/* $OpenBSD: switch.c,v 1.2 2016/07/20 20:07:02 reyk Exp $ */
/*
* Copyright (c) 2013-2016 Reyk Floeter <reyk@openbsd.org>
struct macaddr *
switch_learn(struct switchd *sc, struct switch_control *sw,
- uint8_t *ea, long port)
+ uint8_t *ea, uint32_t port)
{
struct macaddr *mac, *oldmac = NULL;
struct timeval tv;
mac->mac_port = port;
mac->mac_age = tv.tv_sec;
- log_debug("%s: %s mac %s on switch %u port %ld",
+ log_debug("%s: %s mac %s on switch %u port %u",
__func__, oldmac == NULL ? "learned new" : "updated",
print_ether(ea), sw->sw_id, port);
-/* $OpenBSD: switchd.h,v 1.3 2016/07/20 14:15:08 reyk Exp $ */
+/* $OpenBSD: switchd.h,v 1.4 2016/07/20 20:07:02 reyk Exp $ */
/*
* Copyright (c) 2013-2016 Reyk Floeter <reyk@openbsd.org>
struct macaddr {
uint8_t mac_addr[ETHER_ADDR_LEN];
- long mac_port;
+ uint32_t mac_port;
time_t mac_age;
RB_ENTRY(macaddr) mac_entry;
};
int switchd_open_device(struct privsep *, const char *, size_t);
/* packet.c */
-long packet_input(struct switchd *, struct switch_control *, long,
- struct ibuf *, size_t, struct packet *);
+uint32_t packet_input(struct switchd *, struct switch_control *,
+ uint32_t, struct ibuf *, size_t, struct packet *);
/* switch.c */
void switch_init(struct switchd *);
struct switch_control
*switch_get(struct switch_connection *);
struct macaddr *switch_learn(struct switchd *, struct switch_control *,
- uint8_t *, long);
+ uint8_t *, uint32_t);
struct macaddr *switch_cached(struct switch_control *, uint8_t *);
RB_PROTOTYPE(switch_head, switch_control, sw_entry, switch_cmp);
RB_PROTOTYPE(macaddr_head, macaddr, mac_entry, switch_maccmp);