transport: Use the proper enumerated event code.

Originally the 'event' parameter to transport_send() was a single
Boolean flag.  Over time, we grew an enumerated list of event
flavors, but the function signatures were never updated.  This patch
changes the methods to use the proper type.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
master
Richard Cochran 2018-03-16 23:22:35 -07:00
parent da7bc1db1e
commit 4247eeb104
7 changed files with 30 additions and 30 deletions

6
raw.c
View File

@ -290,9 +290,9 @@ static int raw_recv(struct transport *t, int fd, void *buf, int buflen,
return cnt;
}
static int raw_send(struct transport *t, struct fdarray *fda, int event,
int peer, void *buf, int len, struct address *addr,
struct hw_timestamp *hwts)
static int raw_send(struct transport *t, struct fdarray *fda,
enum transport_event event, int peer, void *buf, int len,
struct address *addr, struct hw_timestamp *hwts)
{
struct raw *raw = container_of(t, struct raw, t);
ssize_t cnt;

View File

@ -42,24 +42,24 @@ int transport_recv(struct transport *t, int fd, struct ptp_message *msg)
return t->recv(t, fd, msg, sizeof(msg->data), &msg->address, &msg->hwts);
}
int transport_send(struct transport *t, struct fdarray *fda, int event,
struct ptp_message *msg)
int transport_send(struct transport *t, struct fdarray *fda,
enum transport_event event, struct ptp_message *msg)
{
int len = ntohs(msg->header.messageLength);
return t->send(t, fda, event, 0, msg, len, NULL, &msg->hwts);
}
int transport_peer(struct transport *t, struct fdarray *fda, int event,
struct ptp_message *msg)
int transport_peer(struct transport *t, struct fdarray *fda,
enum transport_event event, struct ptp_message *msg)
{
int len = ntohs(msg->header.messageLength);
return t->send(t, fda, event, 1, msg, len, NULL, &msg->hwts);
}
int transport_sendto(struct transport *t, struct fdarray *fda, int event,
struct ptp_message *msg)
int transport_sendto(struct transport *t, struct fdarray *fda,
enum transport_event event, struct ptp_message *msg)
{
int len = ntohs(msg->header.messageLength);

View File

@ -67,12 +67,12 @@ int transport_recv(struct transport *t, int fd, struct ptp_message *msg);
* ptp_message itself is ignored.
* @param t The transport.
* @param fda The array of descriptors filled in by transport_open.
* @param event 1 for event message, 0 for general message.
* @param event One of the @ref transport_event enumeration values.
* @param msg The message to send.
* @return Number of bytes send, or negative value in case of an error.
*/
int transport_send(struct transport *t, struct fdarray *fda, int event,
struct ptp_message *msg);
int transport_send(struct transport *t, struct fdarray *fda,
enum transport_event event, struct ptp_message *msg);
/**
* Sends the PTP message using the given transport. The message is sent to
@ -80,25 +80,25 @@ int transport_send(struct transport *t, struct fdarray *fda, int event,
* address), any address field in the ptp_message itself is ignored.
* @param t The transport.
* @param fda The array of descriptors filled in by transport_open.
* @param event 1 for event message, 0 for general message.
* @param event One of the @ref transport_event enumeration values.
* @param msg The message to send.
* @return Number of bytes send, or negative value in case of an error.
*/
int transport_peer(struct transport *t, struct fdarray *fda, int event,
struct ptp_message *msg);
int transport_peer(struct transport *t, struct fdarray *fda,
enum transport_event event, struct ptp_message *msg);
/**
* Sends the PTP message using the given transport. The address has to be
* provided in the address field of the message.
* @param t The transport.
* @param fda The array of descriptors filled in by transport_open.
* @param event 1 for event message, 0 for general message.
* @param event One of the @ref transport_event enumeration values.
* @param msg The message to send. The address of the destination has to
* be set in the address field.
* @return Number of bytes send, or negative value in case of an error.
*/
int transport_sendto(struct transport *t, struct fdarray *fda, int event,
struct ptp_message *msg);
int transport_sendto(struct transport *t, struct fdarray *fda,
enum transport_event event, struct ptp_message *msg);
/**
* Returns the transport's type.

View File

@ -38,9 +38,9 @@ struct transport {
int (*recv)(struct transport *t, int fd, void *buf, int buflen,
struct address *addr, struct hw_timestamp *hwts);
int (*send)(struct transport *t, struct fdarray *fda, int event,
int peer, void *buf, int buflen, struct address *addr,
struct hw_timestamp *hwts);
int (*send)(struct transport *t, struct fdarray *fda,
enum transport_event event, int peer, void *buf, int buflen,
struct address *addr, struct hw_timestamp *hwts);
void (*release)(struct transport *t);

6
udp.c
View File

@ -215,9 +215,9 @@ static int udp_recv(struct transport *t, int fd, void *buf, int buflen,
return sk_receive(fd, buf, buflen, addr, hwts, 0);
}
static int udp_send(struct transport *t, struct fdarray *fda, int event,
int peer, void *buf, int len, struct address *addr,
struct hw_timestamp *hwts)
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];

6
udp6.c
View File

@ -225,9 +225,9 @@ static int udp6_recv(struct transport *t, int fd, void *buf, int buflen,
return sk_receive(fd, buf, buflen, addr, hwts, 0);
}
static int udp6_send(struct transport *t, struct fdarray *fda, int event,
int peer, void *buf, int len, struct address *addr,
struct hw_timestamp *hwts)
static int udp6_send(struct transport *t, struct fdarray *fda,
enum transport_event event, int peer, void *buf, int len,
struct address *addr, struct hw_timestamp *hwts)
{
struct udp6 *udp6 = container_of(t, struct udp6, t);
ssize_t cnt;

6
uds.c
View File

@ -108,9 +108,9 @@ static int uds_recv(struct transport *t, int fd, void *buf, int buflen,
return cnt;
}
static int uds_send(struct transport *t, struct fdarray *fda, int event,
int peer, void *buf, int buflen, struct address *addr,
struct hw_timestamp *hwts)
static int uds_send(struct transport *t, struct fdarray *fda,
enum transport_event event, int peer, void *buf, int buflen,
struct address *addr, struct hw_timestamp *hwts)
{
int cnt, fd = fda->fd[FD_GENERAL];
struct uds *uds = container_of(t, struct uds, t);