[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lwip-devel] UDP Input with wrong PCB
From: |
Becker, Andreas |
Subject: |
[lwip-devel] UDP Input with wrong PCB |
Date: |
Thu, 18 Aug 2011 11:26:31 +0200 |
Hi folks,
i have an issue with udp_input() IPV4 at the PCB and IP Matching.
I use two netifs with two UDP PCBs. If I receive a broadcast packet on one
Interface, I want to send this to the other Interface, same UDP Ports.
But at the moment I'll receive the packet with the wrong UDP-pcb. Every time
it receives arrives with the same UDP PCB.
For example
Netif1: ip_addr: 192.168.0.1/24
PCB 1: local_ip 192.168.0.1 : 1000
Netif2: ip_addr: 192.168.1.1/24
PCB 2: local_ip 192.168.1.1 : 1000
We receive a Packet from 192.168.1.255:
udp_input(.)
{
broadcast = ip_addr_isbroadcast(ip_current_dest_addr(), inp);
> Yes it is Broadcast.
for (pcb = udp_pcbs; pcb != NULL; pcb = pcb->next) {
local_match = 0;
...
/* compare PCB local addr+port to UDP destination addr+port */
if ((pcb->local_port == dest) &&
> PORT match
... /* IPV 6*/
((
((!broadcast && ipX_addr_isany(0, &pcb->local_ip)) ||
ip_addr_cmp(ipX_2_ip(&pcb->local_ip), ip_current_dest_addr()) ||
#if LWIP_IGMP
ip_addr_ismulticast(ip_current_dest_addr()) ||
#endif /* LWIP_IGMP */
#if IP_SOF_BROADCAST_RECV
(broadcast && (pcb->so_options & SOF_BROADCAST)))))) {
#else /* IP_SOF_BROADCAST_RECV */
(broadcast))))) {
> YES it is Broadcast but will it be PCB1 or PCB2 --> It could be the wrong PCB.
#endif /* IP_SOF_BROADCAST_RECV */
local_match = 1;
...
}
So I suggest, in case of Broadcast, we should match the netif->ip_addr with the
pcb->local_ip:
( /* In Broadcast*/
#if IP_SOF_BROADCAST_RECV
(broadcast && (pcb->so_options & SOF_BROADCAST))
#else /* IP_SOF_BROADCAST_RECV */
(broadcast)
#endif /* IP_SOF_BROADCAST_RECV */
&& ( ip_addr_isany(&pcb->local_ip) || /* don't care IP*/
ip_addr_cmp(&(pcb->local_ip), &(inp->ip_addr)) /* IF Local IP
== PCB Local IP*/
/* In Broadcast*/)
What do You think?
Best Regards,
Andreas.
i.A. Andreas Becker
Entwicklung Embedded
________________________________
SE-Elektronic GmbH
Eythstrasse 16
73037 Göppingen
Deutschland
Fon +49 (7161) 9584-0
Fax +49 (7161) 9584-30
address@hidden
www.se-elektronic.de
Geschäftsführer:
Bogomir Dajcman
Hermann Lippert
Sitz der Gesellschaft: Göppingen
Handelsregister: Amtsgericht Ulm HRB Nr. 531354
- [lwip-devel] UDP Input with wrong PCB,
Becker, Andreas <=