From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 122774 invoked by alias); 15 Mar 2016 14:56:37 -0000 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 Received: (qmail 122708 invoked by uid 89); 15 Mar 2016 14:56:36 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-0.1 required=5.0 tests=AWL,BAYES_50,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,RP_MATCHES_RCVD,SPF_HELO_PASS,SPF_PASS autolearn=ham version=3.3.2 spammy=pants, Grant, edwards, Edwards X-HELO: plane.gmane.org Received: from plane.gmane.org (HELO plane.gmane.org) (80.91.229.3) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-SHA encrypted) ESMTPS; Tue, 15 Mar 2016 14:56:35 +0000 Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1afqOb-0007pQ-2d for ecos-discuss@ecos.sourceware.org; Tue, 15 Mar 2016 15:56:29 +0100 Received: from 67-130-15-94.dia.static.qwest.net ([67.130.15.94]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 15 Mar 2016 15:56:29 +0100 Received: from grant.b.edwards by 67-130-15-94.dia.static.qwest.net with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 15 Mar 2016 15:56:29 +0100 To: ecos-discuss@ecos.sourceware.org From: Grant Edwards Date: Tue, 15 Mar 2016 14:56:00 -0000 Message-ID: References: <56CACBE1.6040103@televic.com> <56CC139C.4080601@televic.com> <56E7ED7F.6020205@televic.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit User-Agent: slrn/1.0.2 (Linux) X-IsSubscribed: yes Subject: [ECOS] Re: Does FreeBSD stack support multiple IP addresses? X-SW-Source: 2016-03/txt/msg00007.txt.bz2 On 2016-03-15, Lambrecht Jürgen wrote: > On 02/23/2016 04:59 PM, Grant Edwards wrote: >> I just re-ran my tests and verified again that I'm able to set the IP >> and netmask in a single call to ioctl(SIOCAIFADDR). In my tests, I >> tried: >> >> Address Netmask >> ----------- -------------- >> 11.0.0.104 255.0.0.0 >> 11.0.0.104 255.255.0.0 >> 11.0.0.104 255.255.255.0 >> 11.0.0.104 255.240.0.0 > OK, now I see it: you use > SIOCAIFADDR > we use > SIOCSIFADDR > (from http://sourceware.org/ml/ecos-discuss/2005-08/msg00015.html) Yes. > Where did you learn to use SIOCAIFADDR? When I was writing a DHCPv6 implimentation, I had found some example code somewhere that used SIOCAIFADDR_IN6. So, I grepped the stack source for SIOCAIFADDR. Below is the function I was using during my testing. The 's' parameter is a UDP socket file descriptor. void addInterfaceAddress4(int s, uint32_t ip4addr, uint32_t netmask) { struct in_aliasreq ifra; struct sockaddr_in *addrp, *maskp; memset(&ifra, 0, sizeof ifra); strcpy(ifra.ifra_name, "eth0"); addrp = (struct sockaddr_in *) &ifra.ifra_addr; memset(addrp, 0, sizeof(*addrp)); addrp->sin_family = AF_INET; addrp->sin_len = sizeof(*addrp); addrp->sin_port = 0; maskp = (struct sockaddr_in *) &ifra.ifra_mask; memset(maskp, 0, sizeof(*maskp)); maskp->sin_family = AF_INET; maskp->sin_len = sizeof(*maskp); maskp->sin_port = 0; addrp->sin_addr.s_addr = htonl(ip4addr); maskp->sin_addr.s_addr = htonl(netmask); if (ioctl(s, SIOCAIFADDR, &ifra)) diag_printf("Error setting second 'eth0' IP address (SIOCAIFADDR): %s\n", strerror(errno)); } I just noticed that the memset(addrp,...) and memset(maskp,...) calls are redundant (not needed). -- Grant Edwards grant.b.edwards Yow! ... My pants just went at on a wild rampage through a gmail.com Long Island Bowling Alley!! -- Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss