Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Commits on May 3, 2011
  1. Allow '/' in character device name

    authored
    Accomodate character devices kept in a directory under /dev, e.g.,
    the tun device in /dev/net/tun.
Commits on Apr 18, 2011
  1. Compile errors

    authored
  2. Allow setuid open of any character device

    authored
    Make the bpf device code generic so that the spawned setuid procket
    executable is able to open any character device.
    
    The code first checks the multiplex device (e.g., /dev/bpf). If it exists
    and no error occurs, the fd is returned to the Erlang side.
    
    If the muliplexing device does not exist or is not a character device,
    the code will fall back to trying numbered devices.
Commits on Apr 17, 2011
  1. Initial support for BPF on BSDs

    authored
    Add support for sending and receiving raw frames on BSD systems.
    Only tested on Mac OS X. The bpf module calls the C interface with
    the appropriate parameters.
Commits on Apr 1, 2011
Commits on Feb 20, 2011
  1. Simplify option handling

    authored
Commits on Jan 16, 2011
  1. Allocate pointers to buffers for ioctl requests

    authored
    Some ioctl requests require a pointer to a user allocated buffer. For
    example:
    
    struct  iw_point
    {
        void *pointer;
        u_int16_t length;
        u_int16_t flags;
    };
    
    Would be constructed using:
    
    {ok, Structure, [Resource]} = procket:alloc([
        {ptr, 4096},                                % buffer
        <<4096:2/unsigned-native-integer-unit:8,    % length
        0:2/native-unsigned-integer-unit:8>>        % flags
    ]).
    
    A tuple containing the structure and a list of resources (one for
    each allocated buffer) is returned.
    
    After calling the ioctl, the contents of the buffer is retrieved by
    using the buf/1 function on the resource.
    
    NOTE: If the pointer points to somewhere invalid, ioctl will return
    {error, efault}, but if the pointer points somewhere within beam's memory
    space, the VM may crash.
Commits on Dec 25, 2010
  1. Fix sockaddr on BSD

    authored
    On SysV type systems, the first field of the struct sockaddr is 2 bytes
    and is set to the protocol family. On BSDs, the first byte is the socket
    address length and the second byte is the protocol family. Add some
    portability goo to deal with it.
  2. Fix for atom socket arguments

    authored
  3. Add sendto/2,3

    authored
    Add versions of sendto with defaults. sendto/2 corresponds to write and
    sendto/3 corresponds to send.
Commits on Dec 21, 2010
  1. Socket args can be either atoms or integers

    authored
    Personally, I prefer the integer macros. Todo: use integer macros when
    mapping atom name -> integer.
  2. Remove fd transfer functions from export

    authored
    Remove the functions used for transferring the socket fd between process
    from the export list. TODO: create wrappers for libancillary
Commits on Dec 17, 2010
  1. Remove close/2; add listen/1

    authored
    Remove close/2 which removed the Unix socket. Handle the socket deletion
    in Erlang. Add listen/1 which uses a default backlog.
  2. recvfrom/4: return socket address

    authored
    Add recvfrom/4 to return the socket address of the packet. recvfrom/4
    takes 2 new args: flags and the size of the socket structure which is
    allocated by the NIF. If the size is not large enough, the socket address
    will be silently truncated.
Commits on Dec 15, 2010
  1. Communicate with Unix sockets

    authored
    Break out socket primitives (socket, listen, accept, ...) to allow Erlang
    to create and access Unix sockets. Any type of unprivileged socket can
    be created without spawning the setuid helper.
    
    Warning: because listen/2 is now a wrapper around the listen(2), the
    procket:listen/1,2 has been renamed to procket:open/1,2.
Commits on Dec 10, 2010
  1. Clean up local socket temp directory

    authored
    If a temporary directory was created to hold the Unix socket, delete it
    after the privileged socket has been sent to Erlang.
Commits on Oct 30, 2010
  1. Fix fd leak

    authored
    The Unix socket file descriptor was leaked whenever there was an error.
Commits on Oct 6, 2010
  1. Add interface name sanitation

    klaar authored
Commits on Jun 26, 2010
  1. Close any file descriptor

    authored
    Re-use procket:close/2 to close any file descriptor. Consequently,
    reverse the arguments to close/2, to take the fd first.
Commits on Jun 24, 2010
  1. Add an NIF setsockopt for promiscous mode

    authored
    Add an interface to setsockopt(). procket:setsockopt/4 can be used for
    putting the interface into promiscous mode.  Add packet:promiscuous/2
    convenience function to do that:
    
    packet:promiscuous(Socket, Ifindex)
Commits on Jun 13, 2010
  1. Add an NIF interface to ioctl()

    authored
    Add an Erlang interface to ioctl() using an NIF. For example, to retrieve
    the interface index for the "eth0" interface to use for sending out
    raw packets:
    
    -define(SIOCGIFINDEX, 16#8933).
    {ok, <<_Ifname:16/bytes, Ifr:8, _/binary>>} = procket:ioctl(S,
            ?SIOCGIFINDEX,
            <<"eth0", 0:224>>).
    
    The value "Ifr" will contain the index that can be used to set the
    sll_ifindex member of struct sockaddr_ll.
  2. Add sendto/4 and bind/2

    authored
    sendto/4 takes as arguments:
    * the socket descriptor
    * the buffer to be sent
    * flags
    * a binary representing a struct sockaddr_*
    
    For example, to send an ICMP echo to 192.168.100.1, assuming the variable
    "Packet" holds a valid ICMP packet:
    
    ok = procket:sendto(S, Packet, 0,
        <<
            2:16/native,                    % sin_family: PF_INET
            0:16,                           % sin_port
            192:8, 168:8, 100:8, 1:8,       % sin_addr
            0:64                            % sin_zero
        >>
    ).
    
    Similarly, bind/2 takes:
    * the socket descriptor
    * a binary representing a struct sockaddr_*
Commits on May 29, 2010
  1. Add NIF versions of recvfrom/sendto

    authored
    sendto is untested and disabled. Make sockets non-blocking for NIF
    sendto/recvfrom. Cache atoms and clean up corresponding error functions.
Commits on May 26, 2010
  1. Type conversion is wardsback

    authored
  2. Allow arbitrary socket family, type and protocol

    authored
    Simplify the procket external command by allowing the user to set
    any protocol, type and family for the socket.
Commits on Mar 9, 2010
  1. Dynamically create path to procket executable too.

    authored
    The path to the procket executable can still be set using {progname, ...}.
    By default, figure out the path relative to the module in ebin and run
    it using sudo.
  2. Dynamically create path to NIF relative to module.

    authored
    Assumes the lib is in the priv directory.
Commits on Mar 8, 2010
  1. Changes for the R13B04 nif interface.

    authored
    Also an excuse to do some clean up.
Commits on Jan 11, 2010
  1. Make the NIF stateless!

    authored
    Need to explicitly pass in socket info to the procket NIF, rather than it
    tracking the data internally. This should make it much safer and reliable.
    
    Changes to the interface:
    
    open/2 -> open/1 : vestigal protocol arg removed, stick to streams. Erlang module changed to match (along with the bizarre passing in of the port as a protocol, who did that? o_O)
    
    Returns the socket descriptor listening on the Unix socket: {ok, FD}
    
    poll/0 -> poll/1 : takes the socket descriptor
    
    close/0 -> close/2 : close(SocketPath, SocketDescriptor), closes the socket descriptor and deletes the socket path.
Commits on Jan 9, 2010
Something went wrong with that request. Please try again.