Permalink
Switch branches/tags
Commits on Jun 14, 2010
Commits on Jun 13, 2010
  1. Remove debug printf

    msantos committed Jun 13, 2010
  2. Add an NIF interface to ioctl()

    msantos committed Jun 13, 2010
    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.
  3. Add sendto/4 and bind/2

    msantos committed Jun 13, 2010
    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

    msantos committed May 29, 2010
    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

    msantos committed May 26, 2010
  2. Allow arbitrary socket family, type and protocol

    msantos committed May 26, 2010
    Simplify the procket external command by allowing the user to set
    any protocol, type and family for the socket.
Commits on May 25, 2010
  1. Remove use of setsockopt() from external command

    msantos committed May 25, 2010
    "Unsupported" socket options can be set from Erlang using the
    inet:setopts/2 raw option.
Commits on May 24, 2010
  1. Hard code ICMP code

    msantos committed May 24, 2010
  2. Add a define for ICMP ECHO

    msantos committed May 24, 2010
  3. Add an example for ICMP ping

    msantos committed May 24, 2010
    Create an ICMP ping packet from within Erlang, using a passed in
    raw socket and the sendto() available in gen_udp (gen_udp:send/4).
Commits on Mar 9, 2010
  1. Dynamically create path to procket executable too.

    msantos committed Mar 9, 2010
    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.

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

    msantos committed Mar 8, 2010
    Also an excuse to do some clean up.
Commits on Jan 21, 2010
Commits on Jan 13, 2010
  1. Restrict perms on directory containing Unix socket.

    msantos committed Jan 13, 2010
    Change the permissions on the directory holding the unix socket by
    forking chmod (yes, yes, hackish). There doesn't seem to be a way of
    setting perms/mask natively in Erlang.
    
    The alternative is doing the chmod within the NIF (e.g., procket:chmod/2).
    At that point, it's maybe better just to make an NIF procket:tmpdir/0.
Commits on Jan 12, 2010
  1. Clarify help.

    msantos committed Jan 12, 2010
Commits on Jan 11, 2010
  1. Nit squashing.

    msantos committed Jan 11, 2010
  2. Change my_enif_get_string() to return false if the string exceeds the…

    msantos committed Jan 11, 2010
    … buflen.
    
    Previously the string would have been silently truncated. If the string
    exceeds the buflen, open()/close() will throw an exception, which should
    provide for more predictable behaviour.
  3. Simplify by switching to a static buffer for socket path.

    msantos committed Jan 11, 2010
    And avoid those peksy memory leaks when we return early.
  4. Make the NIF stateless!

    msantos committed Jan 11, 2010
    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 10, 2010
Commits on Jan 9, 2010
  1. Fixes for compile on Mac OS X (what a PITA).

    msantos committed Jan 9, 2010
    I hate makefiles.