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

int nl_cache_mngr_alloc ( struct nl_sock *  sk,
int  protocol,
int  flags,
struct nl_cache_mngr **  result 

Allocate new cache manager

  • sk Netlink socket.
  • protocol Netlink Protocol this manager is used for
  • flags Flags
Newly allocated cache manager or NULL on failure.

Definition at line 149 of file cache_mngr.c.

References nl_cache_mngr_free(), NL_CB_CUSTOM, NL_CB_VALID, nl_connect(), nl_socket_disable_seq_check(), nl_socket_modify_cb(), and nl_socket_set_nonblocking().

      struct nl_cache_mngr *mngr;
      int err = -NLE_NOMEM;

      if (sk == NULL)

      mngr = calloc(1, sizeof(*mngr));
      if (!mngr)
            goto errout;

      mngr->cm_handle = sk;
      mngr->cm_nassocs = 32;
      mngr->cm_protocol = protocol;
      mngr->cm_flags = flags;
      mngr->cm_assocs = calloc(mngr->cm_nassocs,
                         sizeof(struct nl_cache_assoc));
      if (!mngr->cm_assocs)
            goto errout;

      nl_socket_modify_cb(mngr->cm_handle, NL_CB_VALID, NL_CB_CUSTOM,
                      event_input, mngr);

      /* Required to receive async event notifications */

      if ((err = nl_connect(mngr->cm_handle, protocol) < 0))
            goto errout;

      if ((err = nl_socket_set_nonblocking(mngr->cm_handle) < 0))
            goto errout;

      NL_DBG(1, "Allocated cache manager %p, protocol %d, %d caches\n",
             mngr, protocol, mngr->cm_nassocs);

      *result = mngr;
      return 0;

      return err;

Generated by  Doxygen 1.6.0   Back to index