public inbox for ecos-discuss@sourceware.org
 help / color / mirror / Atom feed
From: Birahim Larou Fall <BLFall@scmmicro.fr>
To: "Michael Grimard" <michaelg@maxt.com>
Cc: ecos-discuss@sourceware.org
Subject: Re: [ECOS] ARP static entry
Date: Mon, 27 Mar 2006 08:39:00 -0000	[thread overview]
Message-ID: <OFCC9FAB41.C3D2350E-ONC125713E.002C1DD1-C125713E.002E2DFB@scmmicro.fr> (raw)
In-Reply-To: <00f201c64fbc$3de06580$970a0a0a@cygnus>

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




  reply	other threads:[~2006-03-27  8:21 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-03-25  9:09 Michael Grimard
2006-03-27  8:39 ` Birahim Larou Fall [this message]
2006-03-27 17:05   ` Michael Grimard
2006-03-28 10:10     ` Birahim Larou Fall
2006-03-29 20:06       ` Michael Grimard

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=OFCC9FAB41.C3D2350E-ONC125713E.002C1DD1-C125713E.002E2DFB@scmmicro.fr \
    --to=blfall@scmmicro.fr \
    --cc=ecos-discuss@sourceware.org \
    --cc=michaelg@maxt.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).