[erlang-questions] How to add a option for inet:getopts

Kenneth Lundin <>
Fri Jan 19 12:59:31 CET 2007


Hi,

We have preliminary planned to implement a new option called "raw" as
an  extension to the
inet:getopts(Socket,Options)
and
inet:setopts(Socket,Options)
and all other places where socket options are handled.

The new "raw" option would look something like this:
{{raw,Level,OptionCode},OptionValue}

Both OptionCode and OptionValue is positive integers assumed to be mapped on
UINT32 in C. Thus the use is limited to OptionValues that fits in an UINT32.
Of course the inet_driver will be updated to support this as well.

With this new raw option it should be possible to use various non standard and
non supported socket options directly from Erlang code.
Thus the example

'getsockopt(fd,SOL_IP,SO_ORIGINAL_DST,&server,&slen)'.

could be implemented something like this:

-define(SOL_IP,10).  % the value 10 is only an example
-define(SO_ORIGINAL_DST,47). % the value 47 is only an example
%% The user has to find the right values from the C header files.
....
inet:getopts(Socket,[{raw,$SOL_IP,$SO_ORIGINAL_DST}])

which should return

[{{raw,$SOL_IP,$SO_ORIGINAL_DST},OptionValue}]

Note that this is preliminary ideas which may be adjusted when we implement it.

/Regards Kenneth (Erlang responsible at Ericsson)

On 1/19/07, Serge Aleynikov <> wrote:
> The only way to get this socket option accessible from Erlang is to add
> support for it in the network driver (inet_drv.c).
>
> Serge
>
> William Gan wrote:
> > Hello,
> >
> > I am preparing to implement a transparent proxy by erlang, and I need an
> > equivalent call for
> > 'getsockopt(fd,SOL_IP,SO_ORIGINAL_DST,&server,&slen)'.
> >
> > Can anyone give me some advice how to add such a call in erlang?
> >
> > William Gan
> >
> > _______________________________________________
> > erlang-questions mailing list
> > 
> > http://www.erlang.org/mailman/listinfo/erlang-questions
> >
>
> _______________________________________________
> erlang-questions mailing list
> 
> http://www.erlang.org/mailman/listinfo/erlang-questions
>



More information about the erlang-questions mailing list