Logo Search packages:      
Sourcecode: libnl version File versions  Download package

struct nl_handle* nl_handle_alloc_nondefault ( enum nl_cb_kind  kind  )  [read]

Allocate and initialize new non-default netlink handle.

  • kind Kind of callback handler to use per default.
Allocates and initializes a new netlink handle, the netlink process id is set to the local process id which may conflict if multiple handles are created, therefore you may have to overwrite it using nl_handle_set_pid(). The initial sequence number is initialized to the current UNIX time.

Returns:
Newly allocated netlink handle or NULL.

Definition at line 140 of file nl.c.

References nl_cb_new(), and nl_handle_destroy().

Referenced by nl_handle_alloc().

{
      struct nl_handle *handle;
      
      handle = calloc(1, sizeof(*handle));
      if (!handle)
            goto errout;

      handle->h_cb = nl_cb_new(kind);
      if (!handle->h_cb)
            goto errout;
      
      handle->h_local.nl_family = AF_NETLINK;
      handle->h_peer.nl_family = AF_NETLINK;
      handle->h_local.nl_pid = getpid();
      handle->h_seq_expect = handle->h_seq_next = time(0);

      return handle;
errout:
      nl_handle_destroy(handle);
      nl_errno(ENOMEM);
      return NULL;
}


Generated by  Doxygen 1.6.0   Back to index