Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Commits on May 15, 2011
  1. Move examples out of source directory

    Examples are no longer built by default.
  2. Rename the mktmp utility module

    To avoid future module name conflicts, put the mktmp utility module into
    a procket namespace.
  3. sh printf is portable

Commits on May 14, 2011
  1. Return POSIX atom on error from forked setuid bin

    Add a function to the NIF returning an atom from erl_errno_id().
    Do not distinguish between procket_cmd and procket errors. Return the
    same tuple {error, posix()} on errors.
    Return the POSIX value in hackish way: by echo'ing the return code
    in os:cmd/1. Otherwise, sudo may return failure (for example, if the
    user has not placed the procket command in sudoers.conf. sudo exits
    with a return value of EPERM in this case).
Commits on May 13, 2011
  1. Simplify pad calculation

Commits on May 9, 2011
  1. Mask the top 3 bits for BSD ioctl requests

    The linux calculation was copied from asm-generic/ioctl.h but looks off
    still. If the size takes >14 bits, the direction will be overwritten.
  2. Portability pixie dust for ioctl macros

    First attempt at supporting the ioctl request macros on bsd and linux.
    The result seems to work but doesn't seem to be quite right yet.
    On BSD systems, the top 3 bits indicate the direction of the request:
    8 : ioctl parameter will be copied from user space into the kernel
    4 : ioctl parameter will be copied into the user supplied buffer from
        the kernel
    2 : no parameters are used
    The remaining 13 bits are used to indicate the size of the parameter.
    On Linux systems, only the top 2 bits are used. Setting both bits to 0
    indicates a void parameter. The meaning of the bits is reversed:
    8 : ioctl parameter will be copied into the user supplied buffer from
        the kernel
    4 : ioctl parameter will be copied from user space into the kernel
    The remaining 14 bits is used to hold the length of the parameter.
  3. Support tuntap interfaces

Commits on May 3, 2011
  1. Allow '/' in character device name

    Accomodate character devices kept in a directory under /dev, e.g.,
    the tun device in /dev/net/tun.
Commits on Apr 29, 2011
  1. packet: remove filter program limit

    Instead of throwing an exception when the max program instruction length
    has been reached, return setsockopt's errno value (out of memory).
Commits on Apr 28, 2011
Commits on Apr 27, 2011
  1. packet: pasto in endian conversion

    2 byte family field was inadvervently made into a 4 byte field and
    byte swapped.
Commits on Apr 23, 2011
  1. Remove support for decoding datalink types

    Move the support to pkt.
Commits on Apr 22, 2011
  1. Rename bpf:data/3 to bpf:packet/3

    Rename data -> packet to avoid confusion with the datalen (whole
    packe length) struct field. The term "packet" is used to describe
    the bpf captured content in the man page.
Commits on Apr 21, 2011
  1. Rename bpf parsing functions

    Clarify the bpf parsing by renaming them to match the bpf_hdr
    (Should bpf:data/3 really be bpf:cap/3 then?)
  2. bpf: set immediate mode by default

    In bpf:open/1, set immediate mode. The BIOCIMMEDIATE flags allows
    a read to return immediately after a packet is received by the bpf
    device, rather than waiting for the timeout to be reached (which
    is set to 0/inifinity) or the bpf buffer to fill.
Commits on Apr 20, 2011
  1. bpf: workaround for missing padding

    Probably due to a bug somewhere, the final 2 byte pad of some packets
    is stripped. If the real size of the data is equal to the sum of
    the capture and header length from the bpf header, set the pad to
  2. bpf: include header length in padding calculation

    The bpf man page states when calculating the start of the next packet,
        p = (char *)p + BPF_WORDALIGN(p->bh_hdrlen + p->bh_caplen)
    Add a BPF_WORDALIGN macro for compat use.
  3. bpf: move setting promiscuous mode to ctl/3

    Make promiscous mode another "set" function. There doesn't appear to be
    a way to disable promiscuous mode, so the third argument isn't necessary.
    Sort the ctl/2 and ctl/3 functions.
  4. Suppress warning

  5. Retrieve BPF stats

  6. Retrieve BIOCGSEESENT status

Commits on Apr 19, 2011
  1. Support filtering using BPF byte code

    Add support for loading filters into the BPF device.
    Filters are set by calling:
        bpf:ctl(Socket, setf, Filter).
    Where filter is a list of binaries. For example, the rules to filter
    IP addresses used in the bpf man page would look like:
    -define(ETHERTYPE_IP, 16#0800).
    ip() ->
            ?BPF_STMT(?BPF_LD+?BPF_H+?BPF_ABS, 12),
            ?BPF_JUMP(?BPF_JMP+?BPF_JEQ+?BPF_K, ?ETHERTYPE_IP, 0, 8),
            ?BPF_STMT(?BPF_LD+?BPF_W+?BPF_ABS, 26),
            ?BPF_JUMP(?BPF_JMP+?BPF_JEQ+?BPF_K, 16#8003700f, 0, 2),
            ?BPF_STMT(?BPF_LD+?BPF_W+?BPF_ABS, 30),
            ?BPF_JUMP(?BPF_JMP+?BPF_JEQ+?BPF_K, 16#80037023, 3, 4),
            ?BPF_JUMP(?BPF_JMP+?BPF_JEQ+?BPF_K, 16#80037023, 0, 3),
            ?BPF_STMT(?BPF_LD+?BPF_W+?BPF_ABS, 30),
            ?BPF_JUMP(?BPF_JMP+?BPF_JEQ+?BPF_K, 16#8003700f, 0, 1),
            ?BPF_STMT(?BPF_RET+?BPF_K, ?SIZEOF_U_INT-1),
            ?BPF_STMT(?BPF_RET+?BPF_K, 0)
    The ?BPF_STMT and ?BPF_JUMP macros are a just convenience when
    re-using existing examples. They simply call bpf:stmt/2 and bpf:jump/4.
  2. Don't leak fd's on error

    Someday bpf will be a real gen_server ...
Commits on Apr 18, 2011
  1. Wrappers for bpf ioctl's

  2. Update bpf for char dev changes

  3. Compile errors

Something went wrong with that request. Please try again.