* [ECOS] ARP static entry @ 2006-03-25 9:09 Michael Grimard 2006-03-27 8:39 ` Birahim Larou Fall 0 siblings, 1 reply; 5+ messages in thread From: Michael Grimard @ 2006-03-25 9:09 UTC (permalink / raw) To: ecos-discuss Hi, I need to enter some entries in the ARP table to bypass the ARP protocol with the FreeBSD stack. I started by using the code that came with this previous post: http://sourceware.org/ml/ecos-discuss/2005-09/msg00023.html but I cant make it work. Say that I want to link the IP Address 10.10.10.90 to Ethernet Address 00:07:E9:E3:07:A7, what will the parameters be to the call of AddMAC function? Any help/suggestion will be greatly appreciated. Im new to eCos and networking stuff, so Im a little lost here Thanks, Michael P.S.: Je parle français, alors si Sébastien Couret est encore sur la liste, tu peux me faire un reply en français. int AddMAC(const char* dest,const char* gateway,const int index) { struct sockaddr_dl gway; // Adresse passerelle struct sockaddr_in dst; // Réseau/hote cible char ds[IPSTRING]; struct ecos_rtentry *rt=NULL; // Entrée dans la table de routage int s=0; // Descripteur de socket u_char cp[MACSTRING]; // Adresse MAC sous forme chaine memset(&gway,0,sizeof(struct sockaddr_dl)); gway.sdl_family=AF_LINK; // AF_UNSPEC ? gway.sdl_len=sizeof(struct sockaddr_dl); gway.sdl_index=index; gway.sdl_type=IFT_ETHER; gway.sdl_alen=ETHER_ADDR_LEN; memcpy(gway.sdl_data,gateway,ETHER_ADDR_LEN); memset(&dst,0,sizeof(struct sockaddr_in)); dst.sin_family=AF_INET; dst.sin_port=0; dst.sin_len=sizeof(struct sockaddr_in); dst.sin_addr.s_addr=inet_addr(dest); rt=(struct ecos_rtentry*)malloc(sizeof(struct ecos_rtentry)); if (!rt) { diag_printf("Erreur d'allocation d'une route :'%s'",strerror(errno)); return(-1); } memset(rt,0,sizeof(struct ecos_rtentry)); rt->rt_flags|=RTF_LLINFO; rt->rt_flags|=RTF_HOST; // Host entry memcpy(&(rt->rt_gateway), &gway, sizeof(struct sockaddr)); memcpy(&(rt->rt_dst), &dst, sizeof(struct sockaddr_in)); rt->rt_flags|=RTF_UP; // Route utilisable // rt->rt_flags|=RTF_WAS_CLONED; //rt->rt_use=0; rt->rt_dev=NULL; rt->rt_metric=1; // Reseau local strncpy(ds,inet_ntoa(dst.sin_addr),IPSTRING); ether_print((u_char*)gateway,(char*)cp,MACSTRING); diag_printf("Ajout d'une adresse MAC pour '%s' :'%s' sur interface eth%d",ds,cp,index-1); s=socket(AF_INET,SOCK_DGRAM,0); if (s<0) { diag_printf("Socket error :'%s'",strerror(errno)); free(rt); return(-1); } if (ioctl(s,SIOCADDRT,rt)<0) { diag_printf("Ioctl error :'%s'",strerror(errno)); switch (errno) { case EINVAL:diag_printf("Invalid Command or agument"); break; case ENOTTY:diag_printf("Not a device"); break; case EBADF:diag_printf("Bad File descriptor"); break; case EEXIST:diag_printf("Already existing"); break; default:diag_printf("Unknown error %d:'%s'",errno,strerror(errno)); } free(rt); close(s); return (-1); } diag_printf("ARP entry added"); free(rt); close(s); return(0); } -- Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [ECOS] ARP static entry 2006-03-25 9:09 [ECOS] ARP static entry Michael Grimard @ 2006-03-27 8:39 ` Birahim Larou Fall 2006-03-27 17:05 ` Michael Grimard 0 siblings, 1 reply; 5+ messages in thread From: Birahim Larou Fall @ 2006-03-27 8:39 UTC (permalink / raw) To: Michael Grimard; +Cc: ecos-discuss The code posted by Sebastien just add a route in ARP table but does not disable/bypass the ARP protocole. What does the function ioct returns? use show_network_tables(); to print all routes: typedef int pfunc( const char *fmt, ... ) CYGBLD_ATTRIB_PRINTF_FORMAT(1,2); externC void show_network_tables(pfunc *pfct);// packages/net/bsd_tcpip/current/src/ecos/support.c show_network_tables(diag_printf);// show all routes. Why you don't use use LWIP stack? you can easily remove the ARP protocole. Give more informations about your project. PS: je parle français mais l'anglais permet d'en faire profiter un max de softer. Fall Birahim Elsys Design for SCM Microsystems "Michael Grimard" <michaelg@maxt.com> Sent by: ecos-discuss-owner@ecos.sourceware.org 25/03/2006 04:28 To <ecos-discuss@sourceware.org> cc Subject [ECOS] ARP static entry Hi, I need to enter some entries in the ARP table to bypass the ARP protocol with the FreeBSD stack. I started by using the code that came with this previous post: http://sourceware.org/ml/ecos-discuss/2005-09/msg00023.html but I can’t make it work. Say that I want to link the IP Address 10.10.10.90 to Ethernet Address 00:07:E9:E3:07:A7, what will the parameters be to the call of AddMAC function? Any help/suggestion will be greatly appreciated. I’m new to eCos and networking stuff, so I’m a little lost here… Thanks, Michael P.S.: Je parle français, alors si Sébastien Couret est encore sur la liste, tu peux me faire un reply en français. int AddMAC(const char* dest,const char* gateway,const int index) { struct sockaddr_dl gway; // Adresse passerelle struct sockaddr_in dst; // Réseau/hote cible char ds[IPSTRING]; struct ecos_rtentry *rt=NULL; // Entrée dans la table de routage int s=0; // Descripteur de socket u_char cp[MACSTRING]; // Adresse MAC sous forme chaine memset(&gway,0,sizeof(struct sockaddr_dl)); gway.sdl_family=AF_LINK; // AF_UNSPEC ? gway.sdl_len=sizeof(struct sockaddr_dl); gway.sdl_index=index; gway.sdl_type=IFT_ETHER; gway.sdl_alen=ETHER_ADDR_LEN; memcpy(gway.sdl_data,gateway,ETHER_ADDR_LEN); memset(&dst,0,sizeof(struct sockaddr_in)); dst.sin_family=AF_INET; dst.sin_port=0; dst.sin_len=sizeof(struct sockaddr_in); dst.sin_addr.s_addr=inet_addr(dest); rt=(struct ecos_rtentry*)malloc(sizeof(struct ecos_rtentry)); if (!rt) { diag_printf("Erreur d'allocation d'une route :'%s'",strerror(errno)); return(-1); } memset(rt,0,sizeof(struct ecos_rtentry)); rt->rt_flags|=RTF_LLINFO; rt->rt_flags|=RTF_HOST; // Host entry memcpy(&(rt->rt_gateway), &gway, sizeof(struct sockaddr)); memcpy(&(rt->rt_dst), &dst, sizeof(struct sockaddr_in)); rt->rt_flags|=RTF_UP; // Route utilisable // rt->rt_flags|=RTF_WAS_CLONED; //rt->rt_use=0; rt->rt_dev=NULL; rt->rt_metric=1; // Reseau local strncpy(ds,inet_ntoa(dst.sin_addr),IPSTRING); ether_print((u_char*)gateway,(char*)cp,MACSTRING); diag_printf("Ajout d'une adresse MAC pour '%s' :'%s' sur interface eth%d",ds,cp,index-1); s=socket(AF_INET,SOCK_DGRAM,0); if (s<0) { diag_printf("Socket error :'%s'",strerror(errno)); free(rt); return(-1); } if (ioctl(s,SIOCADDRT,rt)<0) { diag_printf("Ioctl error :'%s'",strerror(errno)); switch (errno) { case EINVAL:diag_printf("Invalid Command or agument"); break; case ENOTTY:diag_printf("Not a device"); break; case EBADF:diag_printf("Bad File descriptor"); break; case EEXIST:diag_printf("Already existing"); break; default:diag_printf("Unknown error %d:'%s'",errno,strerror(errno)); } free(rt); close(s); return (-1); } diag_printf("ARP entry added"); free(rt); close(s); return(0); } -- Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss ^ permalink raw reply [flat|nested] 5+ messages in thread
* RE: [ECOS] ARP static entry 2006-03-27 8:39 ` Birahim Larou Fall @ 2006-03-27 17:05 ` Michael Grimard 2006-03-28 10:10 ` Birahim Larou Fall 0 siblings, 1 reply; 5+ messages in thread From: Michael Grimard @ 2006-03-27 17:05 UTC (permalink / raw) To: ecos-discuss Thanks Birahim. What I'm trying to do is modify the stack so that all configuration will be static (no DNS and no ARP). Everything (Host name, IP Address and MAC Address) will be known in advance and read from a configuration file to configure the stack. My network is a closed network and it needs to be up and running really fast after a reset, so there is no time (and need) to use DNS and ARP protocols. Also, I only need to use UDP packet. The first step I thaught to do is to add a static entry to the ARP and the next step would have been to disable it. I used the code posted by Sebastien to add a route in ARP table, ioctl() returns 0 (no error), show_network_tables() show me a new route for 10.10.10.90 (but the gateway is 10.10.10.90) so the route is probably not good. The first time I send a packet to 10.10.10.90, I see the ARP request and reply packets on the wire... That confirms that the route/entry is not good. I removed the code to add the entry to ARP table and call show_network_tables() after the first packet is sent and the ARP protocol has done is job, but I don't see the new entry (I have four entries, two on eth0 (0.0.0.0 and 10.10.10.0) and two for lo0). I have two questions: 1- does UDP packet add entry to the table? UDP is connectionless, maybe the route is saved elsewhere or differently. 2- The target machine is running eCos with Redboot. Both have an IP Address but only are using the same MAC. The route should be to Redboot (that will pass it to eCos)? That is what I see with Ethereal, Ethernet destination is Redboot and IP destination is eCos. For LwIp, I will definitely take a look at it, but I will wait that the patches to the latest version will be accepted. Thanks, Michael -----Original Message----- From: Birahim Larou Fall [mailto:BLFall@scmmicro.fr] Sent: March 27, 2006 3:17 AM To: Michael Grimard Cc: ecos-discuss@sourceware.org Subject: Re: [ECOS] ARP static entry The code posted by Sebastien just add a route in ARP table but does not disable/bypass the ARP protocole. What does the function ioct returns? use show_network_tables(); to print all routes: typedef int pfunc( const char *fmt, ... ) CYGBLD_ATTRIB_PRINTF_FORMAT(1,2); externC void show_network_tables(pfunc *pfct);// packages/net/bsd_tcpip/current/src/ecos/support.c show_network_tables(diag_printf);// show all routes. Why you don't use use LWIP stack? you can easily remove the ARP protocole. Give more informations about your project. PS: je parle français mais l'anglais permet d'en faire profiter un max de softer. Fall Birahim Elsys Design for SCM Microsystems "Michael Grimard" <michaelg@maxt.com> Sent by: ecos-discuss-owner@ecos.sourceware.org 25/03/2006 04:28 To <ecos-discuss@sourceware.org> cc Subject [ECOS] ARP static entry Hi, I need to enter some entries in the ARP table to bypass the ARP protocol with the FreeBSD stack. I started by using the code that came with this previous post: http://sourceware.org/ml/ecos-discuss/2005-09/msg00023.html but I cant make it work. Say that I want to link the IP Address 10.10.10.90 to Ethernet Address 00:07:E9:E3:07:A7, what will the parameters be to the call of AddMAC function? Any help/suggestion will be greatly appreciated. Im new to eCos and networking stuff, so Im a little lost here Thanks, Michael P.S.: Je parle français, alors si Sébastien Couret est encore sur la liste, tu peux me faire un reply en français. int AddMAC(const char* dest,const char* gateway,const int index) { struct sockaddr_dl gway; // Adresse passerelle struct sockaddr_in dst; // Réseau/hote cible char ds[IPSTRING]; struct ecos_rtentry *rt=NULL; // Entrée dans la table de routage int s=0; // Descripteur de socket u_char cp[MACSTRING]; // Adresse MAC sous forme chaine memset(&gway,0,sizeof(struct sockaddr_dl)); gway.sdl_family=AF_LINK; // AF_UNSPEC ? gway.sdl_len=sizeof(struct sockaddr_dl); gway.sdl_index=index; gway.sdl_type=IFT_ETHER; gway.sdl_alen=ETHER_ADDR_LEN; memcpy(gway.sdl_data,gateway,ETHER_ADDR_LEN); memset(&dst,0,sizeof(struct sockaddr_in)); dst.sin_family=AF_INET; dst.sin_port=0; dst.sin_len=sizeof(struct sockaddr_in); dst.sin_addr.s_addr=inet_addr(dest); rt=(struct ecos_rtentry*)malloc(sizeof(struct ecos_rtentry)); if (!rt) { diag_printf("Erreur d'allocation d'une route :'%s'",strerror(errno)); return(-1); } memset(rt,0,sizeof(struct ecos_rtentry)); rt->rt_flags|=RTF_LLINFO; rt->rt_flags|=RTF_HOST; // Host entry memcpy(&(rt->rt_gateway), &gway, sizeof(struct sockaddr)); memcpy(&(rt->rt_dst), &dst, sizeof(struct sockaddr_in)); rt->rt_flags|=RTF_UP; // Route utilisable // rt->rt_flags|=RTF_WAS_CLONED; //rt->rt_use=0; rt->rt_dev=NULL; rt->rt_metric=1; // Reseau local strncpy(ds,inet_ntoa(dst.sin_addr),IPSTRING); ether_print((u_char*)gateway,(char*)cp,MACSTRING); diag_printf("Ajout d'une adresse MAC pour '%s' :'%s' sur interface eth%d",ds,cp,index-1); s=socket(AF_INET,SOCK_DGRAM,0); if (s<0) { diag_printf("Socket error :'%s'",strerror(errno)); free(rt); return(-1); } if (ioctl(s,SIOCADDRT,rt)<0) { diag_printf("Ioctl error :'%s'",strerror(errno)); switch (errno) { case EINVAL:diag_printf("Invalid Command or agument"); break; case ENOTTY:diag_printf("Not a device"); break; case EBADF:diag_printf("Bad File descriptor"); break; case EEXIST:diag_printf("Already existing"); break; default:diag_printf("Unknown error %d:'%s'",errno,strerror(errno)); } free(rt); close(s); return (-1); } diag_printf("ARP entry added"); free(rt); close(s); return(0); } -- Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss -- Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss ^ permalink raw reply [flat|nested] 5+ messages in thread
* RE: [ECOS] ARP static entry 2006-03-27 17:05 ` Michael Grimard @ 2006-03-28 10:10 ` Birahim Larou Fall 2006-03-29 20:06 ` Michael Grimard 0 siblings, 1 reply; 5+ messages in thread From: Birahim Larou Fall @ 2006-03-28 10:10 UTC (permalink / raw) To: Michael Grimard; +Cc: ecos-discuss 1/ The argument gateway passed to the function may not be correct char gateway[] = {01, 10,10,10}; // to be confirm or {10,10,10,01}; Also before to call ioct() declares the routes static: rt->rt_flags|=RTF_STATIC; // static route: added by user. This avoid the route to be removed on timeout Make a break point for debug in function ip_output() and follows your packet until arp_request(); Why you want to disable this roote after interface set up? 2/UDP is connectionless but it needs a route to send data. So if it does not know its route, IP layer uses ARP to found the route. "UDP and TCP" can have the same route. UDP add entry to the tab. 3/ More than two network interface can share the same MAC adress but they must have different IP adress. When IP packets arrived, data are passed to the interface that match with IP address of the dest addr of the IP packet. Of course the best way, since you use freebsd, is to use eth0 for redboot and eth1 for your appli with different address MAC. You should configure the cdl file to enable eth1 if it's not done. 4/ About lwip, for me it's ok, you have just to modifie the ethernet logical driver for lwip (eth_drv) to bypass arp: eCos\packages\io\eth\current\src\lwip\eth_drv hope this can help you! PS: en utilisant lwip tu peux economiser jusqu'à 150Mo surtout que t'ulise pas TCP qui represente la moitié de lwip. Si on parle pas un peu le français, on risque de se faire taper par chirac :) Fall Birahim Elsys Design for SCM Microsystems Thanks Birahim. What I'm trying to do is modify the stack so that all configuration will be static (no DNS and no ARP). Everything (Host name, IP Address and MAC Address) will be known in advance and read from a configuration file to configure the stack. My network is a closed network and it needs to be up and running really fast after a reset, so there is no time (and need) to use DNS and ARP protocols. Also, I only need to use UDP packet. The first step I thaught to do is to add a static entry to the ARP and the next step would have been to disable it. I used the code posted by Sebastien to add a route in ARP table, ioctl() returns 0 (no error), show_network_tables() show me a new route for 10.10.10.90 (but the gateway is 10.10.10.90) so the route is probably not good. The first time I send a packet to 10.10.10.90, I see the ARP request and reply packets on the wire... That confirms that the route/entry is not good. I removed the code to add the entry to ARP table and call show_network_tables() after the first packet is sent and the ARP protocol has done is job, but I don't see the new entry (I have four entries, two on eth0 (0.0.0.0 and 10.10.10.0) and two for lo0). I have two questions: 1- does UDP packet add entry to the table? UDP is connectionless, maybe the route is saved elsewhere or differently. 2- The target machine is running eCos with Redboot. Both have an IP Address but only are using the same MAC. The route should be to Redboot (that will pass it to eCos)? That is what I see with Ethereal, Ethernet destination is Redboot and IP destination is eCos. For LwIp, I will definitely take a look at it, but I will wait that the patches to the latest version will be accepted. Thanks, Michael -----Original Message----- From: Birahim Larou Fall [mailto:BLFall@scmmicro.fr] Sent: March 27, 2006 3:17 AM To: Michael Grimard Cc: ecos-discuss@sourceware.org Subject: Re: [ECOS] ARP static entry The code posted by Sebastien just add a route in ARP table but does not disable/bypass the ARP protocole. What does the function ioct returns? use show_network_tables(); to print all routes: typedef int pfunc( const char *fmt, ... ) CYGBLD_ATTRIB_PRINTF_FORMAT(1,2); externC void show_network_tables(pfunc *pfct);// packages/net/bsd_tcpip/current/src/ecos/support.c show_network_tables(diag_printf);// show all routes. Why you don't use use LWIP stack? you can easily remove the ARP protocole. Give more informations about your project. PS: je parle français mais l'anglais permet d'en faire profiter un max de softer. Fall Birahim Elsys Design for SCM Microsystems "Michael Grimard" <michaelg@maxt.com> Sent by: ecos-discuss-owner@ecos.sourceware.org 25/03/2006 04:28 To <ecos-discuss@sourceware.org> cc Subject [ECOS] ARP static entry Hi, I need to enter some entries in the ARP table to bypass the ARP protocol with the FreeBSD stack. I started by using the code that came with this previous post: http://sourceware.org/ml/ecos-discuss/2005-09/msg00023.html but I can’t make it work. Say that I want to link the IP Address 10.10.10.90 to Ethernet Address 00:07:E9:E3:07:A7, what will the parameters be to the call of AddMAC function? Any help/suggestion will be greatly appreciated. I’m new to eCos and networking stuff, so I’m a little lost here… Thanks, Michael P.S.: Je parle français, alors si Sébastien Couret est encore sur la liste, tu peux me faire un reply en français. int AddMAC(const char* dest,const char* gateway,const int index) { struct sockaddr_dl gway; // Adresse passerelle struct sockaddr_in dst; // Réseau/hote cible char ds[IPSTRING]; struct ecos_rtentry *rt=NULL; // Entrée dans la table de routage int s=0; // Descripteur de socket u_char cp[MACSTRING]; // Adresse MAC sous forme chaine memset(&gway,0,sizeof(struct sockaddr_dl)); gway.sdl_family=AF_LINK; // AF_UNSPEC ? gway.sdl_len=sizeof(struct sockaddr_dl); gway.sdl_index=index; gway.sdl_type=IFT_ETHER; gway.sdl_alen=ETHER_ADDR_LEN; memcpy(gway.sdl_data,gateway,ETHER_ADDR_LEN); memset(&dst,0,sizeof(struct sockaddr_in)); dst.sin_family=AF_INET; dst.sin_port=0; dst.sin_len=sizeof(struct sockaddr_in); dst.sin_addr.s_addr=inet_addr(dest); rt=(struct ecos_rtentry*)malloc(sizeof(struct ecos_rtentry)); if (!rt) { diag_printf("Erreur d'allocation d'une route :'%s'",strerror(errno)); return(-1); } memset(rt,0,sizeof(struct ecos_rtentry)); rt->rt_flags|=RTF_LLINFO; rt->rt_flags|=RTF_HOST; // Host entry memcpy(&(rt->rt_gateway), &gway, sizeof(struct sockaddr)); memcpy(&(rt->rt_dst), &dst, sizeof(struct sockaddr_in)); rt->rt_flags|=RTF_UP; // Route utilisable // rt->rt_flags|=RTF_WAS_CLONED; //rt->rt_use=0; rt->rt_dev=NULL; rt->rt_metric=1; // Reseau local strncpy(ds,inet_ntoa(dst.sin_addr),IPSTRING); ether_print((u_char*)gateway,(char*)cp,MACSTRING); diag_printf("Ajout d'une adresse MAC pour '%s' :'%s' sur interface eth%d",ds,cp,index-1); s=socket(AF_INET,SOCK_DGRAM,0); if (s<0) { diag_printf("Socket error :'%s'",strerror(errno)); free(rt); return(-1); } if (ioctl(s,SIOCADDRT,rt)<0) { diag_printf("Ioctl error :'%s'",strerror(errno)); switch (errno) { case EINVAL:diag_printf("Invalid Command or agument"); break; case ENOTTY:diag_printf("Not a device"); break; case EBADF:diag_printf("Bad File descriptor"); break; case EEXIST:diag_printf("Already existing"); break; default:diag_printf("Unknown error %d:'%s'",errno,strerror(errno)); } free(rt); close(s); return (-1); } diag_printf("ARP entry added"); free(rt); close(s); return(0); } -- Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss -- Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss ^ permalink raw reply [flat|nested] 5+ messages in thread
* RE: [ECOS] ARP static entry 2006-03-28 10:10 ` Birahim Larou Fall @ 2006-03-29 20:06 ` Michael Grimard 0 siblings, 0 replies; 5+ messages in thread From: Michael Grimard @ 2006-03-29 20:06 UTC (permalink / raw) To: ecos-discuss Merci Birahim. It still doesn't work with gateway set 10.10.10.1. For the gateway parameter, I now pass the destination MAC address, since in the code, Sebastien does a memcpy on ETHER_ADDR_LEN, which is 6 (48 bits). memcpy(gway.sdl_data,gateway,ETHER_ADDR_LEN); But it still doesn't work. In arpresolve(), the sdl_alen field of sockaddr_dl structure is 0, so I'm tracing to see why. In the device, I will use the IFF_NOARP flag to disable the ARP. I guess it would still be able to resolve the addresses that are set statically in the table by the code, but not send request and reply to request. I'm thinking to buy TCP/IP Illustrated, Volume 2: The Implementation, from AW, any comments on this book? Does it explain well how the stack works internally? Thanks, Michael -----Original Message----- From: ecos-discuss-owner@ecos.sourceware.org [mailto:ecos-discuss-owner@ecos.sourceware.org] On Behalf Of Birahim Larou Fall Sent: March 28, 2006 4:12 AM To: Michael Grimard Cc: ecos-discuss@sourceware.org Subject: RE: [ECOS] ARP static entry 1/ The argument gateway passed to the function may not be correct char gateway[] = {01, 10,10,10}; // to be confirm or {10,10,10,01}; Also before to call ioct() declares the routes static: rt->rt_flags|=RTF_STATIC; // static route: added by user. This avoid the route to be removed on timeout Make a break point for debug in function ip_output() and follows your packet until arp_request(); Why you want to disable this roote after interface set up? 2/UDP is connectionless but it needs a route to send data. So if it does not know its route, IP layer uses ARP to found the route. "UDP and TCP" can have the same route. UDP add entry to the tab. 3/ More than two network interface can share the same MAC adress but they must have different IP adress. When IP packets arrived, data are passed to the interface that match with IP address of the dest addr of the IP packet. Of course the best way, since you use freebsd, is to use eth0 for redboot and eth1 for your appli with different address MAC. You should configure the cdl file to enable eth1 if it's not done. 4/ About lwip, for me it's ok, you have just to modifie the ethernet logical driver for lwip (eth_drv) to bypass arp: eCos\packages\io\eth\current\src\lwip\eth_drv hope this can help you! PS: en utilisant lwip tu peux economiser jusqu'à 150Mo surtout que t'ulise pas TCP qui represente la moitié de lwip. Si on parle pas un peu le français, on risque de se faire taper par chirac :) Fall Birahim Elsys Design for SCM Microsystems Thanks Birahim. What I'm trying to do is modify the stack so that all configuration will be static (no DNS and no ARP). Everything (Host name, IP Address and MAC Address) will be known in advance and read from a configuration file to configure the stack. My network is a closed network and it needs to be up and running really fast after a reset, so there is no time (and need) to use DNS and ARP protocols. Also, I only need to use UDP packet. The first step I thaught to do is to add a static entry to the ARP and the next step would have been to disable it. I used the code posted by Sebastien to add a route in ARP table, ioctl() returns 0 (no error), show_network_tables() show me a new route for 10.10.10.90 (but the gateway is 10.10.10.90) so the route is probably not good. The first time I send a packet to 10.10.10.90, I see the ARP request and reply packets on the wire... That confirms that the route/entry is not good. I removed the code to add the entry to ARP table and call show_network_tables() after the first packet is sent and the ARP protocol has done is job, but I don't see the new entry (I have four entries, two on eth0 (0.0.0.0 and 10.10.10.0) and two for lo0). I have two questions: 1- does UDP packet add entry to the table? UDP is connectionless, maybe the route is saved elsewhere or differently. 2- The target machine is running eCos with Redboot. Both have an IP Address but only are using the same MAC. The route should be to Redboot (that will pass it to eCos)? That is what I see with Ethereal, Ethernet destination is Redboot and IP destination is eCos. For LwIp, I will definitely take a look at it, but I will wait that the patches to the latest version will be accepted. Thanks, Michael -----Original Message----- From: Birahim Larou Fall [mailto:BLFall@scmmicro.fr] Sent: March 27, 2006 3:17 AM To: Michael Grimard Cc: ecos-discuss@sourceware.org Subject: Re: [ECOS] ARP static entry The code posted by Sebastien just add a route in ARP table but does not disable/bypass the ARP protocole. What does the function ioct returns? use show_network_tables(); to print all routes: typedef int pfunc( const char *fmt, ... ) CYGBLD_ATTRIB_PRINTF_FORMAT(1,2); externC void show_network_tables(pfunc *pfct);// packages/net/bsd_tcpip/current/src/ecos/support.c show_network_tables(diag_printf);// show all routes. Why you don't use use LWIP stack? you can easily remove the ARP protocole. Give more informations about your project. PS: je parle français mais l'anglais permet d'en faire profiter un max de softer. Fall Birahim Elsys Design for SCM Microsystems "Michael Grimard" <michaelg@maxt.com> Sent by: ecos-discuss-owner@ecos.sourceware.org 25/03/2006 04:28 To <ecos-discuss@sourceware.org> cc Subject [ECOS] ARP static entry Hi, I need to enter some entries in the ARP table to bypass the ARP protocol with the FreeBSD stack. I started by using the code that came with this previous post: http://sourceware.org/ml/ecos-discuss/2005-09/msg00023.html but I cant make it work. Say that I want to link the IP Address 10.10.10.90 to Ethernet Address 00:07:E9:E3:07:A7, what will the parameters be to the call of AddMAC function? Any help/suggestion will be greatly appreciated. Im new to eCos and networking stuff, so Im a little lost here Thanks, Michael P.S.: Je parle français, alors si Sébastien Couret est encore sur la liste, tu peux me faire un reply en français. int AddMAC(const char* dest,const char* gateway,const int index) { struct sockaddr_dl gway; // Adresse passerelle struct sockaddr_in dst; // Réseau/hote cible char ds[IPSTRING]; struct ecos_rtentry *rt=NULL; // Entrée dans la table de routage int s=0; // Descripteur de socket u_char cp[MACSTRING]; // Adresse MAC sous forme chaine memset(&gway,0,sizeof(struct sockaddr_dl)); gway.sdl_family=AF_LINK; // AF_UNSPEC ? gway.sdl_len=sizeof(struct sockaddr_dl); gway.sdl_index=index; gway.sdl_type=IFT_ETHER; gway.sdl_alen=ETHER_ADDR_LEN; memcpy(gway.sdl_data,gateway,ETHER_ADDR_LEN); memset(&dst,0,sizeof(struct sockaddr_in)); dst.sin_family=AF_INET; dst.sin_port=0; dst.sin_len=sizeof(struct sockaddr_in); dst.sin_addr.s_addr=inet_addr(dest); rt=(struct ecos_rtentry*)malloc(sizeof(struct ecos_rtentry)); if (!rt) { diag_printf("Erreur d'allocation d'une route :'%s'",strerror(errno)); return(-1); } memset(rt,0,sizeof(struct ecos_rtentry)); rt->rt_flags|=RTF_LLINFO; rt->rt_flags|=RTF_HOST; // Host entry memcpy(&(rt->rt_gateway), &gway, sizeof(struct sockaddr)); memcpy(&(rt->rt_dst), &dst, sizeof(struct sockaddr_in)); rt->rt_flags|=RTF_UP; // Route utilisable // rt->rt_flags|=RTF_WAS_CLONED; //rt->rt_use=0; rt->rt_dev=NULL; rt->rt_metric=1; // Reseau local strncpy(ds,inet_ntoa(dst.sin_addr),IPSTRING); ether_print((u_char*)gateway,(char*)cp,MACSTRING); diag_printf("Ajout d'une adresse MAC pour '%s' :'%s' sur interface eth%d",ds,cp,index-1); s=socket(AF_INET,SOCK_DGRAM,0); if (s<0) { diag_printf("Socket error :'%s'",strerror(errno)); free(rt); return(-1); } if (ioctl(s,SIOCADDRT,rt)<0) { diag_printf("Ioctl error :'%s'",strerror(errno)); switch (errno) { case EINVAL:diag_printf("Invalid Command or agument"); break; case ENOTTY:diag_printf("Not a device"); break; case EBADF:diag_printf("Bad File descriptor"); break; case EEXIST:diag_printf("Already existing"); break; default:diag_printf("Unknown error %d:'%s'",errno,strerror(errno)); } free(rt); close(s); return (-1); } diag_printf("ARP entry added"); free(rt); close(s); return(0); } -- Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss -- Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss -- Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2006-03-29 16:33 UTC | newest] Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2006-03-25 9:09 [ECOS] ARP static entry Michael Grimard 2006-03-27 8:39 ` Birahim Larou Fall 2006-03-27 17:05 ` Michael Grimard 2006-03-28 10:10 ` Birahim Larou Fall 2006-03-29 20:06 ` Michael Grimard
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).