Fixes so that UDP connect() works.Enable generation of ICMP destination unreachable when the port is unavailable

This commit is contained in:
jani 2003-01-23 16:46:01 +00:00
parent 46c575c038
commit 721d237120
2 changed files with 6 additions and 10 deletions

View File

@ -272,6 +272,7 @@ lwip_recvfrom(int s, void *mem, int len, unsigned int flags,
port = netbuf_fromport(buf); port = netbuf_fromport(buf);
((struct sockaddr_in *)from)->sin_addr.s_addr = addr->addr; ((struct sockaddr_in *)from)->sin_addr.s_addr = addr->addr;
((struct sockaddr_in *)from)->sin_port = port; ((struct sockaddr_in *)from)->sin_port = port;
((struct sockaddr_in *)from)->sin_family = AF_INET;
*fromlen = sizeof(struct sockaddr_in); *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_addr.addr = ((struct sockaddr_in *)to)->sin_addr.s_addr;
remote_port = ((struct sockaddr_in *)to)->sin_port; 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); ret = lwip_send(s, data, size, flags);

View File

@ -28,7 +28,7 @@
* *
* Author: Adam Dunkels <adam@sics.se> * 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. */ /* Check checksum if this is a match or if it was directed at us. */
/* if(pcb != NULL || if(pcb != NULL || ip_addr_cmp(&inp->ip_addr, &iphdr->dest))
ip_addr_cmp(&inp->ip_addr, &iphdr->dest)) {*/ {
if(pcb != NULL) {
DEBUGF(UDP_DEBUG, ("udp_input: calculating checksum\n")); DEBUGF(UDP_DEBUG, ("udp_input: calculating checksum\n"));
pbuf_header(p, UDP_HLEN); pbuf_header(p, UDP_HLEN);
#ifdef IPv6 #ifdef IPv6
@ -266,7 +265,7 @@ udp_input(struct pbuf *p, struct netif *inp)
#if LWIP_SNMP > 0 #if LWIP_SNMP > 0
snmp_inc_udpindatagrams(); snmp_inc_udpindatagrams();
#endif #endif
pcb->recv(pcb->recv_arg, pcb, p, &(iphdr->src), src); pcb->recv(pcb->recv_arg, pcb, p, &(iphdr->src), udphdr->src);
} else { } else {
DEBUGF(UDP_DEBUG, ("udp_input: not for us.\n")); 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) && if(!ip_addr_isbroadcast(&iphdr->dest, &inp->netmask) &&
!ip_addr_ismulticast(&iphdr->dest)) { !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 */ /* adjust pbuf pointer */
p->payload = iphdr; p->payload = iphdr;
icmp_dest_unreach(p, ICMP_DUR_PORT); icmp_dest_unreach(p, ICMP_DUR_PORT);