Added function for sending an UDP packet to a specified IP address and port number over an existing UDP connection
This commit is contained in:
parent
e14a30262c
commit
fb037e0afb
2 changed files with 26 additions and 2 deletions
|
@ -28,7 +28,7 @@
|
|||
*
|
||||
* This file is part of the Contiki operating system.
|
||||
*
|
||||
* $Id: uip-udp-packet.c,v 1.6 2008/10/14 13:39:12 julienabeille Exp $
|
||||
* $Id: uip-udp-packet.c,v 1.7 2009/10/18 22:02:01 adamdunkels Exp $
|
||||
*/
|
||||
|
||||
/**
|
||||
|
@ -67,3 +67,25 @@ uip_udp_packet_send(struct uip_udp_conn *c, const void *data, int len)
|
|||
#endif /* UIP_UDP */
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
uip_udp_packet_sendto(struct uip_udp_conn *c, const void *data, int len,
|
||||
const uip_ipaddr_t *toaddr, uint16_t toport)
|
||||
{
|
||||
uip_ipaddr_t curaddr;
|
||||
uint16_t curport;
|
||||
|
||||
/* Save current IP addr/port. */
|
||||
uip_ipaddr_copy(&curaddr, &c->ripaddr);
|
||||
curport = c->rport;
|
||||
|
||||
/* Load new IP addr/port */
|
||||
uip_ipaddr_copy(&c->ripaddr, toaddr);
|
||||
c->rport = toport;
|
||||
|
||||
uip_udp_packet_send(c, data, len);
|
||||
|
||||
/* Restore old IP addr/port */
|
||||
uip_ipaddr_copy(&c->ripaddr, &curaddr);
|
||||
c->rport = curport;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
*
|
||||
* This file is part of the Contiki operating system.
|
||||
*
|
||||
* $Id: uip-udp-packet.h,v 1.2 2007/04/30 15:19:53 bg- Exp $
|
||||
* $Id: uip-udp-packet.h,v 1.3 2009/10/18 22:02:01 adamdunkels Exp $
|
||||
*/
|
||||
|
||||
/**
|
||||
|
@ -44,5 +44,7 @@
|
|||
#include "net/uip.h"
|
||||
|
||||
void uip_udp_packet_send(struct uip_udp_conn *c, const void *data, int len);
|
||||
void uip_udp_packet_sendto(struct uip_udp_conn *c, const void *data, int len,
|
||||
const uip_ipaddr_t *toaddr, uint16_t toport);
|
||||
|
||||
#endif /* __UIP_UDP_PACKET_H__ */
|
||||
|
|
Loading…
Reference in a new issue