mirror of
https://github.com/lwip-tcpip/lwip.git
synced 2024-10-05 22:29:49 +00:00
Fixes so that UDP connect() works.Enable generation of ICMP destination unreachable when the port is unavailable
This commit is contained in:
parent
46c575c038
commit
721d237120
@ -272,6 +272,7 @@ lwip_recvfrom(int s, void *mem, int len, unsigned int flags,
|
||||
port = netbuf_fromport(buf);
|
||||
((struct sockaddr_in *)from)->sin_addr.s_addr = addr->addr;
|
||||
((struct sockaddr_in *)from)->sin_port = port;
|
||||
((struct sockaddr_in *)from)->sin_family = AF_INET;
|
||||
*fromlen = sizeof(struct sockaddr_in);
|
||||
}
|
||||
|
||||
@ -358,7 +359,7 @@ lwip_sendto(int s, void *data, int size, unsigned int flags,
|
||||
|
||||
remote_addr.addr = ((struct sockaddr_in *)to)->sin_addr.s_addr;
|
||||
remote_port = ((struct sockaddr_in *)to)->sin_port;
|
||||
netconn_connect(sock->conn, &remote_addr, remote_port);
|
||||
netconn_connect(sock->conn, &remote_addr, ntohs(remote_port));
|
||||
|
||||
ret = lwip_send(s, data, size, flags);
|
||||
|
||||
|
@ -28,7 +28,7 @@
|
||||
*
|
||||
* Author: Adam Dunkels <adam@sics.se>
|
||||
*
|
||||
* $Id: udp.c,v 1.11 2003/01/22 16:18:05 jani Exp $
|
||||
* $Id: udp.c,v 1.12 2003/01/23 16:46:01 jani Exp $
|
||||
*/
|
||||
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
@ -217,9 +217,8 @@ udp_input(struct pbuf *p, struct netif *inp)
|
||||
|
||||
|
||||
/* Check checksum if this is a match or if it was directed at us. */
|
||||
/* if(pcb != NULL ||
|
||||
ip_addr_cmp(&inp->ip_addr, &iphdr->dest)) {*/
|
||||
if(pcb != NULL) {
|
||||
if(pcb != NULL || ip_addr_cmp(&inp->ip_addr, &iphdr->dest))
|
||||
{
|
||||
DEBUGF(UDP_DEBUG, ("udp_input: calculating checksum\n"));
|
||||
pbuf_header(p, UDP_HLEN);
|
||||
#ifdef IPv6
|
||||
@ -266,7 +265,7 @@ udp_input(struct pbuf *p, struct netif *inp)
|
||||
#if LWIP_SNMP > 0
|
||||
snmp_inc_udpindatagrams();
|
||||
#endif
|
||||
pcb->recv(pcb->recv_arg, pcb, p, &(iphdr->src), src);
|
||||
pcb->recv(pcb->recv_arg, pcb, p, &(iphdr->src), udphdr->src);
|
||||
} else {
|
||||
DEBUGF(UDP_DEBUG, ("udp_input: not for us.\n"));
|
||||
|
||||
@ -276,10 +275,6 @@ udp_input(struct pbuf *p, struct netif *inp)
|
||||
if(!ip_addr_isbroadcast(&iphdr->dest, &inp->netmask) &&
|
||||
!ip_addr_ismulticast(&iphdr->dest)) {
|
||||
|
||||
/* deconvert from host to network byte order */
|
||||
udphdr->src = htons(udphdr->src);
|
||||
udphdr->dest = htons(udphdr->dest);
|
||||
|
||||
/* adjust pbuf pointer */
|
||||
p->payload = iphdr;
|
||||
icmp_dest_unreach(p, ICMP_DUR_PORT);
|
||||
|
Loading…
Reference in New Issue
Block a user