[erlang-questions] [Fwd: Re: subnet masking with binary matching]

jm jeffm@REDACTED
Sat Jan 20 01:50:20 CET 2007


Meant to email this to the list not directly.

-------- Original Message --------

Thanks. I'll have to keep that in mind. I haven't looked at the IPv6
support that closely it's just in the back of my mind at the moment. As
long as the code is structured correctly with no major assumptions I'm
hoping that in will be a simple matter to go back and tweak a few lines
here and there.

Jeff.

Per Hedeland wrote:
> Just a side note,
> 
>> jm wrote:
>>> Using binary matching to perform subnet masking with the following code, 
>>> which should work with both IPv4 and IPv6 as far as I can tell,
>>>
>>> mask_address(Addr, Maskbits) ->
>>>    B = list_to_binary(tuple_to_list(Addr)),
> 
> It will actually *not* work for IPv6, as each tuple element there holds
> two address octets. You'd typically get a badarg from list_to_binary/1,
> but if you're really unlucky the thing could end up silently doing
> something completely wrong.
> 
> --Per Hedeland





More information about the erlang-questions mailing list