From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 14093 invoked by alias); 1 Sep 2009 09:59:03 -0000 Received: (qmail 14080 invoked by uid 22791); 1 Sep 2009 09:59:01 -0000 X-SWARE-Spam-Status: No, hits=-1.6 required=5.0 tests=AWL,BAYES_00,J_CHICKENPOX_43,J_CHICKENPOX_65,J_CHICKENPOX_66,SPF_HELO_PASS,SPF_PASS X-Spam-Check-By: sourceware.org Received: from www.meduna.org (HELO meduna.org) (92.240.244.38) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 01 Sep 2009 09:58:52 +0000 Received: from dial-78-141-95-31-orange.orange.sk ([78.141.95.31] helo=[192.168.130.27]) by meduna.org with esmtpsa (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.69) (envelope-from ) id 1MiQ8S-0001uB-Fz; Tue, 01 Sep 2009 11:58:47 +0200 Message-ID: <4A9CF045.4060107@meduna.org> Date: Tue, 01 Sep 2009 09:59:00 -0000 From: Stanislav Meduna User-Agent: Thunderbird 2.0.0.23 (Windows/20090812) MIME-Version: 1.0 To: Tarmo Kuuse , eCos Discussion References: <4A9C0111.70300@gmail.com> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Authenticated-User: stano@meduna.org X-Authenticator: dovecot_plain X-Spam-Score: -8.2 X-Spam-Score-Int: -81 X-Exim-Version: 4.69 (build at 30-Sep-2008 18:26:44) X-Date: 2009-09-01 11:58:47 X-Connected-IP: 78.141.95.31:2361 X-Message-Linecount: 109 X-Body-Linecount: 96 X-Message-Size: 3224 X-Body-Size: 2694 X-Received-Count: 1 X-Recipient-Count: 2 X-Local-Recipient-Count: 2 X-Local-Recipient-Defer-Count: 0 X-Local-Recipient-Fail-Count: 0 X-IsSubscribed: yes Mailing-List: contact ecos-discuss-help@ecos.sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: ecos-discuss-owner@ecos.sourceware.org Subject: Re: [ECOS] Re: How to deconfigure an interface? X-SW-Source: 2009-09/txt/msg00010.txt.bz2 Tarmo Kuuse wrote: > There could be a better way, but I just do SIOCGIFADDR to read the > current addresses from an interface and delete them with SIOCDIFADDR. As > input, the "struct ifreq" needs the interface's textual name (e.g. > "eth0"). Works fine. Yes, that's the same I'm doing now. > Another task which needs doing is clearing the routes table. There > exists a function "cyg_route_reinit()" which simply flushes all routes. > Unfortunately it also deletes routes for the local loopback and all > other interfaces you may have. I haven't yet figured out how to delete > the routes only for a given interface. I added such a function, it seems to work. In net\common\current\include: =================================================================== RCS file: /cvs/ecos/ecos-opt/net/net/common/current/include/network.h,v retrieving revision 1.6 diff -u -r1.6 network.h --- network.h 29 Jan 2009 17:49:57 -0000 1.6 +++ network.h 1 Sep 2009 09:36:34 -0000 @@ -68,6 +68,7 @@ __externC void init_all_network_interfaces(void); __externC void cyg_route_reinit(void); +__externC void cyg_route_reinit_iface(const char *); __externC void perror(const char *) __THROW; __externC int close(int); __externC ssize_t read(int, void *, size_t); In net\bsd_tcpip\current\src\sys\net: =================================================================== RCS file: /cvs/ecos/ecos-opt/net/net/bsd_tcpip/current/src/sys/net/route.c,v retrieving revision 1.5 diff -u -r1.5 route.c --- route.c 29 Jan 2009 17:49:56 -0000 1.5 +++ route.c 1 Sep 2009 09:42:34 -0000 @@ -79,6 +79,8 @@ struct sockaddr *, struct sockaddr *)); static void rtable_init __P((void **)); +externC void if_indextoname(int indx, char *buf, int len); + static void rtable_init(table) void **table; @@ -116,6 +118,14 @@ { struct rtentry *rt = (struct rtentry *)rn; if (rt->rt_ifa->ifa_addr->sa_family == AF_INET) { + int dodel = (vifp == NULL); + if (! dodel) { + char ifname[64]; + if_indextoname(rt->rt_ifp->if_index, ifname, 64); + dodel = ! strcmp(ifname, (const char *) vifp); + } + + if (dodel) rtrequest(RTM_DELETE, rt_key(rt), rt->rt_gateway, rt_mask(rt), 0, NULL); } @@ -135,6 +145,19 @@ } } +void +cyg_route_reinit_iface(const char *iface) +{ + int i; + for (i = 0; i < AF_MAX+1; i++) { + struct radix_node_head *rnh; + rnh = rt_tables[i]; + if (rnh) { + (*rnh->rnh_walktree)(rnh, rt_reinit_rtdelete, (void *) iface); + } + } +} + /* * Packet routing routines. */ Regards -- Stano -- Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss