This is the mail archive of the ecos-discuss@sourceware.org mailing list for the eCos project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Re: Does FreeBSD stack support multiple IP addresses?


On 02/22/2016 04:05 PM, Grant Edwards wrote:
> On 2016-02-22, Lambrecht JÃrgen <J.Lambrecht@TELEVIC.com> wrote:
>> On 02/19/2016 07:11 PM, Grant Edwards wrote:
>>> On 2016-02-19, Grant Edwards <grant.b.edwards@gmail.com> wrote:
>>>
>>>> Can one assign multiple IP addresses (on different subnets) to a
>>>> single interface when using the eCos FreeBSD network stack?
> [...]
>>> You use SIOCAIFADDR(_IN6) instead of SIOCASIFADDR and its brethren.
>> I had 2 problems to assign 2 IP addresses with different netmasks:
>>
>> - To assign an IP address an set a netmask are 2 different ioctl
>>    calls.  To set the netmask, you cannot specify for which IP
>>    address you set it.  The code (current/src/sys/netinet/in.c) is
>>    written in such a way that the netmask is set on the last IP
>>    address you added on that interface.  So that should be OK if you
>>    keep the correct order.
> When I tried it, the SIOCAIFADDR ioctl() let me set both address and
> netmask in a single call.  The "case SIOCAIFADDR" code falls through
> into SIOCSIFNETMASK code.  That didn't work for you?
Indeed, I remember now that I saw that in the code, but then you have 
the netmask according to the class A/B/C rules, and that is not what we 
want.
>
>> - It is only possible to assign a class A/B/C netmask. CIDR netmasks are
>>    not possible.
> I think that's always been the case for this version of the stack,
> hasn't it?
Indeed.
>
>>    I fixed current/src/sys/netinet/in.c for it, but I also
>>    adapted the ioctl to combine setting IP address and netmask in 1 call
>>    (so I cannot commit it back). Let me know if you want my fix.
I changed a bit the use of the members of the "inet"-something struct 
(in the ioctl call) to also use the netmask struct member that is 
already in it. Because normally, when you call ioctl SIOCSIFNETMASK 
separately, you specify the netmask in the same struct member where you 
put the IP address for the SIOCAIFADDR call.
(I did a fast search in the linux code, but I am not used to that, so I 
did not find the "Linux way")
> I'm confused: based on my experiments and examination of the source
> code, it already works that way.
>
Well, it is both.
Indeed, as you say above, "code falls through into SIOCSIFNETMASK code", 
but then it sets "the netmask according to the class A/B/C rules", so 
the netmask is _calculated_, not strictly _set_.
I am completely sure about this, I read that whole code part.
(And my collegues did the experimentation to set a 255.248.0.0 netmask 
resulting in a 255.255.0.0 mask for 172.24.0.0 which is class B)

Kind regards,
JÃrgen

-- 
JÃrgen Lambrecht
R&D Associate
Mobile: +32 499 644 531
Twitter: JGRLambrecht
Tel: +32 (0)51 303045    Fax: +32 (0)51 310670
http://www.televic-rail.com
https://www.facebook.com/TelevicRail
Televic Rail NV - Leo Bekaertlaan 1 - 8870 Izegem - Belgium
Company number 0825.539.581 - RPR Kortrijk

This electronic transmission is intended exclusively for the person or entity
to whom it is addressed and may contain confidential and/or privileged
material. Any disclosure, copying, distribution or other action based upon the
information by persons or entities other than the intended recipient is
prohibited. All e-mail correspondence from Televic Rail NV is only intended for
information purposes and can not result in contractual obligations. Commitments
under Televic Rail NV can only occur through regular exchange of letters,
signed by authorized persons in accordance with publication in the Belgian
Official Gazette.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]