Implement port_forward_to

Signed-off-by: Jiri Benc <jbenc@redhat.com>
master
Jiri Benc 2014-05-02 12:37:47 +02:00 committed by Richard Cochran
parent d6e4173e19
commit d0a67e8b1a
2 changed files with 15 additions and 0 deletions

7
port.c
View File

@ -2170,6 +2170,13 @@ int port_forward(struct port *p, struct ptp_message *msg)
return cnt <= 0 ? -1 : 0;
}
int port_forward_to(struct port *p, struct ptp_message *msg)
{
int cnt;
cnt = transport_sendto(p->trp, &p->fda, 0, msg);
return cnt <= 0 ? -1 : 0;
}
int port_prepare_and_send(struct port *p, struct ptp_message *msg, int event)
{
int cnt;

8
port.h
View File

@ -91,6 +91,14 @@ enum fsm_event port_event(struct port *port, int fd_index);
*/
int port_forward(struct port *p, struct ptp_message *msg);
/**
* Forward a message on a given port to the address stored in the message.
* @param port A pointer previously obtained via port_open().
* @param msg The message to send. Must be in network byte order.
* @return Zero on success, non-zero otherwise.
*/
int port_forward_to(struct port *p, struct ptp_message *msg);
/**
* Prepare message for transmission and send it to a given port. Note that
* a single message cannot be sent several times using this function, that