[erlang-questions] How to add a option for inet:getopts
Fri Jan 19 14:29:51 CET 2007
Thanks for sharing this preliminary info. As a caveat, it looks to me
that this option would require to run erl with root privileges (that
from the security point of view is not a good thing). There's actually
a work around on Linux for this using 'cap_net_raw' capability, where
you can start the process as root, set the capability and switch to
effective user. This would allow to retain access to a raw socket and
not to be root.
If interested I can provide a sample code.
Kenneth Lundin wrote:
> We have preliminary planned to implement a new option called "raw" as
> an extension to the
> and all other places where socket options are handled.
> The new "raw" option would look something like this:
> 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
> 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
> 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.
> which should return
> 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).
>> 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
More information about the erlang-questions