Skip to content

Commit

Permalink
portability: assign value for inet6 based on OS
Browse files Browse the repository at this point in the history
  • Loading branch information
msantos committed Jun 26, 2011
1 parent 5686980 commit b6af970
Showing 1 changed file with 28 additions and 3 deletions.
31 changes: 28 additions & 3 deletions src/procket.erl
Expand Up @@ -294,15 +294,40 @@ progname() ->
%% Protocol family (aka domain) %% Protocol family (aka domain)
family(unspec) -> 0; family(unspec) -> 0;
family(inet) -> 2; family(inet) -> 2;
family(inet6) -> 10; family(inet6) ->
case os:type() of
{unix, linux} -> 10;
{unix, darwin} -> 30;
{unix, freebsd} -> 28
end;
family(packet) -> 17; family(packet) -> 17;
family(Proto) when Proto == local; Proto == unix; Proto == file -> 1; family(Proto) when Proto == local; Proto == unix; Proto == file -> 1;


family(0) -> unspec; family(0) -> unspec;
family(1) -> unix; family(1) -> unix;
family(2) -> inet; family(2) -> inet;
family(10) -> inet6; family(10) ->
family(17) -> packet. case os:type() of
{unix, linux} -> inet6;
{unix, _} -> ccitt
end;
family(17) ->
case os:type() of
{unix, linux} -> packet;
{unix, _} -> route
end;
family(28) ->
case os:type() of
% linux: not defined
{unix, freebsd} -> inet6;
{unix, darwin} -> isdn
end;
family(30) ->
case os:type() of
{unix, linux} -> tipc;
{unix, freebsd} -> atm;
{unix, darwin} -> inet6
end.




%% Socket type %% Socket type
Expand Down

0 comments on commit b6af970

Please sign in to comment.