Socket based TCP/UDP network stack (XSOCKETS)

XCore Project reviews, ideas, videos and proposals.
User avatar
colinbroad
Junior Member
Posts: 7
Joined: Wed Nov 21, 2012 6:16 pm

Post by colinbroad »

Hello Benoit
Thanks for your helpful reply, the extra information on multicast confirms my understanding of broadcast addresses.

Can you let me have the patch for uIP, although I am new to C and ip I have written assembler for the 30+ years. I will take a shot at it!

Thanks again

Colin



User avatar
BEBDigitalAudio
Experienced Member
Posts: 82
Joined: Thu Nov 11, 2010 7:45 pm

Post by BEBDigitalAudio »

Hi Colin,

here is the patch you have to add into uIP to make it receive correctly any limited broadcast UDP packet:

Add this to uip.c

void uip_setlimitedbroadcast (void)
{
uip_ipaddr_t newmask;

uip_limbcastaddr[0]=uip_hostaddr[0]&uip_netmask[0];
uip_limbcastaddr[1]=uip_hostaddr[1]&uip_netmask[1];

newmask[0]=~uip_netmask[0];
newmask[1]=~uip_netmask[1];

uip_limbcastaddr[0]|=newmask[0];
uip_limbcastaddr[1]|=newmask[1];
} // uip_setlimitedbrodcast
// -------------------------------------------------------------

You have to call this function to initialize the specific mask in uIP

In uip.c, in function uip_process, replace this line
if(!uip_ipaddr_cmp(BUF->destipaddr, uip_hostaddr) && !igmp_check_addr(BUF->destipaddr))


by this line

if (!uip_ipaddr_cmp(BUF->destipaddr, uip_hostaddr) &&
(!igmp_check_addr(BUF->destipaddr)) &&
(!uip_ipaddr_cmp(BUF->destipaddr, uip_limbcastaddr)))

and it's done, uIP will now process correctly any limited broadcast it receives °-)

Hope it helps!

Benoit
User avatar
colinbroad
Junior Member
Posts: 7
Joined: Wed Nov 21, 2012 6:16 pm

Post by colinbroad »

Thanks Benoit
I received your post after a day of looking at the code to work out a solution. Your input certainly helped. Here is the routine that I used.


static uip_ipaddr_t subnetaddr = { 0xffff, 0xffff };

void uip_setsubnetaddr(void)
{
uip_ipaddr_t newmask;

newmask[0]=~uip_netmask[0];
newmask[1]=~uip_netmask[1];

subnetaddr[0]=uip_hostaddr[0]|newmask[0];
subnetaddr[1]=uip_hostaddr[1]|newmask[1];
printstr("Subnet Mask ");
printint(subnetaddr[0]);
printintln(subnetaddr[1]);
}

To initialize subnetaddr I called 'uip_setsubnetaddr' after ever call to
'uip_setnetmask';

To implement I looked for every time that 'all_ones_addr' is used and added a test for 'subnetaddr'

Thanks for your help and support

Colin

Post Reply