diff --git a/raw.c b/raw.c index 937f473..8dc50bc 100644 --- a/raw.c +++ b/raw.c @@ -296,9 +296,21 @@ static int raw_send(struct transport *t, struct fdarray *fda, { struct raw *raw = container_of(t, struct raw, t); ssize_t cnt; - int fd = event ? fda->fd[FD_EVENT] : fda->fd[FD_GENERAL]; unsigned char pkt[1600], *ptr = buf; struct eth_hdr *hdr; + int fd = -1; + + switch (event) { + case TRANS_GENERAL: + fd = fda->fd[FD_GENERAL]; + break; + case TRANS_EVENT: + case TRANS_ONESTEP: + case TRANS_P2P1STEP: + case TRANS_DEFER_EVENT: + fd = fda->fd[FD_EVENT]; + break; + } ptr -= sizeof(*hdr); len += sizeof(*hdr); diff --git a/transport.h b/transport.h index 5c8a051..171e59f 100644 --- a/transport.h +++ b/transport.h @@ -50,6 +50,7 @@ enum transport_event { TRANS_EVENT, TRANS_ONESTEP, TRANS_P2P1STEP, + TRANS_DEFER_EVENT, }; struct transport; diff --git a/udp.c b/udp.c index 3ac489e..6ebec3e 100644 --- a/udp.c +++ b/udp.c @@ -219,10 +219,22 @@ static int udp_send(struct transport *t, struct fdarray *fda, enum transport_event event, int peer, void *buf, int len, struct address *addr, struct hw_timestamp *hwts) { - ssize_t cnt; - int fd = event ? fda->fd[FD_EVENT] : fda->fd[FD_GENERAL]; struct address addr_buf; unsigned char junk[1600]; + ssize_t cnt; + int fd = -1; + + switch (event) { + case TRANS_GENERAL: + fd = fda->fd[FD_GENERAL]; + break; + case TRANS_EVENT: + case TRANS_ONESTEP: + case TRANS_P2P1STEP: + case TRANS_DEFER_EVENT: + fd = fda->fd[FD_EVENT]; + break; + } if (!addr) { memset(&addr_buf, 0, sizeof(addr_buf)); diff --git a/udp6.c b/udp6.c index 12213d7..9978844 100644 --- a/udp6.c +++ b/udp6.c @@ -230,10 +230,22 @@ static int udp6_send(struct transport *t, struct fdarray *fda, struct address *addr, struct hw_timestamp *hwts) { struct udp6 *udp6 = container_of(t, struct udp6, t); - ssize_t cnt; - int fd = event ? fda->fd[FD_EVENT] : fda->fd[FD_GENERAL]; struct address addr_buf; unsigned char junk[1600]; + ssize_t cnt; + int fd = -1; + + switch (event) { + case TRANS_GENERAL: + fd = fda->fd[FD_GENERAL]; + break; + case TRANS_EVENT: + case TRANS_ONESTEP: + case TRANS_P2P1STEP: + case TRANS_DEFER_EVENT: + fd = fda->fd[FD_EVENT]; + break; + } if (!addr) { memset(&addr_buf, 0, sizeof(addr_buf));