mirror of
https://github.com/oliverschmidt/contiki.git
synced 2024-09-09 23:54:32 +00:00
Added a function simple_udp_sendto_port() for sending a UDP packet to a specified port.
This commit is contained in:
parent
5c5545ba7d
commit
f561bfc205
@ -113,6 +113,34 @@ simple_udp_sendto(struct simple_udp_connection *c,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
|
/**
|
||||||
|
* \brief Send a UDP packet to a specified IP address and UDP port
|
||||||
|
* \param c A pointer to a struct simple_udp_connection
|
||||||
|
* \param data A pointer to the data to be sent
|
||||||
|
* \param datalen The length of the data
|
||||||
|
* \param to The IP address of the receiver
|
||||||
|
* \param port The UDP port of the receiver, in host byte order
|
||||||
|
*
|
||||||
|
* This function sends a UDP packet to a specified IP
|
||||||
|
* address and UDP port. The packet will be sent with the
|
||||||
|
* UDP ports that were specified when the connection wa
|
||||||
|
* registered with simple_udp_register().
|
||||||
|
*
|
||||||
|
* \sa simple_udp_sendto()
|
||||||
|
*/
|
||||||
|
int
|
||||||
|
simple_udp_sendto_port(struct simple_udp_connection *c,
|
||||||
|
const void *data, uint16_t datalen,
|
||||||
|
const uip_ipaddr_t *to,
|
||||||
|
uint16_t port)
|
||||||
|
{
|
||||||
|
if(c->udp_conn != NULL) {
|
||||||
|
uip_udp_packet_sendto(c->udp_conn, data, datalen,
|
||||||
|
to, UIP_HTONS(port));
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
/**
|
/**
|
||||||
* \brief Register a UDP connection
|
* \brief Register a UDP connection
|
||||||
* \param c A pointer to a struct simple_udp_connection
|
* \param c A pointer to a struct simple_udp_connection
|
||||||
|
@ -86,6 +86,10 @@ int simple_udp_sendto(struct simple_udp_connection *c,
|
|||||||
const void *data, uint16_t datalen,
|
const void *data, uint16_t datalen,
|
||||||
const uip_ipaddr_t *to);
|
const uip_ipaddr_t *to);
|
||||||
|
|
||||||
|
int simple_udp_sendto_port(struct simple_udp_connection *c,
|
||||||
|
const void *data, uint16_t datalen,
|
||||||
|
const uip_ipaddr_t *to, uint16_t to_port);
|
||||||
|
|
||||||
void simple_udp_init(void);
|
void simple_udp_init(void);
|
||||||
|
|
||||||
#endif /* SIMPLE_UDP_H */
|
#endif /* SIMPLE_UDP_H */
|
||||||
|
Loading…
Reference in New Issue
Block a user