From beb3d5d8211799231a3f6d95091543b56ec46199 Mon Sep 17 00:00:00 2001 From: Richard Cochran Date: Thu, 5 Apr 2012 17:15:32 +0200 Subject: [PATCH] Expand the transport layer interface with a peer transmission method. Signed-off-by: Richard Cochran --- raw.c | 2 +- transport.c | 8 +++++++- transport.h | 3 +++ transport_private.h | 2 +- udp.c | 2 +- 5 files changed, 13 insertions(+), 4 deletions(-) diff --git a/raw.c b/raw.c index f9a9cc3..7c492db 100644 --- a/raw.c +++ b/raw.c @@ -210,7 +210,7 @@ static int raw_recv(struct transport *t, int fd, void *buf, int buflen, return sk_receive(fd, ptr, buflen, hwts, 0); } -static int raw_send(struct transport *t, struct fdarray *fda, int event, +static int raw_send(struct transport *t, struct fdarray *fda, int event, int peer, void *buf, int len, struct hw_timestamp *hwts) { struct raw *raw = container_of(t, struct raw, t); diff --git a/transport.c b/transport.c index be7663f..2d71e25 100644 --- a/transport.c +++ b/transport.c @@ -42,7 +42,13 @@ int transport_recv(struct transport *t, int fd, int transport_send(struct transport *t, struct fdarray *fda, int event, void *buf, int buflen, struct hw_timestamp *hwts) { - return t->send(t, fda, event, buf, buflen, hwts); + return t->send(t, fda, event, 0, buf, buflen, hwts); +} + +int transport_peer(struct transport *t, struct fdarray *fda, int event, + void *buf, int buflen, struct hw_timestamp *hwts) +{ + return t->send(t, fda, event, 1, buf, buflen, hwts); } struct transport *transport_create(enum transport_type type) diff --git a/transport.h b/transport.h index 2a9bda6..6a50816 100644 --- a/transport.h +++ b/transport.h @@ -57,6 +57,9 @@ int transport_recv(struct transport *t, int fd, int transport_send(struct transport *t, struct fdarray *fda, int event, void *buf, int buflen, struct hw_timestamp *hwts); +int transport_peer(struct transport *t, struct fdarray *fda, int event, + void *buf, int buflen, struct hw_timestamp *hwts); + /** * Allocate an instance of the specified transport. * @param type Which transport to obtain. diff --git a/transport_private.h b/transport_private.h index 0791c1d..255035d 100644 --- a/transport_private.h +++ b/transport_private.h @@ -34,7 +34,7 @@ struct transport { int (*recv)(struct transport *t, int fd, void *buf, int buflen, struct hw_timestamp *hwts); - int (*send)(struct transport *t, struct fdarray *fda, int event, + int (*send)(struct transport *t, struct fdarray *fda, int event, int peer, void *buf, int buflen, struct hw_timestamp *hwts); void (*release)(struct transport *t); diff --git a/udp.c b/udp.c index 07c6b33..c8e35ee 100644 --- a/udp.c +++ b/udp.c @@ -165,7 +165,7 @@ static int udp_recv(struct transport *t, int fd, void *buf, int buflen, return sk_receive(fd, buf, buflen, hwts, 0); } -static int udp_send(struct transport *t, struct fdarray *fda, int event, +static int udp_send(struct transport *t, struct fdarray *fda, int event, int peer, void *buf, int len, struct hw_timestamp *hwts) { ssize_t cnt;