Implement transport_sendto

Also, document transport_send, transport_peer and transport_sendto usage.

Signed-off-by: Jiri Benc <jbenc@redhat.com>
master
Jiri Benc 2014-04-22 16:01:00 +02:00 committed by Richard Cochran
parent e804e6f9a0
commit 4df924b253
2 changed files with 41 additions and 0 deletions

View File

@ -58,6 +58,14 @@ int transport_peer(struct transport *t, struct fdarray *fda, int event,
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 len = ntohs(msg->header.messageLength);
return t->send(t, fda, event, 0, msg, len, &msg->address, &msg->hwts);
}
int transport_physical_addr(struct transport *t, uint8_t *addr)
{
if (t->physical_addr) {

View File

@ -57,12 +57,45 @@ int transport_open(struct transport *t, const char *name,
int transport_recv(struct transport *t, int fd, struct ptp_message *msg);
/**
* Sends the PTP message using the given transport. The message is sent to
* the default (usually multicast) 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 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);
/**
* Sends the PTP message using the given transport. The message is sent to
* the address used for p2p delay measurements (usually a multicast
* 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 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);
/**
* 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 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);
/**
* Returns the transport's type.
*/