From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 9690 invoked by alias); 27 Mar 2006 16:40:01 -0000 Received: (qmail 9638 invoked by uid 22791); 27 Mar 2006 16:40:00 -0000 X-Spam-Check-By: sourceware.org Received: from Unknown (HELO mail.maxt.com) (207.61.20.50) by sourceware.org (qpsmtpd/0.31) with ESMTP; Mon, 27 Mar 2006 16:39:56 +0000 Received: from cygnus ([207.61.20.54]) by mail.maxt.com (Merak 4.2.1) with ESMTP id MYE73786 for ; Mon, 27 Mar 2006 11:27:14 -0500 From: "Michael Grimard" To: Date: Mon, 27 Mar 2006 17:05:00 -0000 Message-ID: <002801c651bd$10c40b30$970a0a0a@cygnus> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable In-Reply-To: X-IsSubscribed: yes Mailing-List: contact ecos-discuss-help@ecos.sourceware.org; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: ecos-discuss-owner@ecos.sourceware.org Subject: RE: [ECOS] ARP static entry X-SW-Source: 2006-03/txt/msg00224.txt.bz2 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:=20 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]=20 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=20 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, ... )=20 CYGBLD_ATTRIB_PRINTF_FORMAT(1,2);=20 externC void show_network_tables(pfunc *pfct);//=20 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. =20 PS: je parle fran=E7ais mais l'anglais permet d'en faire profiter un max de= =20 softer.=20 Fall Birahim Elsys Design for SCM Microsystems "Michael Grimard" =20 Sent by: ecos-discuss-owner@ecos.sourceware.org 25/03/2006 04:28 To 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=92t=20 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=92m new to eCos and networking stuff, so I=92m a little lost here=85 Thanks, Michael P.S.: Je parle fran=E7ais, alors si S=E9bastien Couret est encore sur la=20 liste, tu peux me faire un reply en fran=E7ais. int AddMAC(const char* dest,const char* gateway,const int index) { struct sockaddr_dl gway; // Adresse passerelle struct sockaddr_in dst; // R=E9seau/hote cible =20 char ds[IPSTRING]; struct ecos_rtentry *rt=3DNULL; // Entr=E9e dans la table de routage int s=3D0; // Descripteur de socket u_char cp[MACSTRING]; // Adresse MAC sous forme chaine =20 memset(&gway,0,sizeof(struct sockaddr_dl)); gway.sdl_family=3DAF_LINK; // AF_UNSPEC ? gway.sdl_len=3Dsizeof(struct sockaddr_dl); gway.sdl_index=3Dindex; gway.sdl_type=3DIFT_ETHER;=20 gway.sdl_alen=3DETHER_ADDR_LEN; memcpy(gway.sdl_data,gateway,ETHER_ADDR_LEN); =20 memset(&dst,0,sizeof(struct sockaddr_in)); dst.sin_family=3DAF_INET; dst.sin_port=3D0; dst.sin_len=3Dsizeof(struct sockaddr_in); dst.sin_addr.s_addr=3Dinet_addr(dest); =20 rt=3D(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|=3DRTF_LLINFO; rt->rt_flags|=3DRTF_HOST; // Host entry memcpy(&(rt->rt_gateway), &gway, sizeof(struct sockaddr)); memcpy(&(rt->rt_dst), &dst, sizeof(struct sockaddr_in)); =20 rt->rt_flags|=3DRTF_UP; // Route utilisable // rt->rt_flags|=3DRTF_WAS_CLONED; //rt->rt_use=3D0; rt->rt_dev=3DNULL; rt->rt_metric=3D1; // 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=3Dsocket(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); } =20 =20 --=20 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