]> granicus.if.org Git - libnl/commitdiff
Rename struct nl_handle to struct nl_sock
authorThomas Graf <tgr@lsx.localdomain>
Thu, 15 May 2008 11:26:32 +0000 (13:26 +0200)
committerThomas Graf <tgr@lsx.localdomain>
Thu, 15 May 2008 11:26:32 +0000 (13:26 +0200)
The idea of a common handle is long revised and only misleading,
nl_handle really represents a socket with some additional
action handlers assigned to it.

Alias for nl_handle is kept for backwards compatibility.

50 files changed:
include/netlink-types.h
include/netlink/cache-api.h
include/netlink/cache.h
include/netlink/fib_lookup/lookup.h
include/netlink/genl/ctrl.h
include/netlink/genl/genl.h
include/netlink/handlers.h
include/netlink/netfilter/ct.h
include/netlink/netfilter/log.h
include/netlink/netfilter/log_msg.h
include/netlink/netfilter/nfnl.h
include/netlink/netfilter/queue.h
include/netlink/netfilter/queue_msg.h
include/netlink/netlink.h
include/netlink/route/addr.h
include/netlink/route/class.h
include/netlink/route/classifier.h
include/netlink/route/link.h
include/netlink/route/neighbour.h
include/netlink/route/neightbl.h
include/netlink/route/qdisc.h
include/netlink/route/route.h
include/netlink/route/rtnl.h
include/netlink/route/rule.h
include/netlink/socket.h
lib/cache.c
lib/cache_mngr.c
lib/doc.c
lib/fib_lookup/lookup.c
lib/genl/ctrl.c
lib/genl/genl.c
lib/genl/mngt.c
lib/handlers.c
lib/netfilter/ct.c
lib/netfilter/log.c
lib/netfilter/nfnl.c
lib/netfilter/queue.c
lib/netfilter/queue_msg.c
lib/nl.c
lib/route/addr.c
lib/route/class.c
lib/route/classifier.c
lib/route/link.c
lib/route/neigh.c
lib/route/neightbl.c
lib/route/qdisc.c
lib/route/route.c
lib/route/rtnl.c
lib/route/rule.c
lib/socket.c

index d5e23646f9ef6fc532faa4234ef976ab73dcbc6e..a818f996d35de9b0195cfe744588770073dc6ee7 100644 (file)
@@ -26,7 +26,7 @@
 #define NL_MSG_CRED_PRESENT 1
 
 struct nl_cache_ops;
-struct nl_handle;
+struct nl_sock;
 struct nl_object;
 
 struct nl_cb
@@ -39,34 +39,34 @@ struct nl_cb
 
        /** May be used to replace nl_recvmsgs with your own implementation
         * in all internal calls to nl_recvmsgs. */
-       int                     (*cb_recvmsgs_ow)(struct nl_handle *,
+       int                     (*cb_recvmsgs_ow)(struct nl_sock *,
                                                  struct nl_cb *);
 
        /** Overwrite internal calls to nl_recv, must return the number of
         * octets read and allocate a buffer for the received data. */
-       int                     (*cb_recv_ow)(struct nl_handle *,
+       int                     (*cb_recv_ow)(struct nl_sock *,
                                              struct sockaddr_nl *,
                                              unsigned char **,
                                              struct ucred **);
 
        /** Overwrites internal calls to nl_send, must send the netlink
         * message. */
-       int                     (*cb_send_ow)(struct nl_handle *,
+       int                     (*cb_send_ow)(struct nl_sock *,
                                              struct nl_msg *);
 
        int                     cb_refcnt;
 };
 
-struct nl_handle
+struct nl_sock
 {
-       struct sockaddr_nl      h_local;
-       struct sockaddr_nl      h_peer;
-       int                     h_fd;
-       int                     h_proto;
-       unsigned int            h_seq_next;
-       unsigned int            h_seq_expect;
-       int                     h_flags;
-       struct nl_cb *          h_cb;
+       struct sockaddr_nl      s_local;
+       struct sockaddr_nl      s_peer;
+       int                     s_fd;
+       int                     s_proto;
+       unsigned int            s_seq_next;
+       unsigned int            s_seq_expect;
+       int                     s_flags;
+       struct nl_cb *          s_cb;
 };
 
 struct nl_cache
@@ -89,7 +89,7 @@ struct nl_cache_mngr
        int                     cm_protocol;
        int                     cm_flags;
        int                     cm_nassocs;
-       struct nl_handle *      cm_handle;
+       struct nl_sock *        cm_handle;
        struct nl_cache_assoc * cm_assocs;
 };
 
index 96699ed1f0f93662f8c7fa0a20cfb03bafaf59b6..22fc449d1b91401c1902c664018ae07155544fa0 100644 (file)
@@ -39,7 +39,7 @@ extern "C" {
  * // function which must trigger a complete dump on the kernel-side of
  * // whatever the cache covers.
  * static int my_request_update(struct nl_cache *cache,
- *                             struct nl_handle *socket)
+ *                             struct nl_sock *socket)
  * {
  *     // In this example, we request a full dump of the interface table
  *     return nl_rtgen_request(socket, RTM_GETLINK, AF_UNSPEC, NLM_F_DUMP);
@@ -172,7 +172,7 @@ struct nl_cache_ops
         * Called whenever an update of the cache is required. Must send
         * a request message to the kernel requesting a complete dump.
         */
-       int   (*co_request_update)(struct nl_cache *, struct nl_handle *);
+       int   (*co_request_update)(struct nl_cache *, struct nl_sock *);
 
        /**
         * Called whenever a message was received that needs to be parsed.
index 604a56f86640cd6d7448b77ba3c3630bbd6401fd..f4db3b9bf943e413c92ee5029e5faef92892cb23 100644 (file)
@@ -38,7 +38,7 @@ extern struct nl_object *     nl_cache_get_prev(struct nl_object *);
 
 extern struct nl_cache *       nl_cache_alloc(struct nl_cache_ops *);
 extern int                     nl_cache_alloc_and_fill(struct nl_cache_ops *,
-                                                       struct nl_handle *,
+                                                       struct nl_sock *,
                                                        struct nl_cache **);
 extern int                     nl_cache_alloc_name(const char *,
                                                    struct nl_cache **);
@@ -53,11 +53,11 @@ extern int                  nl_cache_add(struct nl_cache *,
 extern int                     nl_cache_parse_and_add(struct nl_cache *,
                                                       struct nl_msg *);
 extern void                    nl_cache_remove(struct nl_object *);
-extern int                     nl_cache_refill(struct nl_handle *,
+extern int                     nl_cache_refill(struct nl_sock *,
                                                struct nl_cache *);
-extern int                     nl_cache_pickup(struct nl_handle *,
+extern int                     nl_cache_pickup(struct nl_sock *,
                                                struct nl_cache *);
-extern int                     nl_cache_resync(struct nl_handle *,
+extern int                     nl_cache_resync(struct nl_sock *,
                                                struct nl_cache *,
                                                change_func_t);
 extern int                     nl_cache_include(struct nl_cache *,
@@ -106,7 +106,7 @@ struct nl_cache_mngr;
 
 #define NL_AUTO_PROVIDE                1
 
-extern int                     nl_cache_mngr_alloc(struct nl_handle *,
+extern int                     nl_cache_mngr_alloc(struct nl_sock *,
                                                    int, int,
                                                    struct nl_cache_mngr **);
 extern int                     nl_cache_mngr_add(struct nl_cache_mngr *,
index 201a7a0887784f210c1da326c3fc2b94a6d153b2..8bf27b8d95495784fac2863aa4ccf29d5ef1a611 100644 (file)
@@ -31,7 +31,7 @@ extern struct nl_cache *      flnl_result_alloc_cache(void);
 extern int                     flnl_lookup_build_request(struct flnl_request *,
                                                          int,
                                                          struct nl_msg **);
-extern int                     flnl_lookup(struct nl_handle *,
+extern int                     flnl_lookup(struct nl_sock *,
                                            struct flnl_request *,
                                            struct nl_cache *);
 
index f66338e10f9570ee2ef6532918df0e8595014948..1ae62f4480d6caa4e9da9a7e1980d19591e5ccd6 100644 (file)
@@ -22,12 +22,12 @@ extern "C" {
 
 struct genl_family;
 
-extern int                     genl_ctrl_alloc_cache(struct nl_handle *,
+extern int                     genl_ctrl_alloc_cache(struct nl_sock *,
                                                      struct nl_cache **);
 extern struct genl_family *    genl_ctrl_search(struct nl_cache *, int);
 extern struct genl_family *    genl_ctrl_search_by_name(struct nl_cache *,
                                                         const char *);
-extern int                     genl_ctrl_resolve(struct nl_handle *,
+extern int                     genl_ctrl_resolve(struct nl_sock *,
                                                  const char *);
 
 #ifdef __cplusplus
index de142d07bc7a1a65edb7fcd128f3a562287e4f6d..3f3340cfdc7b8c6cd1f1099cc2f578193e310838 100644 (file)
@@ -6,7 +6,7 @@
  *     License as published by the Free Software Foundation version 2.1
  *     of the License.
  *
- * Copyright (c) 2003-2006 Thomas Graf <tgraf@suug.ch>
+ * Copyright (c) 2003-2008 Thomas Graf <tgraf@suug.ch>
  */
 
 #ifndef NETLINK_GENL_H_
@@ -20,9 +20,9 @@
 extern "C" {
 #endif
 
-extern int             genl_connect(struct nl_handle *);
+extern int             genl_connect(struct nl_sock *);
 
-extern int             genl_send_simple(struct nl_handle *, int, int,
+extern int             genl_send_simple(struct nl_sock *, int, int,
                                         int, int);
 
 extern void *          genlmsg_put(struct nl_msg *, uint32_t, uint32_t,
index ebcf9117a651baba87a26dc49d958b56b07a98dc..38c9ba0d9fda2b522665651eb3bb6fa97b4412a9 100644 (file)
@@ -23,7 +23,7 @@ extern "C" {
 #endif
 
 struct nl_cb;
-struct nl_handle;
+struct nl_sock;
 struct nl_msg;
 
 /**
@@ -143,15 +143,15 @@ extern int  nl_cb_err(struct nl_cb *, enum nl_cb_kind, nl_recvmsg_err_cb_t,
                      void *);
 
 extern void nl_cb_overwrite_recvmsgs(struct nl_cb *,
-                                    int (*func)(struct nl_handle *,
+                                    int (*func)(struct nl_sock *,
                                                 struct nl_cb *));
 extern void nl_cb_overwrite_recv(struct nl_cb *,
-                                int (*func)(struct nl_handle *,
+                                int (*func)(struct nl_sock *,
                                             struct sockaddr_nl *,
                                             unsigned char **,
                                             struct ucred **));
 extern void nl_cb_overwrite_send(struct nl_cb *,
-                                int (*func)(struct nl_handle *,
+                                int (*func)(struct nl_sock *,
                                             struct nl_msg *));
 
 #ifdef __cplusplus
index 2e08228703b69b370f3be0e92d1625f6bae1193c..e1f938694c731fbfba033faa387a0471b4051450 100644 (file)
@@ -28,7 +28,7 @@ struct nfnl_ct;
 extern struct nl_object_ops ct_obj_ops;
 
 extern struct nfnl_ct *        nfnl_ct_alloc(void);
-extern int     nfnl_ct_alloc_cache(struct nl_handle *, struct nl_cache **);
+extern int     nfnl_ct_alloc_cache(struct nl_sock *, struct nl_cache **);
 
 extern int     nfnlmsg_ct_group(struct nlmsghdr *);
 extern int     nfnlmsg_ct_parse(struct nlmsghdr *, struct nfnl_ct **);
@@ -36,19 +36,19 @@ extern int  nfnlmsg_ct_parse(struct nlmsghdr *, struct nfnl_ct **);
 extern void    nfnl_ct_get(struct nfnl_ct *);
 extern void    nfnl_ct_put(struct nfnl_ct *);
 
-extern int     nfnl_ct_dump_request(struct nl_handle *);
+extern int     nfnl_ct_dump_request(struct nl_sock *);
 
 extern int     nfnl_ct_build_add_request(const struct nfnl_ct *, int,
                                          struct nl_msg **);
-extern int     nfnl_ct_add(struct nl_handle *, const struct nfnl_ct *, int);
+extern int     nfnl_ct_add(struct nl_sock *, const struct nfnl_ct *, int);
 
 extern int     nfnl_ct_build_delete_request(const struct nfnl_ct *, int,
                                             struct nl_msg **);
-extern int     nfnl_ct_delete(struct nl_handle *, const struct nfnl_ct *, int);
+extern int     nfnl_ct_delete(struct nl_sock *, const struct nfnl_ct *, int);
 
 extern int     nfnl_ct_build_query_request(const struct nfnl_ct *, int,
                                            struct nl_msg **);
-extern int     nfnl_ct_query(struct nl_handle *, const struct nfnl_ct *, int);
+extern int     nfnl_ct_query(struct nl_sock *, const struct nfnl_ct *, int);
 
 extern void    nfnl_ct_set_family(struct nfnl_ct *, uint8_t);
 extern uint8_t nfnl_ct_get_family(const struct nfnl_ct *);
index be8dd3258b61ef4d4918a8137322dcb783e597fa..2002fa8bfd1f19d706115b0e259e5c79a9f33b35 100644 (file)
@@ -21,7 +21,7 @@
 extern "C" {
 #endif
 
-struct nl_handle;
+struct nl_sock;
 struct nlmsghdr;
 struct nfnl_log;
 
@@ -84,22 +84,22 @@ extern char *                       nfnl_log_flags2str(unsigned int, char *, size_t);
 extern unsigned int            nfnl_log_str2flags(const char *);
 
 extern int     nfnl_log_build_pf_bind(uint8_t, struct nl_msg **);
-extern int     nfnl_log_pf_bind(struct nl_handle *, uint8_t);
+extern int     nfnl_log_pf_bind(struct nl_sock *, uint8_t);
 
 extern int     nfnl_log_build_pf_unbind(uint8_t, struct nl_msg **);
-extern int     nfnl_log_pf_unbind(struct nl_handle *, uint8_t);
+extern int     nfnl_log_pf_unbind(struct nl_sock *, uint8_t);
 
 extern int     nfnl_log_build_create_request(const struct nfnl_log *,
                                              struct nl_msg **);
-extern int     nfnl_log_create(struct nl_handle *, const struct nfnl_log *);
+extern int     nfnl_log_create(struct nl_sock *, const struct nfnl_log *);
 
 extern int     nfnl_log_build_change_request(const struct nfnl_log *,
                                              struct nl_msg **);
-extern int     nfnl_log_change(struct nl_handle *, const struct nfnl_log *);
+extern int     nfnl_log_change(struct nl_sock *, const struct nfnl_log *);
 
 extern int     nfnl_log_build_delete_request(const struct nfnl_log *,
                                              struct nl_msg **);
-extern int     nfnl_log_delete(struct nl_handle *, const struct nfnl_log *);
+extern int     nfnl_log_delete(struct nl_sock *, const struct nfnl_log *);
 
 #ifdef __cplusplus
 }
index 42e1f70c20c00de090b033e46d7d242f9009fd53..63b0f6420f48ea78b8b39c59d887699d4e18e4f6 100644 (file)
@@ -21,7 +21,6 @@
 extern "C" {
 #endif
 
-struct nl_handle;
 struct nlmsghdr;
 struct nfnl_log_msg;
 
index 123d93ea65de873271cf3a706cb18ba878e620e4..8da4ba16fbf90c6d7c806237b654a57c6daf4459 100644 (file)
@@ -6,7 +6,7 @@
  *     License as published by the Free Software Foundation version 2.1
  *     of the License.
  *
- * Copyright (c) 2003-2006 Thomas Graf <tgraf@suug.ch>
+ * Copyright (c) 2003-2008 Thomas Graf <tgraf@suug.ch>
  * Copyright (c) 2007 Philip Craig <philipc@snapgear.com>
  * Copyright (c) 2007 Secure Computing Corporation
  */
@@ -23,14 +23,14 @@ extern "C" {
 #define NFNL_HDRLEN NLMSG_ALIGN(sizeof(struct nfgenmsg))
 #define NFNLMSG_TYPE(subsys, subtype) (((subsys) << 8) | (subtype))
 
-extern int             nfnl_connect(struct nl_handle *);
+extern int             nfnl_connect(struct nl_sock *);
 
 extern uint8_t         nfnlmsg_subsys(struct nlmsghdr *);
 extern uint8_t         nfnlmsg_subtype(struct nlmsghdr *);
 extern uint8_t         nfnlmsg_family(struct nlmsghdr *);
 extern uint16_t                nfnlmsg_res_id(struct nlmsghdr *);
 
-extern int             nfnl_send_simple(struct nl_handle *, uint8_t, uint8_t,
+extern int             nfnl_send_simple(struct nl_sock *, uint8_t, uint8_t,
                                         int, uint8_t, uint16_t);
 extern struct nl_msg * nfnlmsg_alloc_simple(uint8_t, uint8_t, int,
                                             uint8_t, uint16_t);
index d480135dfc4e8889f12aee7afe0a4f37522b8699..491b361dfb0f5e786447427badf0a3a87079eb57 100644 (file)
@@ -18,7 +18,7 @@
 extern "C" {
 #endif
 
-struct nl_handle;
+struct nl_sock;
 struct nlmsghdr;
 struct nfnl_queue;
 
@@ -60,24 +60,24 @@ extern int                  nfnl_queue_test_copy_range(const struct nfnl_queue *);
 extern uint32_t                        nfnl_queue_get_copy_range(const struct nfnl_queue *);
 
 extern int     nfnl_queue_build_pf_bind(uint8_t, struct nl_msg **);
-extern int     nfnl_queue_pf_bind(struct nl_handle *, uint8_t);
+extern int     nfnl_queue_pf_bind(struct nl_sock *, uint8_t);
 
 extern int     nfnl_queue_build_pf_unbind(uint8_t, struct nl_msg **);
-extern int     nfnl_queue_pf_unbind(struct nl_handle *, uint8_t);
+extern int     nfnl_queue_pf_unbind(struct nl_sock *, uint8_t);
 
 extern int     nfnl_queue_build_create_request(const struct nfnl_queue *,
                                                struct nl_msg **);
-extern int     nfnl_queue_create(struct nl_handle *,
+extern int     nfnl_queue_create(struct nl_sock *,
                                  const struct nfnl_queue *);
 
 extern int     nfnl_queue_build_change_request(const struct nfnl_queue *,
                                                struct nl_msg **);
-extern int     nfnl_queue_change(struct nl_handle *,
+extern int     nfnl_queue_change(struct nl_sock *,
                                  const struct nfnl_queue *);
 
 extern int     nfnl_queue_build_delete_request(const struct nfnl_queue *,
                                                struct nl_msg **);
-extern int     nfnl_queue_delete(struct nl_handle *,
+extern int     nfnl_queue_delete(struct nl_sock *,
                                  const struct nfnl_queue *);
 
 #ifdef __cplusplus
index f8f034c90bdb197d063cd54879a24acbe1007c0f..95a5d656e381b579788b6962ae03c86ba7cf9d7d 100644 (file)
@@ -18,7 +18,7 @@
 extern "C" {
 #endif
 
-struct nl_handle;
+struct nl_sock;
 struct nlmsghdr;
 struct nfnl_queue_msg;
 
@@ -91,7 +91,7 @@ extern int                    nfnl_queue_msg_test_verdict(const struct nfnl_queue_msg *);
 extern unsigned int            nfnl_queue_msg_get_verdict(const struct nfnl_queue_msg *);
 
 extern struct nl_msg *         nfnl_queue_msg_build_verdict(const struct nfnl_queue_msg *);
-extern int                     nfnl_queue_msg_send_verdict(struct nl_handle *,
+extern int                     nfnl_queue_msg_send_verdict(struct nl_sock *,
                                                            const struct nfnl_queue_msg *);
 
 #ifdef __cplusplus
index 4dafbc8e51b85122f41cc6336e1b644e0e402ae3..a7b64e507c31f5e8c6a7da6b85b3c820346fd8c0 100644 (file)
@@ -39,29 +39,29 @@ extern int nl_debug;
 extern struct nl_dump_params nl_debug_dp;
 
 /* Connection Management */
-extern int                     nl_connect(struct nl_handle *, int);
-extern void                    nl_close(struct nl_handle *);
+extern int                     nl_connect(struct nl_sock *, int);
+extern void                    nl_close(struct nl_sock *);
 
 /* Send */
-extern int                     nl_sendto(struct nl_handle *, void *, size_t);
-extern int                     nl_sendmsg(struct nl_handle *, struct nl_msg *,
+extern int                     nl_sendto(struct nl_sock *, void *, size_t);
+extern int                     nl_sendmsg(struct nl_sock *, struct nl_msg *,
                                           struct msghdr *);
-extern int                     nl_send(struct nl_handle *, struct nl_msg *);
-extern int                     nl_send_auto_complete(struct nl_handle *,
+extern int                     nl_send(struct nl_sock *, struct nl_msg *);
+extern int                     nl_send_auto_complete(struct nl_sock *,
                                                      struct nl_msg *);
-extern int                     nl_send_simple(struct nl_handle *, int, int,
+extern int                     nl_send_simple(struct nl_sock *, int, int,
                                               void *, size_t);
 
 /* Receive */
-extern int                     nl_recv(struct nl_handle *,
+extern int                     nl_recv(struct nl_sock *,
                                        struct sockaddr_nl *, unsigned char **,
                                        struct ucred **);
 
-extern int                     nl_recvmsgs(struct nl_handle *, struct nl_cb *);
+extern int                     nl_recvmsgs(struct nl_sock *, struct nl_cb *);
 
-extern int                     nl_recvmsgs_default(struct nl_handle *);
+extern int                     nl_recvmsgs_default(struct nl_sock *);
 
-extern int                     nl_wait_for_ack(struct nl_handle *);
+extern int                     nl_wait_for_ack(struct nl_sock *);
 
 /* Netlink Family Translations */
 extern char *                  nl_nlfamily2str(int, char *, size_t);
index a23907276360d7f4224f6b4528ae047292641df4..f92c36bed1c0955131e37a5d40c962c19433c44a 100644 (file)
@@ -28,15 +28,15 @@ struct rtnl_addr;
 extern struct rtnl_addr *rtnl_addr_alloc(void);
 extern void    rtnl_addr_put(struct rtnl_addr *);
 
-extern int     rtnl_addr_alloc_cache(struct nl_handle *, struct nl_cache **);
+extern int     rtnl_addr_alloc_cache(struct nl_sock *, struct nl_cache **);
 
 extern int     rtnl_addr_build_add_request(struct rtnl_addr *, int,
                                            struct nl_msg **);
-extern int     rtnl_addr_add(struct nl_handle *, struct rtnl_addr *, int);
+extern int     rtnl_addr_add(struct nl_sock *, struct rtnl_addr *, int);
 
 extern int     rtnl_addr_build_delete_request(struct rtnl_addr *, int,
                                               struct nl_msg **);
-extern int     rtnl_addr_delete(struct nl_handle *,
+extern int     rtnl_addr_delete(struct nl_sock *,
                                 struct rtnl_addr *, int);
 
 extern char *  rtnl_addr_flags2str(int, char *, size_t);
index a704ed157fc863e54954b61b5b557ed4f02aa19f..012128b9cd7af20105cb2d0ec5684949b5bdbaf6 100644 (file)
@@ -26,7 +26,7 @@ extern struct nl_object_ops class_obj_ops;
 
 extern struct rtnl_class *     rtnl_class_alloc(void);
 extern void            rtnl_class_put(struct rtnl_class *);
-extern int             rtnl_class_alloc_cache(struct nl_handle *, int,
+extern int             rtnl_class_alloc_cache(struct nl_sock *, int,
                                               struct nl_cache **);
 
 /* leaf qdisc access */
@@ -35,7 +35,7 @@ extern struct rtnl_qdisc *    rtnl_class_leaf_qdisc(struct rtnl_class *,
 
 extern int             rtnl_class_build_add_request(struct rtnl_class *, int,
                                                     struct nl_msg **);
-extern int             rtnl_class_add(struct nl_handle *, struct rtnl_class *,
+extern int             rtnl_class_add(struct nl_sock *, struct rtnl_class *,
                                       int);
 
 extern void            rtnl_class_set_ifindex(struct rtnl_class *, int);
index 0ee563e5d1bedcead9802c9b341a66c2a26dfd60..0c0b9c54c0e0ad4c023affab90455eec42b859a8 100644 (file)
@@ -26,18 +26,18 @@ extern struct nl_object_ops cls_obj_ops;
 extern struct rtnl_cls *rtnl_cls_alloc(void);
 extern void    rtnl_cls_put(struct rtnl_cls *);
 
-extern int     rtnl_cls_alloc_cache(struct nl_handle *, int, uint32_t,
+extern int     rtnl_cls_alloc_cache(struct nl_sock *, int, uint32_t,
                                     struct nl_cache **);
 
 extern int     rtnl_cls_build_add_request(struct rtnl_cls *, int,
                                           struct nl_msg **);
-extern int     rtnl_cls_add(struct nl_handle *, struct rtnl_cls *, int);
+extern int     rtnl_cls_add(struct nl_sock *, struct rtnl_cls *, int);
 
 extern int     rtnl_cls_build_change_request(struct rtnl_cls *, int,
                                              struct nl_msg **);
 extern int     rtnl_cls_build_delete_request(struct rtnl_cls *, int,
                                              struct nl_msg **);
-extern int     rtnl_cls_delete(struct nl_handle *, struct rtnl_cls *, int);
+extern int     rtnl_cls_delete(struct nl_sock *, struct rtnl_cls *, int);
 
 extern void rtnl_cls_set_ifindex(struct rtnl_cls *, int);
 extern void rtnl_cls_set_handle(struct rtnl_cls *, uint32_t);
index ec151aa7671ded61de7a636c0b64dfb3e10b42d8..4b630f746dd9d8e295bc1f9864ef03fa45a7ceeb 100644 (file)
@@ -57,7 +57,7 @@ extern void   rtnl_link_put(struct rtnl_link *);
 extern void    rtnl_link_free(struct rtnl_link *);
 
 /* link cache management */
-extern int     rtnl_link_alloc_cache(struct nl_handle *, struct nl_cache **);
+extern int     rtnl_link_alloc_cache(struct nl_sock *, struct nl_cache **);
 extern struct rtnl_link *rtnl_link_get(struct nl_cache *, int);
 extern struct rtnl_link *rtnl_link_get_by_name(struct nl_cache *, const char *);
 
@@ -65,7 +65,7 @@ extern struct rtnl_link *rtnl_link_get_by_name(struct nl_cache *, const char *);
 extern int     rtnl_link_build_change_request(struct rtnl_link *,
                                               struct rtnl_link *, int,
                                               struct nl_msg **);
-extern int     rtnl_link_change(struct nl_handle *, struct rtnl_link *,
+extern int     rtnl_link_change(struct nl_sock *, struct rtnl_link *,
                                 struct rtnl_link *, int);
 
 /* Name <-> Index Translations */
index 7b5ed248c5b414c29cd5bb73e0f2cfd1a5a6c3b4..d390af1a09b42db0e0e7049035b27d3691b739e9 100644 (file)
@@ -25,7 +25,7 @@ struct rtnl_neigh;
 extern struct rtnl_neigh *rtnl_neigh_alloc(void);
 extern void    rtnl_neigh_put(struct rtnl_neigh *);
 
-extern int     rtnl_neigh_alloc_cache(struct nl_handle *, struct nl_cache **);
+extern int     rtnl_neigh_alloc_cache(struct nl_sock *, struct nl_cache **);
 extern struct rtnl_neigh *rtnl_neigh_get(struct nl_cache *, int,
                                               struct nl_addr *);
 
@@ -35,15 +35,15 @@ extern int  rtnl_neigh_str2state(const char *);
 extern char *  rtnl_neigh_flags2str(int, char *, size_t);
 extern int     rtnl_neigh_str2flag(const char *);
 
-extern int     rtnl_neigh_add(struct nl_handle *, struct rtnl_neigh *, int);
+extern int     rtnl_neigh_add(struct nl_sock *, struct rtnl_neigh *, int);
 extern int     rtnl_neigh_build_add_request(struct rtnl_neigh *, int,
                                             struct nl_msg **);
 
-extern int     rtnl_neigh_change(struct nl_handle *, struct rtnl_neigh *, int);
+extern int     rtnl_neigh_change(struct nl_sock *, struct rtnl_neigh *, int);
 extern int     rtnl_neigh_build_change_request(struct rtnl_neigh *, int,
                                                struct nl_msg **);
 
-extern int     rtnl_neigh_delete(struct nl_handle *, struct rtnl_neigh *, int);
+extern int     rtnl_neigh_delete(struct nl_sock *, struct rtnl_neigh *, int);
 extern int     rtnl_neigh_build_delete_request(struct rtnl_neigh *, int,
                                                struct nl_msg **);
 
index 7120053fa1771cc8c67b318eaecbb79226f2b70e..412c3e942e918897630d0313abc08b006743838d 100644 (file)
@@ -25,7 +25,7 @@ struct rtnl_neightbl;
 extern struct rtnl_neightbl *rtnl_neightbl_alloc(void);
 extern void rtnl_neightbl_put(struct rtnl_neightbl *);
 extern void rtnl_neightbl_free(struct rtnl_neightbl *);
-extern int rtnl_neightbl_alloc_cache(struct nl_handle *, struct nl_cache **);
+extern int rtnl_neightbl_alloc_cache(struct nl_sock *, struct nl_cache **);
 extern struct rtnl_neightbl *rtnl_neightbl_get(struct nl_cache *,
                                               const char *, int);
 extern void rtnl_neightbl_dump(struct rtnl_neightbl *, FILE *,
@@ -34,7 +34,7 @@ extern void rtnl_neightbl_dump(struct rtnl_neightbl *, FILE *,
 extern int rtnl_neightbl_build_change_request(struct rtnl_neightbl *,
                                              struct rtnl_neightbl *,
                                              struct nl_msg **);
-extern int rtnl_neightbl_change(struct nl_handle *, struct rtnl_neightbl *,
+extern int rtnl_neightbl_change(struct nl_sock *, struct rtnl_neightbl *,
                                struct rtnl_neightbl *);
 
 extern void rtnl_neightbl_set_family(struct rtnl_neightbl *, int);
index d3bc99bd4f0d53d04a1c66b5337f3ea62500fb55..5acd6e1c07eaaced76c985701dc6a8a76e667862 100644 (file)
@@ -27,24 +27,24 @@ extern struct nl_object_ops qdisc_obj_ops;
 extern struct rtnl_qdisc *rtnl_qdisc_alloc(void);
 extern void    rtnl_qdisc_put(struct rtnl_qdisc *);
 
-extern int     rtnl_qdisc_alloc_cache(struct nl_handle *, struct nl_cache **);
+extern int     rtnl_qdisc_alloc_cache(struct nl_sock *, struct nl_cache **);
 extern struct rtnl_qdisc *rtnl_qdisc_get(struct nl_cache *, int, uint32_t);
 extern struct rtnl_qdisc *rtnl_qdisc_get_by_parent(struct nl_cache *,
                                                   int, uint32_t);
 
 extern int     rtnl_qdisc_build_add_request(struct rtnl_qdisc *, int,
                                             struct nl_msg **);
-extern int     rtnl_qdisc_add(struct nl_handle *, struct rtnl_qdisc *, int);
+extern int     rtnl_qdisc_add(struct nl_sock *, struct rtnl_qdisc *, int);
 
 extern int     rtnl_qdisc_build_change_request(struct rtnl_qdisc *,
                                                struct rtnl_qdisc *,
                                                struct nl_msg **);
-extern int     rtnl_qdisc_change(struct nl_handle *, struct rtnl_qdisc *,
+extern int     rtnl_qdisc_change(struct nl_sock *, struct rtnl_qdisc *,
                                  struct rtnl_qdisc *);
 
 extern int     rtnl_qdisc_build_delete_request(struct rtnl_qdisc *,
                                                struct nl_msg **);
-extern int     rtnl_qdisc_delete(struct nl_handle *, struct rtnl_qdisc *);
+extern int     rtnl_qdisc_delete(struct nl_sock *, struct rtnl_qdisc *);
 
 extern void    rtnl_qdisc_set_ifindex(struct rtnl_qdisc *, int);
 extern int     rtnl_qdisc_get_ifindex(struct rtnl_qdisc *);
index b3a9b9e9abc2180ce065aab098095d0d1aae33fb..488ecc48d7d09df54f0012bd0e1e544b89069b4f 100644 (file)
@@ -44,7 +44,7 @@ extern struct nl_object_ops route_obj_ops;
 
 extern struct rtnl_route *     rtnl_route_alloc(void);
 extern void    rtnl_route_put(struct rtnl_route *);
-extern int     rtnl_route_alloc_cache(struct nl_handle *, int, int,
+extern int     rtnl_route_alloc_cache(struct nl_sock *, int, int,
                                       struct nl_cache **);
 
 extern void    rtnl_route_get(struct rtnl_route *);
@@ -55,10 +55,10 @@ extern int  rtnl_route_build_msg(struct nl_msg *, struct rtnl_route *);
 
 extern int     rtnl_route_build_add_request(struct rtnl_route *, int,
                                             struct nl_msg **);
-extern int     rtnl_route_add(struct nl_handle *, struct rtnl_route *, int);
+extern int     rtnl_route_add(struct nl_sock *, struct rtnl_route *, int);
 extern int     rtnl_route_build_del_request(struct rtnl_route *, int,
                                             struct nl_msg **);
-extern int     rtnl_route_delete(struct nl_handle *, struct rtnl_route *, int);
+extern int     rtnl_route_delete(struct nl_sock *, struct rtnl_route *, int);
 
 extern void    rtnl_route_set_table(struct rtnl_route *, uint32_t);
 extern uint32_t        rtnl_route_get_table(struct rtnl_route *);
index b12479aec3c57f15bdd2a7b5c3939f3458274838..f551a5d382cdabdffeeeab4da2e376f0af37e631 100644 (file)
@@ -6,7 +6,7 @@
  *     License as published by the Free Software Foundation version 2.1
  *     of the License.
  *
- * Copyright (c) 2003-2006 Thomas Graf <tgraf@suug.ch>
+ * Copyright (c) 2003-2008 Thomas Graf <tgraf@suug.ch>
  */
 
 #ifndef NETLINK_RTNL_H_
@@ -49,7 +49,7 @@ extern "C" {
 
 
 /* General */
-extern int             nl_rtgen_request(struct nl_handle *, int, int, int);
+extern int             nl_rtgen_request(struct nl_sock *, int, int, int);
 
 /* Routing Type Translations */
 extern char *          nl_rtntype2str(int, char *, size_t);
index 2602f77f538f5096598c6fecd7da4f92fd230b0f..928dc0f174846cd7afc9cb92a5d2eb1cc7f89a45 100644 (file)
@@ -27,16 +27,16 @@ struct rtnl_rule;
 extern struct rtnl_rule *      rtnl_rule_alloc(void);
 extern void                    rtnl_rule_put(struct rtnl_rule *);
 
-extern int     rtnl_rule_alloc_cache(struct nl_handle *, int,
+extern int     rtnl_rule_alloc_cache(struct nl_sock *, int,
                                      struct nl_cache **);
 extern void rtnl_rule_dump(struct rtnl_rule *, FILE *, struct nl_dump_params *);
 
 extern int     rtnl_rule_build_add_request(struct rtnl_rule *, int,
                                            struct nl_msg **);
-extern int rtnl_rule_add(struct nl_handle *, struct rtnl_rule *, int);
+extern int rtnl_rule_add(struct nl_sock *, struct rtnl_rule *, int);
 extern int     rtnl_rule_build_delete_request(struct rtnl_rule *, int,
                                               struct nl_msg **);
-extern int rtnl_rule_delete(struct nl_handle *, struct rtnl_rule *, int);
+extern int rtnl_rule_delete(struct nl_sock *, struct rtnl_rule *, int);
 
 
 /* attribute modification */
index 038df7a769d5ab808de7250cc5dfa6c3e1d3b73e..68477e41f1e7b6fd9f443febfe68ce51aa2ee063 100644 (file)
@@ -6,7 +6,7 @@
  *     License as published by the Free Software Foundation version 2.1
  *     of the License.
  *
- * Copyright (c) 2003-2006 Thomas Graf <tgraf@suug.ch>
+ * Copyright (c) 2003-2008 Thomas Graf <tgraf@suug.ch>
  */
 
 #ifndef NETLINK_SOCKET_H_
 extern "C" {
 #endif
 
-extern struct nl_handle *      nl_handle_alloc(void);
-extern struct nl_handle *      nl_handle_alloc_cb(struct nl_cb *);
-extern void                    nl_handle_destroy(struct nl_handle *);
+/* backwards compatibility for now */
+#define nl_handle      nl_sock
 
-extern uint32_t                        nl_socket_get_local_port(struct nl_handle *);
-extern void                    nl_socket_set_local_port(struct nl_handle *,
+extern struct nl_sock *                nl_socket_alloc(void);
+extern struct nl_sock *                nl_socket_alloc_cb(struct nl_cb *);
+extern void                    nl_socket_free(struct nl_sock *);
+
+extern uint32_t                        nl_socket_get_local_port(struct nl_sock *);
+extern void                    nl_socket_set_local_port(struct nl_sock *,
                                                         uint32_t);
 
-extern int                     nl_socket_add_membership(struct nl_handle *,
+extern int                     nl_socket_add_membership(struct nl_sock *,
                                                         int);
-extern int                     nl_socket_drop_membership(struct nl_handle *,
+extern int                     nl_socket_drop_membership(struct nl_sock *,
                                                          int);
-extern void                    nl_join_groups(struct nl_handle *, int);
+extern void                    nl_join_groups(struct nl_sock *, int);
 
-extern uint32_t                        nl_socket_get_peer_port(struct nl_handle *);
-extern void                    nl_socket_set_peer_port(struct nl_handle *,
+extern uint32_t                        nl_socket_get_peer_port(struct nl_sock *);
+extern void                    nl_socket_set_peer_port(struct nl_sock *,
                                                        uint32_t);
 
-extern struct nl_cb *          nl_socket_get_cb(struct nl_handle *);
-extern void                    nl_socket_set_cb(struct nl_handle *,
+extern struct nl_cb *          nl_socket_get_cb(struct nl_sock *);
+extern void                    nl_socket_set_cb(struct nl_sock *,
                                                 struct nl_cb *);
-extern int                     nl_socket_modify_cb(struct nl_handle *,
+extern int                     nl_socket_modify_cb(struct nl_sock *,
                                                    enum nl_cb_type,
                                                    enum nl_cb_kind,
                                                    nl_recvmsg_msg_cb_t,
                                                    void *);
 
-extern int                     nl_set_buffer_size(struct nl_handle *,
+extern int                     nl_set_buffer_size(struct nl_sock *,
                                                   int, int);
-extern int                     nl_set_passcred(struct nl_handle *, int);
-extern int                     nl_socket_recv_pktinfo(struct nl_handle *, int);
+extern int                     nl_set_passcred(struct nl_sock *, int);
+extern int                     nl_socket_recv_pktinfo(struct nl_sock *, int);
 
-extern void                    nl_disable_sequence_check(struct nl_handle *);
-extern unsigned int            nl_socket_use_seq(struct nl_handle *);
+extern void                    nl_disable_sequence_check(struct nl_sock *);
+extern unsigned int            nl_socket_use_seq(struct nl_sock *);
 
-extern int                     nl_socket_get_fd(struct nl_handle *);
-extern int                     nl_socket_set_nonblocking(struct nl_handle *);
-extern void                    nl_socket_enable_msg_peek(struct nl_handle *);
-extern void                    nl_socket_disable_msg_peek(struct nl_handle *);
+extern int                     nl_socket_get_fd(struct nl_sock *);
+extern int                     nl_socket_set_nonblocking(struct nl_sock *);
+extern void                    nl_socket_enable_msg_peek(struct nl_sock *);
+extern void                    nl_socket_disable_msg_peek(struct nl_sock *);
 
 #ifdef __cplusplus
 }
index bc360f0a6f358d41f46814f4138a0001062f0c23..4dcc1a463ebb7bb7cec3e74dbdbbe3a5df582ce6 100644 (file)
@@ -186,7 +186,7 @@ struct nl_cache *nl_cache_alloc(struct nl_cache_ops *ops)
        return cache;
 }
 
-int nl_cache_alloc_and_fill(struct nl_cache_ops *ops, struct nl_handle *sock,
+int nl_cache_alloc_and_fill(struct nl_cache_ops *ops, struct nl_sock *sock,
                            struct nl_cache **result)
 {
        struct nl_cache *cache;
@@ -427,7 +427,7 @@ struct nl_object *nl_cache_search(struct nl_cache *cache,
 
 /**
  * Request a full dump from the kernel to fill a cache
- * @arg handle         Netlink handle
+ * @arg sk             Netlink socket.
  * @arg cache          Cache subjected to be filled.
  *
  * Send a dumping request to the kernel causing it to dump all objects
@@ -436,7 +436,7 @@ struct nl_object *nl_cache_search(struct nl_cache *cache,
  * Use nl_cache_pickup() to read the objects from the socket and fill them
  * into a cache.
  */
-int nl_cache_request_full_dump(struct nl_handle *handle, struct nl_cache *cache)
+int nl_cache_request_full_dump(struct nl_sock *sk, struct nl_cache *cache)
 {
        NL_DBG(2, "Requesting dump from kernel for cache %p <%s>...\n",
                  cache, nl_cache_name(cache));
@@ -444,7 +444,7 @@ int nl_cache_request_full_dump(struct nl_handle *handle, struct nl_cache *cache)
        if (cache->c_ops->co_request_update == NULL)
                return -NLE_OPNOTSUPP;
 
-       return cache->c_ops->co_request_update(cache, handle);
+       return cache->c_ops->co_request_update(cache, sk);
 }
 
 /** @cond SKIP */
@@ -461,7 +461,7 @@ static int update_msg_parser(struct nl_msg *msg, void *arg)
 }
 /** @endcond */
 
-int __cache_pickup(struct nl_handle *handle, struct nl_cache *cache,
+int __cache_pickup(struct nl_sock *sk, struct nl_cache *cache,
                   struct nl_parser_param *param)
 {
        int err;
@@ -474,13 +474,13 @@ int __cache_pickup(struct nl_handle *handle, struct nl_cache *cache,
        NL_DBG(1, "Picking up answer for cache %p <%s>...\n",
                  cache, nl_cache_name(cache));
 
-       cb = nl_cb_clone(handle->h_cb);
+       cb = nl_cb_clone(sk->s_cb);
        if (cb == NULL)
                return -NLE_NOMEM;
 
        nl_cb_set(cb, NL_CB_VALID, NL_CB_CUSTOM, update_msg_parser, &x);
 
-       err = nl_recvmsgs(handle, cb);
+       err = nl_recvmsgs(sk, cb);
        if (err < 0)
                NL_DBG(2, "While picking up for %p <%s>, recvmsgs() returned " \
                       "%d: %s", cache, nl_cache_name(cache),
@@ -498,7 +498,7 @@ static int pickup_cb(struct nl_object *c, struct nl_parser_param *p)
 
 /**
  * Pickup a netlink dump response and put it into a cache.
- * @arg handle         Netlink handle.
+ * @arg sk             Netlink socket.
  * @arg cache          Cache to put items into.
  *
  * Waits for netlink messages to arrive, parses them and puts them into
@@ -506,14 +506,14 @@ static int pickup_cb(struct nl_object *c, struct nl_parser_param *p)
  *
  * @return 0 on success or a negative error code.
  */
-int nl_cache_pickup(struct nl_handle *handle, struct nl_cache *cache)
+int nl_cache_pickup(struct nl_sock *sk, struct nl_cache *cache)
 {
        struct nl_parser_param p = {
                .pp_cb = pickup_cb,
                .pp_arg = cache,
        };
 
-       return __cache_pickup(handle, cache, &p);
+       return __cache_pickup(sk, cache, &p);
 }
 
 static int cache_include(struct nl_cache *cache, struct nl_object *obj,
@@ -578,7 +578,7 @@ static int resync_cb(struct nl_object *c, struct nl_parser_param *p)
        return nl_cache_include(ca->ca_cache, c, ca->ca_change);
 }
 
-int nl_cache_resync(struct nl_handle *handle, struct nl_cache *cache,
+int nl_cache_resync(struct nl_sock *sk, struct nl_cache *cache,
                    change_func_t change_cb)
 {
        struct nl_object *obj, *next;
@@ -597,11 +597,11 @@ int nl_cache_resync(struct nl_handle *handle, struct nl_cache *cache,
        /* Mark all objects so we can see if some of them are obsolete */
        nl_cache_mark_all(cache);
 
-       err = nl_cache_request_full_dump(handle, cache);
+       err = nl_cache_request_full_dump(sk, cache);
        if (err < 0)
                goto errout;
 
-       err = __cache_pickup(handle, cache, &p);
+       err = __cache_pickup(sk, cache, &p);
        if (err < 0)
                goto errout;
 
@@ -669,7 +669,7 @@ int nl_cache_parse_and_add(struct nl_cache *cache, struct nl_msg *msg)
 
 /**
  * (Re)fill a cache with the contents in the kernel.
- * @arg handle         netlink handle
+ * @arg sk             Netlink socket.
  * @arg cache          cache to update
  *
  * Clears the specified cache and fills it with the current state in
@@ -677,11 +677,11 @@ int nl_cache_parse_and_add(struct nl_cache *cache, struct nl_msg *msg)
  *
  * @return 0 or a negative error code.
  */
-int nl_cache_refill(struct nl_handle *handle, struct nl_cache *cache)
+int nl_cache_refill(struct nl_sock *sk, struct nl_cache *cache)
 {
        int err;
 
-       err = nl_cache_request_full_dump(handle, cache);
+       err = nl_cache_request_full_dump(sk, cache);
        if (err < 0)
                return err;
 
@@ -689,7 +689,7 @@ int nl_cache_refill(struct nl_handle *handle, struct nl_cache *cache)
               cache, nl_cache_name(cache));
        nl_cache_clear(cache);
 
-       return nl_cache_pickup(handle, cache);
+       return nl_cache_pickup(sk, cache);
 }
 
 /** @} */
index 590979539c74395534d709c662aae4b4537ca18d..8dbfaf4c7022dfeb0b91b10277bcd484e858fb16 100644 (file)
@@ -140,26 +140,26 @@ found:
 
 /**
  * Allocate new cache manager
- * @arg handle         Netlink socket/handle to be used
+ * @arg sk             Netlink socket.
  * @arg protocol       Netlink Protocol this manager is used for
  * @arg flags          Flags
  *
  * @return Newly allocated cache manager or NULL on failure.
  */
-int nl_cache_mngr_alloc(struct nl_handle *handle, int protocol, int flags,
+int nl_cache_mngr_alloc(struct nl_sock *sk, int protocol, int flags,
                        struct nl_cache_mngr **result)
 {
        struct nl_cache_mngr *mngr;
        int err = -NLE_NOMEM;
 
-       if (handle == NULL)
+       if (sk == NULL)
                BUG();
 
        mngr = calloc(1, sizeof(*mngr));
        if (!mngr)
                goto errout;
 
-       mngr->cm_handle = handle;
+       mngr->cm_handle = sk;
        mngr->cm_nassocs = 32;
        mngr->cm_protocol = protocol;
        mngr->cm_flags = flags;
index 8fee8c852f34b862f8654d09fc6a3e7448aee80c..d7ee2c68dd1f0693acc7028523cdd76c76226cf0 100644 (file)
--- a/lib/doc.c
+++ b/lib/doc.c
@@ -19,7 +19,7 @@
  * Almost all subsystem provide a function to allocate a new cache
  * of some form. The function usually looks like this:
  * @code
- * struct nl_cache *<object name>_alloc_cache(struct nl_handle *handle)
+ * struct nl_cache *<object name>_alloc_cache(struct nl_sock *sk);
  * @endcode
  *
  * These functions allocate a new cache for the own object type,
index b7692460c266ae7c21ae578524931ebe20fce074..00f3a427efdfda70dbde7beca08cabe74cf61c33 100644 (file)
@@ -251,7 +251,7 @@ errout:
 
 /**
  * Perform FIB Lookup
- * @arg handle         Netlink handle.
+ * @arg sk             Netlink socket.
  * @arg req            Lookup request object.
  * @arg cache          Cache for result.
  *
@@ -260,7 +260,7 @@ errout:
  *
  * @return 0 on success or a negative error code.
  */
-int flnl_lookup(struct nl_handle *handle, struct flnl_request *req,
+int flnl_lookup(struct nl_sock *sk, struct flnl_request *req,
                struct nl_cache *cache)
 {
        struct nl_msg *msg;
@@ -269,12 +269,12 @@ int flnl_lookup(struct nl_handle *handle, struct flnl_request *req,
        if ((err = flnl_lookup_build_request(req, 0, &msg)) < 0)
                return err;
 
-       err = nl_send_auto_complete(handle, msg);
+       err = nl_send_auto_complete(sk, msg);
        nlmsg_free(msg);
        if (err < 0)
                return err;
 
-       return nl_cache_pickup(handle, cache);
+       return nl_cache_pickup(sk, cache);
 }
 
 /** @} */
index fc08e148fc45e112eeb97a9349c18e7c17232a36..f60cd1af06eac81e7b42f2bb5476b6cc8b28999e 100644 (file)
@@ -31,7 +31,7 @@
 static struct nl_cache_ops genl_ctrl_ops;
 /** @endcond */
 
-static int ctrl_request_update(struct nl_cache *c, struct nl_handle *h)
+static int ctrl_request_update(struct nl_cache *c, struct nl_sock *h)
 {
        return genl_send_simple(h, GENL_ID_CTRL, CTRL_CMD_GETFAMILY,
                                CTRL_VERSION, NLM_F_DUMP);
@@ -143,7 +143,7 @@ errout:
  * @{
  */
 
-int genl_ctrl_alloc_cache(struct nl_handle *sock, struct nl_cache **result)
+int genl_ctrl_alloc_cache(struct nl_sock *sock, struct nl_cache **result)
 {
        return nl_cache_alloc_and_fill(&genl_ctrl_ops, sock, result);
 }
@@ -216,7 +216,7 @@ struct genl_family *genl_ctrl_search_by_name(struct nl_cache *cache,
 
 /**
  * Resolve generic netlink family name to its identifier
- * @arg handle         Netlink Handle
+ * @arg sk             Netlink socket.
  * @arg name           Name of generic netlink family
  *
  * Resolves the generic netlink family name to its identifer and returns
@@ -224,13 +224,13 @@ struct genl_family *genl_ctrl_search_by_name(struct nl_cache *cache,
  *
  * @return A positive identifier or a negative error code.
  */
-int genl_ctrl_resolve(struct nl_handle *handle, const char *name)
+int genl_ctrl_resolve(struct nl_sock *sk, const char *name)
 {
        struct nl_cache *cache;
        struct genl_family *family;
        int err;
 
-       if ((err = genl_ctrl_alloc_cache(handle, &cache)) < 0)
+       if ((err = genl_ctrl_alloc_cache(sk, &cache)) < 0)
                return err;
 
        family = genl_ctrl_search_by_name(cache, name);
index cee7efde5ada526d11d27e2a7be49a056ee170d4..4db17e99f8482dfd513fb6703958526324782e0f 100644 (file)
@@ -6,7 +6,7 @@
  *     License as published by the Free Software Foundation version 2.1
  *     of the License.
  *
- * Copyright (c) 2003-2006 Thomas Graf <tgraf@suug.ch>
+ * Copyright (c) 2003-2008 Thomas Graf <tgraf@suug.ch>
  */
 
 /**
  * #include <netlink/genl/genl.h>
  * #include <netlink/genl/ctrl.h>
  *
- * struct nl_handle *sock;
+ * struct nl_sock *sock;
  * struct nl_msg *msg;
  * int family;
  *
  * // Allocate a new netlink socket
- * sock = nl_handle_alloc();
+ * sock = nl_socket_alloc();
  *
  * // Connect to generic netlink socket on kernel side
  * genl_connect(sock);
  * @{
  */
 
-int genl_connect(struct nl_handle *handle)
+int genl_connect(struct nl_sock *sk)
 {
-       return nl_connect(handle, NETLINK_GENERIC);
+       return nl_connect(sk, NETLINK_GENERIC);
 }
 
 /** @} */
@@ -114,7 +114,7 @@ int genl_connect(struct nl_handle *handle)
 
 /**
  * Send trivial generic netlink message
- * @arg handle         Netlink handle.
+ * @arg sk             Netlink socket.
  * @arg family         Generic netlink family
  * @arg cmd            Command
  * @arg version                Version
@@ -125,7 +125,7 @@ int genl_connect(struct nl_handle *handle)
  *
  * @return 0 on success or a negative error code.
  */
-int genl_send_simple(struct nl_handle *handle, int family, int cmd,
+int genl_send_simple(struct nl_sock *sk, int family, int cmd,
                     int version, int flags)
 {
        struct genlmsghdr hdr = {
@@ -133,7 +133,7 @@ int genl_send_simple(struct nl_handle *handle, int family, int cmd,
                .version = version,
        };
 
-       return nl_send_simple(handle, family, flags, &hdr, sizeof(hdr));
+       return nl_send_simple(sk, family, flags, &hdr, sizeof(hdr));
 }
 
 /** @} */
index 76443525180b54d145d829c860e388f6014cf090..0ebe74d79983c1573555f31bfe7d3c52edc5110c 100644 (file)
@@ -234,12 +234,12 @@ static int __genl_ops_resolve(struct nl_cache *ctrl, struct genl_ops *ops)
        return -NLE_OBJ_NOTFOUND;
 }
 
-int genl_ops_resolve(struct nl_handle *handle, struct genl_ops *ops)
+int genl_ops_resolve(struct nl_sock *sk, struct genl_ops *ops)
 {
        struct nl_cache *ctrl;
        int err;
 
-       if ((err = genl_ctrl_alloc_cache(handle, &ctrl)) < 0)
+       if ((err = genl_ctrl_alloc_cache(sk, &ctrl)) < 0)
                goto errout;
 
        err = __genl_ops_resolve(ctrl, ops);
@@ -249,13 +249,13 @@ errout:
        return err;
 }
 
-int genl_mngt_resolve(struct nl_handle *handle)
+int genl_mngt_resolve(struct nl_sock *sk)
 {
        struct nl_cache *ctrl;
        struct genl_ops *ops;
        int err = 0;
 
-       if ((err = genl_ctrl_alloc_cache(handle, &ctrl)) < 0)
+       if ((err = genl_ctrl_alloc_cache(sk, &ctrl)) < 0)
                goto errout;
 
        nl_list_for_each_entry(ops, &genl_ops_list, o_list) {
index 480df596f6f753f126dddb8240d8ec8ab76d90a0..f21d35a3af905d273057ff1024157bdb07f9a077 100644 (file)
@@ -412,7 +412,7 @@ int nl_cb_err(struct nl_cb *cb, enum nl_cb_kind kind,
  * @arg func           replacement callback for nl_recvmsgs()
  */
 void nl_cb_overwrite_recvmsgs(struct nl_cb *cb,
-                             int (*func)(struct nl_handle *, struct nl_cb *))
+                             int (*func)(struct nl_sock *, struct nl_cb *))
 {
        cb->cb_recvmsgs_ow = func;
 }
@@ -423,7 +423,7 @@ void nl_cb_overwrite_recvmsgs(struct nl_cb *cb,
  * @arg func           replacement callback for nl_recv()
  */
 void nl_cb_overwrite_recv(struct nl_cb *cb,
-                         int (*func)(struct nl_handle *, struct sockaddr_nl *,
+                         int (*func)(struct nl_sock *, struct sockaddr_nl *,
                                      unsigned char **, struct ucred **))
 {
        cb->cb_recv_ow = func;
@@ -435,7 +435,7 @@ void nl_cb_overwrite_recv(struct nl_cb *cb,
  * @arg func           replacement callback for nl_send()
  */
 void nl_cb_overwrite_send(struct nl_cb *cb,
-                         int (*func)(struct nl_handle *, struct nl_msg *))
+                         int (*func)(struct nl_sock *, struct nl_msg *))
 {
        cb->cb_send_ow = func;
 }
index cdd50a75f872e096a102c1ff8a38ca4dca969c54..beb1dc506ca72bbecf31595640c4a0bc29de6e48 100644 (file)
@@ -374,15 +374,15 @@ errout:
        return err;
 }
 
-int nfnl_ct_dump_request(struct nl_handle *h)
+int nfnl_ct_dump_request(struct nl_sock *sk)
 {
-       return nfnl_send_simple(h, NFNL_SUBSYS_CTNETLINK, IPCTNL_MSG_CT_GET,
+       return nfnl_send_simple(sk, NFNL_SUBSYS_CTNETLINK, IPCTNL_MSG_CT_GET,
                                NLM_F_DUMP, AF_UNSPEC, 0);
 }
 
-static int ct_request_update(struct nl_cache *c, struct nl_handle *h)
+static int ct_request_update(struct nl_cache *cache, struct nl_sock *sk)
 {
-       return nfnl_ct_dump_request(h);
+       return nfnl_ct_dump_request(sk);
 }
 
 static int nfnl_ct_build_tuple(struct nl_msg *msg, const struct nfnl_ct *ct,
@@ -480,7 +480,7 @@ int nfnl_ct_build_add_request(const struct nfnl_ct *ct, int flags,
        return nfnl_ct_build_message(ct, IPCTNL_MSG_CT_NEW, flags, result);
 }
 
-int nfnl_ct_add(struct nl_handle *h, const struct nfnl_ct *ct, int flags)
+int nfnl_ct_add(struct nl_sock *sk, const struct nfnl_ct *ct, int flags)
 {
        struct nl_msg *msg;
        int err;
@@ -488,12 +488,12 @@ int nfnl_ct_add(struct nl_handle *h, const struct nfnl_ct *ct, int flags)
        if ((err = nfnl_ct_build_add_request(ct, flags, &msg)) < 0)
                return err;
 
-       err = nl_send_auto_complete(h, msg);
+       err = nl_send_auto_complete(sk, msg);
        nlmsg_free(msg);
        if (err < 0)
                return err;
 
-       return nl_wait_for_ack(h);
+       return nl_wait_for_ack(sk);
 }
 
 int nfnl_ct_build_delete_request(const struct nfnl_ct *ct, int flags,
@@ -502,7 +502,7 @@ int nfnl_ct_build_delete_request(const struct nfnl_ct *ct, int flags,
        return nfnl_ct_build_message(ct, IPCTNL_MSG_CT_DELETE, flags, result);
 }
 
-int nfnl_ct_del(struct nl_handle *h, const struct nfnl_ct *ct, int flags)
+int nfnl_ct_del(struct nl_sock *sk, const struct nfnl_ct *ct, int flags)
 {
        struct nl_msg *msg;
        int err;
@@ -510,12 +510,12 @@ int nfnl_ct_del(struct nl_handle *h, const struct nfnl_ct *ct, int flags)
        if ((err = nfnl_ct_build_delete_request(ct, flags, &msg)) < 0)
                return err;
 
-       err = nl_send_auto_complete(h, msg);
+       err = nl_send_auto_complete(sk, msg);
        nlmsg_free(msg);
        if (err < 0)
                return err;
 
-       return nl_wait_for_ack(h);
+       return nl_wait_for_ack(sk);
 }
 
 int nfnl_ct_build_query_request(const struct nfnl_ct *ct, int flags,
@@ -524,7 +524,7 @@ int nfnl_ct_build_query_request(const struct nfnl_ct *ct, int flags,
        return nfnl_ct_build_message(ct, IPCTNL_MSG_CT_GET, flags, result);
 }
 
-int nfnl_ct_query(struct nl_handle *h, const struct nfnl_ct *ct, int flags)
+int nfnl_ct_query(struct nl_sock *sk, const struct nfnl_ct *ct, int flags)
 {
        struct nl_msg *msg;
        int err;
@@ -532,12 +532,12 @@ int nfnl_ct_query(struct nl_handle *h, const struct nfnl_ct *ct, int flags)
        if ((err = nfnl_ct_build_query_request(ct, flags, &msg)) < 0)
                return err;
 
-       err = nl_send_auto_complete(h, msg);
+       err = nl_send_auto_complete(sk, msg);
        nlmsg_free(msg);
        if (err < 0)
                return err;
 
-       return nl_wait_for_ack(h);
+       return nl_wait_for_ack(sk);
 }
 
 /**
@@ -547,7 +547,7 @@ int nfnl_ct_query(struct nl_handle *h, const struct nfnl_ct *ct, int flags)
 
 /**
  * Build a conntrack cache holding all conntrack currently in the kernel
- * @arg handle         netlink handle
+ * @arg sk             Netlink socket.
  * @arg result         Pointer to store resulting cache.
  *
  * Allocates a new cache, initializes it properly and updates it to
@@ -555,9 +555,9 @@ int nfnl_ct_query(struct nl_handle *h, const struct nfnl_ct *ct, int flags)
  *
  * @return 0 on success or a negative error code.
  */
-int nfnl_ct_alloc_cache(struct nl_handle *sock, struct nl_cache **result)
+int nfnl_ct_alloc_cache(struct nl_sock *sk, struct nl_cache **result)
 {
-       return nl_cache_alloc_and_fill(&nfnl_ct_ops, sock, result);
+       return nl_cache_alloc_and_fill(&nfnl_ct_ops, sk, result);
 }
 
 /** @} */
index 0cfbc87fe6a4eb4056f76e001fae382d35c08efe..6d3e23ac82f355484c42f0d5c7db450c04cf85cc 100644 (file)
@@ -54,16 +54,16 @@ nla_put_failure:
        return -NLE_MSGSIZE;
 }
 
-static int send_log_request(struct nl_handle *handle, struct nl_msg *msg)
+static int send_log_request(struct nl_sock *sk, struct nl_msg *msg)
 {
        int err;
 
-       err = nl_send_auto_complete(handle, msg);
+       err = nl_send_auto_complete(sk, msg);
        nlmsg_free(msg);
        if (err < 0)
                return err;
 
-       return nl_wait_for_ack(handle);
+       return nl_wait_for_ack(sk);
 }
 
 int nfnl_log_build_pf_bind(uint8_t pf, struct nl_msg **result)
@@ -71,7 +71,7 @@ int nfnl_log_build_pf_bind(uint8_t pf, struct nl_msg **result)
        return build_log_cmd_request(pf, 0, NFULNL_CFG_CMD_PF_BIND, result);
 }
 
-int nfnl_log_pf_bind(struct nl_handle *nlh, uint8_t pf)
+int nfnl_log_pf_bind(struct nl_sock *nlh, uint8_t pf)
 {
        struct nl_msg *msg;
        int err;
@@ -87,7 +87,7 @@ int nfnl_log_build_pf_unbind(uint8_t pf, struct nl_msg **result)
        return build_log_cmd_request(pf, 0, NFULNL_CFG_CMD_PF_UNBIND, result);
 }
 
-int nfnl_log_pf_unbind(struct nl_handle *nlh, uint8_t pf)
+int nfnl_log_pf_unbind(struct nl_sock *nlh, uint8_t pf)
 {
        struct nl_msg *msg;
        int err;
@@ -179,7 +179,7 @@ nla_put_failure:
        return -NLE_MSGSIZE;
 }
 
-int nfnl_log_create(struct nl_handle *nlh, const struct nfnl_log *log)
+int nfnl_log_create(struct nl_sock *nlh, const struct nfnl_log *log)
 {
        struct nl_msg *msg;
        int err;
@@ -196,7 +196,7 @@ int nfnl_log_build_change_request(const struct nfnl_log *log,
        return nfnl_log_build_request(log, result);
 }
 
-int nfnl_log_change(struct nl_handle *nlh, const struct nfnl_log *log)
+int nfnl_log_change(struct nl_sock *nlh, const struct nfnl_log *log)
 {
        struct nl_msg *msg;
        int err;
@@ -217,7 +217,7 @@ int nfnl_log_build_delete_request(const struct nfnl_log *log,
                                     NFULNL_CFG_CMD_UNBIND, result);
 }
 
-int nfnl_log_delete(struct nl_handle *nlh, const struct nfnl_log *log)
+int nfnl_log_delete(struct nl_sock *nlh, const struct nfnl_log *log)
 {
        struct nl_msg *msg;
        int err;
index 2441f6968f2e75107820b33cfb14e5e71582d2de..b687636f22c9a32af0e133d5300b13d631160ed0 100644 (file)
@@ -47,7 +47,7 @@
  * nla_put_u32(msg, 1, 0x10);
  *
  * // Message is ready to be sent.
- * nl_send_auto_complete(nl_handle, msg);
+ * nl_send_auto_complete(sk, msg);
  *
  * // All done? Free the message.
  * nlmsg_free(msg);
@@ -57,7 +57,7 @@
  * @code
  * // For trivial messages not requiring any subsys specific header or
  * // attributes, nfnl_send_simple() may be used to send messages directly.
- * nfnl_send_simple(nl_handle, SUBSYS, TYPE, 0, FAMILY, RES_ID);
+ * nfnl_send_simple(sk, SUBSYS, TYPE, 0, FAMILY, RES_ID);
  * @endcode
  * @{
  */
@@ -73,7 +73,7 @@
 
 /**
  * Create and connect netfilter netlink socket.
- * @arg handle         Netlink handle.
+ * @arg sk             Netlink socket.
  *
  * Creates a NETLINK_NETFILTER netlink socket, binds the socket and
  * issues a connection attempt.
@@ -82,9 +82,9 @@
  *
  * @return 0 on success or a negative error code.
  */
-int nfnl_connect(struct nl_handle *handle)
+int nfnl_connect(struct nl_sock *sk)
 {
-       return nl_connect(handle, NETLINK_NETFILTER);
+       return nl_connect(sk, NETLINK_NETFILTER);
 }
 
 /** @} */
@@ -96,7 +96,7 @@ int nfnl_connect(struct nl_handle *handle)
 
 /**
  * Send trivial netfilter netlink message
- * @arg handle         Netlink handle.
+ * @arg sk             Netlink socket.
  * @arg subsys_id      nfnetlink subsystem
  * @arg type           nfnetlink message type
  * @arg flags          message flags
@@ -105,7 +105,7 @@ int nfnl_connect(struct nl_handle *handle)
  *
  * @return Newly allocated netlink message or NULL.
  */
-int nfnl_send_simple(struct nl_handle *handle, uint8_t subsys_id, uint8_t type,
+int nfnl_send_simple(struct nl_sock *sk, uint8_t subsys_id, uint8_t type,
                     int flags, uint8_t family, uint16_t res_id)
 {
        struct nfgenmsg hdr = {
@@ -114,7 +114,7 @@ int nfnl_send_simple(struct nl_handle *handle, uint8_t subsys_id, uint8_t type,
                .res_id = htons(res_id),
        };
 
-       return nl_send_simple(handle, NFNLMSG_TYPE(subsys_id, type), flags,
+       return nl_send_simple(sk, NFNLMSG_TYPE(subsys_id, type), flags,
                              &hdr, sizeof(hdr));
 }
 
index 7f31c666dd93b08d6a81eaf75a4fd63585210886..3af2a48a37acfd170e8e6843eb42eca904ff1b29 100644 (file)
 #include <netlink/netfilter/nfnl.h>
 #include <netlink/netfilter/queue.h>
 
-static int send_queue_request(struct nl_handle *handle, struct nl_msg *msg)
+static int send_queue_request(struct nl_sock *sk, struct nl_msg *msg)
 {
        int err;
 
-       err = nl_send_auto_complete(handle, msg);
+       err = nl_send_auto_complete(sk, msg);
        nlmsg_free(msg);
        if (err < 0)
                return err;
 
-       return nl_wait_for_ack(handle);
+       return nl_wait_for_ack(sk);
 }
 
 /**
@@ -71,7 +71,7 @@ int nfnl_queue_build_pf_bind(uint8_t pf, struct nl_msg **result)
        return build_queue_cmd_request(pf, 0, NFQNL_CFG_CMD_PF_BIND, result);
 }
 
-int nfnl_queue_pf_bind(struct nl_handle *nlh, uint8_t pf)
+int nfnl_queue_pf_bind(struct nl_sock *nlh, uint8_t pf)
 {
        struct nl_msg *msg;
        int err;
@@ -87,7 +87,7 @@ int nfnl_queue_build_pf_unbind(uint8_t pf, struct nl_msg **result)
        return build_queue_cmd_request(pf, 0, NFQNL_CFG_CMD_PF_UNBIND, result);
 }
 
-int nfnl_queue_pf_unbind(struct nl_handle *nlh, uint8_t pf)
+int nfnl_queue_pf_unbind(struct nl_sock *nlh, uint8_t pf)
 {
        struct nl_msg *msg;
        int err;
@@ -169,7 +169,7 @@ nla_put_failure:
        return -NLE_MSGSIZE;
 }
 
-int nfnl_queue_create(struct nl_handle *nlh, const struct nfnl_queue *queue)
+int nfnl_queue_create(struct nl_sock *nlh, const struct nfnl_queue *queue)
 {
        struct nl_msg *msg;
        int err;
@@ -186,7 +186,7 @@ int nfnl_queue_build_change_request(const struct nfnl_queue *queue,
        return nfnl_queue_build_request(queue, result);
 }
 
-int nfnl_queue_change(struct nl_handle *nlh, const struct nfnl_queue *queue)
+int nfnl_queue_change(struct nl_sock *nlh, const struct nfnl_queue *queue)
 {
        struct nl_msg *msg;
        int err;
@@ -207,7 +207,7 @@ int nfnl_queue_build_delete_request(const struct nfnl_queue *queue,
                                       NFQNL_CFG_CMD_UNBIND, result);
 }
 
-int nfnl_queue_delete(struct nl_handle *nlh, const struct nfnl_queue *queue)
+int nfnl_queue_delete(struct nl_sock *nlh, const struct nfnl_queue *queue)
 {
        struct nl_msg *msg;
        int err;
index 6d6ca739e8e7881dc40c2b5edece29d7af2dc600..ec461a5f63f42734f6cdef61ae2ab27a9111dc26 100644 (file)
@@ -194,7 +194,7 @@ nla_put_failure:
        return NULL;
 }
 
-int nfnl_queue_msg_send_verdict(struct nl_handle *nlh,
+int nfnl_queue_msg_send_verdict(struct nl_sock *nlh,
                                const struct nfnl_queue_msg *msg)
 {
        struct nl_msg *nlmsg;
index ba5262b4b51ca729868ff165efd694ac23976ed1..715dfeb20f78217423cfb1be58bbc1884e5e8c93 100644 (file)
--- a/lib/nl.c
+++ b/lib/nl.c
  * @par 1) Connecting the socket
  * @code
  * // Bind and connect the socket to a protocol, NETLINK_ROUTE in this example.
- * nl_connect(handle, NETLINK_ROUTE);
+ * nl_connect(sk, NETLINK_ROUTE);
  * @endcode
  *
  * @par 2) Sending data
  * // a piece of data to the other netlink peer. This method is not
  * // recommended.
  * const char buf[] = { 0x01, 0x02, 0x03, 0x04 };
- * nl_sendto(handle, buf, sizeof(buf));
+ * nl_sendto(sk, buf, sizeof(buf));
  *
  * // A more comfortable interface is nl_send() taking a pointer to
  * // a netlink message.
  * struct nl_msg *msg = my_msg_builder();
- * nl_send(handle, nlmsg_hdr(msg));
+ * nl_send(sk, nlmsg_hdr(msg));
  *
  * // nl_sendmsg() provides additional control over the sendmsg() message
  * // header in order to allow more specific addressing of multiple peers etc.
  * struct msghdr hdr = { ... };
- * nl_sendmsg(handle, nlmsg_hdr(msg), &hdr);
+ * nl_sendmsg(sk, nlmsg_hdr(msg), &hdr);
  *
  * // You're probably too lazy to fill out the netlink pid, sequence number
  * // and message flags all the time. nl_send_auto_complete() automatically
  * // extends your message header as needed with an appropriate sequence
- * // number, the netlink pid stored in the netlink handle and the message
+ * // number, the netlink pid stored in the netlink socket and the message
  * // flags NLM_F_REQUEST and NLM_F_ACK
- * nl_send_auto_complete(handle, nlmsg_hdr(msg));
+ * nl_send_auto_complete(sk, nlmsg_hdr(msg));
  *
  * // Simple protocols don't require the complex message construction interface
  * // and may favour nl_send_simple() to easly send a bunch of payload
  * // encapsulated in a netlink message header.
- * nl_send_simple(handle, MY_MSG_TYPE, 0, buf, sizeof(buf));
+ * nl_send_simple(sk, MY_MSG_TYPE, 0, buf, sizeof(buf));
  * @endcode
  *
  * @par 3) Receiving data
  * // content and gives back the pointer to you.
  * struct sockaddr_nl peer;
  * unsigned char *msg;
- * nl_recv(handle, &peer, &msg);
+ * nl_recv(sk, &peer, &msg);
  *
  * // nl_recvmsgs() receives a bunch of messages until the callback system
  * // orders it to state, usually after receving a compolete multi part
  * // message series.
- * nl_recvmsgs(handle, my_callback_configuration);
+ * nl_recvmsgs(sk, my_callback_configuration);
  *
  * // nl_recvmsgs_default() acts just like nl_recvmsg() but uses the callback
- * // configuration stored in the handle.
- * nl_recvmsgs_default(handle);
+ * // configuration stored in the socket.
+ * nl_recvmsgs_default(sk);
  *
  * // In case you want to wait for the ACK to be recieved that you requested
  * // with your latest message, you can call nl_wait_for_ack()
- * nl_wait_for_ack(handle);
+ * nl_wait_for_ack(sk);
  * @endcode
  *
  * @par 4) Closing
  * @code
  * // Close the socket first to release kernel memory
- * nl_close(handle);
+ * nl_close(sk);
  * @endcode
  * 
  * @{
 
 /**
  * Create and connect netlink socket.
- * @arg handle         Netlink handle.
+ * @arg sk             Netlink socket.
  * @arg protocol       Netlink protocol to use.
  *
  * Creates a netlink socket using the specified protocol, binds the socket
  *
  * @return 0 on success or a negative error code.
  */
-int nl_connect(struct nl_handle *handle, int protocol)
+int nl_connect(struct nl_sock *sk, int protocol)
 {
        int err;
        socklen_t addrlen;
 
-       handle->h_fd = socket(AF_NETLINK, SOCK_RAW, protocol);
-       if (handle->h_fd < 0) {
+       sk->s_fd = socket(AF_NETLINK, SOCK_RAW, protocol);
+       if (sk->s_fd < 0) {
                err = -nl_syserr2nlerr(errno);
                goto errout;
        }
 
-       if (!(handle->h_flags & NL_SOCK_BUFSIZE_SET)) {
-               err = nl_set_buffer_size(handle, 0, 0);
+       if (!(sk->s_flags & NL_SOCK_BUFSIZE_SET)) {
+               err = nl_set_buffer_size(sk, 0, 0);
                if (err < 0)
                        goto errout;
        }
 
-       err = bind(handle->h_fd, (struct sockaddr*) &handle->h_local,
-                  sizeof(handle->h_local));
+       err = bind(sk->s_fd, (struct sockaddr*) &sk->s_local,
+                  sizeof(sk->s_local));
        if (err < 0) {
                err = -nl_syserr2nlerr(errno);
                goto errout;
        }
 
-       addrlen = sizeof(handle->h_local);
-       err = getsockname(handle->h_fd, (struct sockaddr *) &handle->h_local,
+       addrlen = sizeof(sk->s_local);
+       err = getsockname(sk->s_fd, (struct sockaddr *) &sk->s_local,
                          &addrlen);
        if (err < 0) {
                err = -nl_syserr2nlerr(errno);
                goto errout;
        }
 
-       if (addrlen != sizeof(handle->h_local)) {
+       if (addrlen != sizeof(sk->s_local)) {
                err = -NLE_NOADDR;
                goto errout;
        }
 
-       if (handle->h_local.nl_family != AF_NETLINK) {
+       if (sk->s_local.nl_family != AF_NETLINK) {
                err = -NLE_AF_NOSUPPORT;
                goto errout;
        }
 
-       handle->h_proto = protocol;
+       sk->s_proto = protocol;
 
        return 0;
 errout:
-       close(handle->h_fd);
-       handle->h_fd = -1;
+       close(sk->s_fd);
+       sk->s_fd = -1;
 
        return err;
 }
 
 /**
  * Close/Disconnect netlink socket.
- * @arg handle         Netlink handle
+ * @arg sk             Netlink socket.
  */
-void nl_close(struct nl_handle *handle)
+void nl_close(struct nl_sock *sk)
 {
-       if (handle->h_fd >= 0) {
-               close(handle->h_fd);
-               handle->h_fd = -1;
+       if (sk->s_fd >= 0) {
+               close(sk->s_fd);
+               sk->s_fd = -1;
        }
 
-       handle->h_proto = 0;
+       sk->s_proto = 0;
 }
 
 /** @} */
@@ -263,17 +263,17 @@ void nl_close(struct nl_handle *handle)
 
 /**
  * Send raw data over netlink socket.
- * @arg handle         Netlink handle.
+ * @arg sk             Netlink socket.
  * @arg buf            Data buffer.
  * @arg size           Size of data buffer.
  * @return Number of characters written on success or a negative error code.
  */
-int nl_sendto(struct nl_handle *handle, void *buf, size_t size)
+int nl_sendto(struct nl_sock *sk, void *buf, size_t size)
 {
        int ret;
 
-       ret = sendto(handle->h_fd, buf, size, 0, (struct sockaddr *)
-                    &handle->h_peer, sizeof(handle->h_peer));
+       ret = sendto(sk->s_fd, buf, size, 0, (struct sockaddr *)
+                    &sk->s_peer, sizeof(sk->s_peer));
        if (ret < 0)
                return -nl_syserr2nlerr(errno);
 
@@ -282,12 +282,12 @@ int nl_sendto(struct nl_handle *handle, void *buf, size_t size)
 
 /**
  * Send netlink message with control over sendmsg() message header.
- * @arg handle         Netlink handle.
+ * @arg sk             Netlink socket.
  * @arg msg            Netlink message to be sent.
  * @arg hdr            Sendmsg() message header.
  * @return Number of characters sent on sucess or a negative error code.
  */
-int nl_sendmsg(struct nl_handle *handle, struct nl_msg *msg, struct msghdr *hdr)
+int nl_sendmsg(struct nl_sock *sk, struct nl_msg *msg, struct msghdr *hdr)
 {
        struct nl_cb *cb;
        int ret;
@@ -300,14 +300,14 @@ int nl_sendmsg(struct nl_handle *handle, struct nl_msg *msg, struct msghdr *hdr)
        hdr->msg_iov = &iov;
        hdr->msg_iovlen = 1;
 
-       nlmsg_set_src(msg, &handle->h_local);
+       nlmsg_set_src(msg, &sk->s_local);
 
-       cb = handle->h_cb;
+       cb = sk->s_cb;
        if (cb->cb_set[NL_CB_MSG_OUT])
                if (nl_cb_call(cb, NL_CB_MSG_OUT, msg) != NL_OK)
                        return 0;
 
-       ret = sendmsg(handle->h_fd, hdr, 0);
+       ret = sendmsg(sk->s_fd, hdr, 0);
        if (ret < 0)
                return -nl_syserr2nlerr(errno);
 
@@ -317,23 +317,23 @@ int nl_sendmsg(struct nl_handle *handle, struct nl_msg *msg, struct msghdr *hdr)
 
 /**
  * Send netlink message.
- * @arg handle         Netlink handle
+ * @arg sk             Netlink socket.
  * @arg msg            Netlink message to be sent.
  * @see nl_sendmsg()
  * @return Number of characters sent on success or a negative error code.
  */
-int nl_send(struct nl_handle *handle, struct nl_msg *msg)
+int nl_send(struct nl_sock *sk, struct nl_msg *msg)
 {
        struct sockaddr_nl *dst;
        struct ucred *creds;
        
        struct msghdr hdr = {
-               .msg_name = (void *) &handle->h_peer,
+               .msg_name = (void *) &sk->s_peer,
                .msg_namelen = sizeof(struct sockaddr_nl),
        };
 
        /* Overwrite destination if specified in the message itself, defaults
-        * to the peer address of the handle.
+        * to the peer address of the socket.
         */
        dst = nlmsg_get_dst(msg);
        if (dst->nl_family == AF_NETLINK)
@@ -355,12 +355,12 @@ int nl_send(struct nl_handle *handle, struct nl_msg *msg)
                memcpy(CMSG_DATA(cmsg), creds, sizeof(struct ucred));
        }
 
-       return nl_sendmsg(handle, msg, &hdr);
+       return nl_sendmsg(sk, msg, &hdr);
 }
 
 /**
  * Send netlink message and check & extend header values as needed.
- * @arg handle         Netlink handle.
+ * @arg sk             Netlink socket.
  * @arg msg            Netlink message to be sent.
  *
  * Checks the netlink message \c nlh for completness and extends it
@@ -370,32 +370,32 @@ int nl_send(struct nl_handle *handle, struct nl_msg *msg)
  * @see nl_send()
  * @return Number of characters sent or a negative error code.
  */
-int nl_send_auto_complete(struct nl_handle *handle, struct nl_msg *msg)
+int nl_send_auto_complete(struct nl_sock *sk, struct nl_msg *msg)
 {
        struct nlmsghdr *nlh;
-       struct nl_cb *cb = handle->h_cb;
+       struct nl_cb *cb = sk->s_cb;
 
        nlh = nlmsg_hdr(msg);
        if (nlh->nlmsg_pid == 0)
-               nlh->nlmsg_pid = handle->h_local.nl_pid;
+               nlh->nlmsg_pid = sk->s_local.nl_pid;
 
        if (nlh->nlmsg_seq == 0)
-               nlh->nlmsg_seq = handle->h_seq_next++;
+               nlh->nlmsg_seq = sk->s_seq_next++;
 
        if (msg->nm_protocol == -1)
-               msg->nm_protocol = handle->h_proto;
+               msg->nm_protocol = sk->s_proto;
        
        nlh->nlmsg_flags |= (NLM_F_REQUEST | NLM_F_ACK);
 
        if (cb->cb_send_ow)
-               return cb->cb_send_ow(handle, msg);
+               return cb->cb_send_ow(sk, msg);
        else
-               return nl_send(handle, msg);
+               return nl_send(sk, msg);
 }
 
 /**
  * Send simple netlink message using nl_send_auto_complete()
- * @arg handle         Netlink handle.
+ * @arg sk             Netlink socket.
  * @arg type           Netlink message type.
  * @arg flags          Netlink message flags.
  * @arg buf            Data buffer.
@@ -407,7 +407,7 @@ int nl_send_auto_complete(struct nl_handle *handle, struct nl_msg *msg)
  * @see nl_send_auto_complete()
  * @return Number of characters sent on success or a negative error code.
  */
-int nl_send_simple(struct nl_handle *handle, int type, int flags, void *buf,
+int nl_send_simple(struct nl_sock *sk, int type, int flags, void *buf,
                   size_t size)
 {
        int err;
@@ -424,7 +424,7 @@ int nl_send_simple(struct nl_handle *handle, int type, int flags, void *buf,
        }
        
 
-       err = nl_send_auto_complete(handle, msg);
+       err = nl_send_auto_complete(sk, msg);
 errout:
        nlmsg_free(msg);
 
@@ -440,7 +440,7 @@ errout:
 
 /**
  * Receive data from netlink socket
- * @arg handle         Netlink handle.
+ * @arg sk             Netlink socket.
  * @arg nla            Destination pointer for peer's netlink address.
  * @arg buf            Destination pointer for message content.
  * @arg creds          Destination pointer for credentials.
@@ -457,7 +457,7 @@ errout:
  *
  * @return Number of octets read, 0 on EOF or a negative error code.
  */
-int nl_recv(struct nl_handle *handle, struct sockaddr_nl *nla,
+int nl_recv(struct nl_sock *sk, struct sockaddr_nl *nla,
            unsigned char **buf, struct ucred **creds)
 {
        int n;
@@ -475,7 +475,7 @@ int nl_recv(struct nl_handle *handle, struct sockaddr_nl *nla,
        };
        struct cmsghdr *cmsg;
 
-       if (handle->h_flags & NL_MSG_PEEK)
+       if (sk->s_flags & NL_MSG_PEEK)
                flags |= MSG_PEEK;
 
        if (page_size == 0)
@@ -484,13 +484,13 @@ int nl_recv(struct nl_handle *handle, struct sockaddr_nl *nla,
        iov.iov_len = page_size;
        iov.iov_base = *buf = malloc(iov.iov_len);
 
-       if (handle->h_flags & NL_SOCK_PASSCRED) {
+       if (sk->s_flags & NL_SOCK_PASSCRED) {
                msg.msg_controllen = CMSG_SPACE(sizeof(struct ucred));
                msg.msg_control = calloc(1, msg.msg_controllen);
        }
 retry:
 
-       n = recvmsg(handle->h_fd, &msg, flags);
+       n = recvmsg(sk->s_fd, &msg, flags);
        if (!n)
                goto abort;
        else if (n < 0) {
@@ -580,7 +580,7 @@ do { \
  * it freed and cause a race condition with later access to that (now
  * freed) data.
  */ 
-static int recvmsgs(struct nl_handle *handle, struct nl_cb *cb)
+static int recvmsgs(struct nl_sock *sk, struct nl_cb *cb)
 {
        int n, err = 0, multipart = 0;
        unsigned char *buf = NULL, free_msg = 1;
@@ -590,21 +590,20 @@ static int recvmsgs(struct nl_handle *handle, struct nl_cb *cb)
        struct ucred *creds = NULL;
 
 continue_reading:
-       NL_DBG(3, "Attempting to read from %p\n", handle);
+       NL_DBG(3, "Attempting to read from %p\n", sk);
        if (cb->cb_recv_ow)
-               n = cb->cb_recv_ow(handle, &nla, &buf, &creds);
+               n = cb->cb_recv_ow(sk, &nla, &buf, &creds);
        else
-               n = nl_recv(handle, &nla, &buf, &creds);
+               n = nl_recv(sk, &nla, &buf, &creds);
 
        if (n <= 0)
                return n;
 
-       NL_DBG(3, "recvmsgs(%p): Read %d bytes\n", handle, n);
+       NL_DBG(3, "recvmsgs(%p): Read %d bytes\n", sk, n);
 
        hdr = (struct nlmsghdr *) buf;
        while (nlmsg_ok(hdr, n)) {
-               NL_DBG(3, "recgmsgs(%p): Processing valid message...\n",
-                      handle);
+               NL_DBG(3, "recgmsgs(%p): Processing valid message...\n", sk);
 
                if (free_msg)
                        nlmsg_free(msg);
@@ -615,7 +614,7 @@ continue_reading:
                        goto out;
                }
 
-               nlmsg_set_proto(msg, handle->h_proto);
+               nlmsg_set_proto(msg, sk->s_proto);
                nlmsg_set_src(msg, &nla);
                if (creds)
                        nlmsg_set_creds(msg, creds);
@@ -630,7 +629,7 @@ continue_reading:
                 * enforcing strict ordering */
                if (cb->cb_set[NL_CB_SEQ_CHECK])
                        NL_CB_CALL(cb, NL_CB_SEQ_CHECK, msg);
-               else if (hdr->nlmsg_seq != handle->h_seq_expect) {
+               else if (hdr->nlmsg_seq != sk->s_seq_expect) {
                        if (cb->cb_set[NL_CB_INVALID])
                                NL_CB_CALL(cb, NL_CB_INVALID, msg);
                        else {
@@ -645,10 +644,10 @@ continue_reading:
                    hdr->nlmsg_type == NLMSG_OVERRUN) {
                        /* We can't check for !NLM_F_MULTI since some netlink
                         * users in the kernel are broken. */
-                       handle->h_seq_expect++;
+                       sk->s_seq_expect++;
                        NL_DBG(3, "recvmsgs(%p): Increased expected " \
                               "sequence number to %d\n",
-                              handle, handle->h_seq_expect);
+                              sk, sk->s_seq_expect);
                }
 
                if (hdr->nlmsg_flags & NLM_F_MULTI)
@@ -766,7 +765,7 @@ out:
 
 /**
  * Receive a set of messages from a netlink socket.
- * @arg handle         netlink handle
+ * @arg sk             Netlink socket.
  * @arg cb             set of callbacks to control behaviour.
  *
  * Repeatedly calls nl_recv() or the respective replacement if provided
@@ -779,23 +778,23 @@ out:
  *
  * @return 0 on success or a negative error code from nl_recv().
  */
-int nl_recvmsgs(struct nl_handle *handle, struct nl_cb *cb)
+int nl_recvmsgs(struct nl_sock *sk, struct nl_cb *cb)
 {
        if (cb->cb_recvmsgs_ow)
-               return cb->cb_recvmsgs_ow(handle, cb);
+               return cb->cb_recvmsgs_ow(sk, cb);
        else
-               return recvmsgs(handle, cb);
+               return recvmsgs(sk, cb);
 }
 
 /**
- * Receive a set of message from a netlink socket using handlers in nl_handle.
- * @arg handle         netlink handle
+ * Receive a set of message from a netlink socket using handlers in nl_sock.
+ * @arg sk             Netlink socket.
  *
- * Calls nl_recvmsgs() with the handlers configured in the netlink handle.
+ * Calls nl_recvmsgs() with the handlers configured in the netlink socket.
  */
-int nl_recvmsgs_default(struct nl_handle *handle)
+int nl_recvmsgs_default(struct nl_sock *sk)
 {
-       return nl_recvmsgs(handle, handle->h_cb);
+       return nl_recvmsgs(sk, sk->s_cb);
 
 }
 
@@ -806,23 +805,23 @@ static int ack_wait_handler(struct nl_msg *msg, void *arg)
 
 /**
  * Wait for ACK.
- * @arg handle         netlink handle
+ * @arg sk             Netlink socket.
  * @pre The netlink socket must be in blocking state.
  *
  * Waits until an ACK is received for the latest not yet acknowledged
  * netlink message.
  */
-int nl_wait_for_ack(struct nl_handle *handle)
+int nl_wait_for_ack(struct nl_sock *sk)
 {
        int err;
        struct nl_cb *cb;
 
-       cb = nl_cb_clone(handle->h_cb);
+       cb = nl_cb_clone(sk->s_cb);
        if (cb == NULL)
                return -NLE_NOMEM;
 
        nl_cb_set(cb, NL_CB_ACK, NL_CB_CUSTOM, ack_wait_handler, NULL);
-       err = nl_recvmsgs(handle, cb);
+       err = nl_recvmsgs(sk, cb);
        nl_cb_put(cb);
 
        return err;
index 1edcd69f001a9d4f7e7fa3f2a113ea85d0217cb9..3e86bdebd41cc1cbc1d0287533dac5fe09592b32 100644 (file)
@@ -58,7 +58,7 @@
  * // block until the operation has been completed. Alternatively the required
  * // netlink message can be built using rtnl_addr_build_add_request() to be
  * // sent out using nl_send_auto_complete().
- * rtnl_addr_add(handle, addr, 0);
+ * rtnl_addr_add(sk, addr, 0);
  *
  * // Free the memory
  * rtnl_addr_put(addr);
@@ -99,7 +99,7 @@
  * // block until the operation has been completed. Alternatively the required
  * // netlink message can be built using rtnl_addr_build_delete_request()
  * // to be sent out using nl_send_auto_complete().
- * rtnl_addr_delete(handle, addr, 0);
+ * rtnl_addr_delete(sk, addr, 0);
  *
  * // Free the memory
  * rtnl_addr_put(addr);
@@ -297,9 +297,9 @@ errout_nomem:
        goto errout;
 }
 
-static int addr_request_update(struct nl_cache *cache, struct nl_handle *handle)
+static int addr_request_update(struct nl_cache *cache, struct nl_sock *sk)
 {
-       return nl_rtgen_request(handle, RTM_GETADDR, AF_UNSPEC, NLM_F_DUMP);
+       return nl_rtgen_request(sk, RTM_GETADDR, AF_UNSPEC, NLM_F_DUMP);
 }
 
 static int addr_dump_brief(struct nl_object *obj, struct nl_dump_params *p)
@@ -640,9 +640,9 @@ void rtnl_addr_put(struct rtnl_addr *addr)
  * @{
  */
 
-int rtnl_addr_alloc_cache(struct nl_handle *sock, struct nl_cache **result)
+int rtnl_addr_alloc_cache(struct nl_sock *sk, struct nl_cache **result)
 {
-       return nl_cache_alloc_and_fill(&rtnl_addr_ops, sock, result);
+       return nl_cache_alloc_and_fill(&rtnl_addr_ops, sk, result);
 }
 
 /** @} */
@@ -742,7 +742,7 @@ int rtnl_addr_build_add_request(struct rtnl_addr *addr, int flags,
 
 /**
  * Request addition of new address
- * @arg handle         Netlink handle.
+ * @arg sk             Netlink socket.
  * @arg addr           Address object representing the new address.
  * @arg flags          Additional netlink message flags.
  *
@@ -754,7 +754,7 @@ int rtnl_addr_build_add_request(struct rtnl_addr *addr, int flags,
  *
  * @return 0 on sucess or a negative error if an error occured.
  */
-int rtnl_addr_add(struct nl_handle *handle, struct rtnl_addr *addr, int flags)
+int rtnl_addr_add(struct nl_sock *sk, struct rtnl_addr *addr, int flags)
 {
        struct nl_msg *msg;
        int err;
@@ -762,12 +762,12 @@ int rtnl_addr_add(struct nl_handle *handle, struct rtnl_addr *addr, int flags)
        if ((err = rtnl_addr_build_add_request(addr, flags, &msg)) < 0)
                return err;
 
-       err = nl_send_auto_complete(handle, msg);
+       err = nl_send_auto_complete(sk, msg);
        nlmsg_free(msg);
        if (err < 0)
                return err;
 
-       return nl_wait_for_ack(handle);
+       return nl_wait_for_ack(sk);
 }
 
 /** @} */
@@ -814,7 +814,7 @@ int rtnl_addr_build_delete_request(struct rtnl_addr *addr, int flags,
 
 /**
  * Request deletion of an address
- * @arg handle         Netlink handle.
+ * @arg sk             Netlink socket.
  * @arg addr           Address object to be deleted.
  * @arg flags          Additional netlink message flags.
  *
@@ -826,8 +826,7 @@ int rtnl_addr_build_delete_request(struct rtnl_addr *addr, int flags,
  *
  * @return 0 on sucess or a negative error if an error occured.
  */
-int rtnl_addr_delete(struct nl_handle *handle, struct rtnl_addr *addr,
-                    int flags)
+int rtnl_addr_delete(struct nl_sock *sk, struct rtnl_addr *addr, int flags)
 {
        struct nl_msg *msg;
        int err;
@@ -835,12 +834,12 @@ int rtnl_addr_delete(struct nl_handle *handle, struct rtnl_addr *addr,
        if ((err = rtnl_addr_build_delete_request(addr, flags, &msg)) < 0)
                return err;
 
-       err = nl_send_auto_complete(handle, msg);
+       err = nl_send_auto_complete(sk, msg);
        nlmsg_free(msg);
        if (err < 0)
                return err;
 
-       return nl_wait_for_ack(handle);
+       return nl_wait_for_ack(sk);
 }
 
 /** @} */
index 9a1784fa7159efe86149a167316457675ca2e2b6..cdf4232dedce907443d058900fe2cce55573840b 100644 (file)
@@ -64,15 +64,14 @@ errout:
        return err;
 }
 
-static int class_request_update(struct nl_cache *cache,
-                               struct nl_handle *handle)
+static int class_request_update(struct nl_cache *cache, struct nl_sock *sk)
 {
        struct tcmsg tchdr = {
                .tcm_family = AF_UNSPEC,
                .tcm_ifindex = cache->c_iarg1,
        };
 
-       return nl_send_simple(handle, RTM_GETTCLASS, NLM_F_DUMP, &tchdr,
+       return nl_send_simple(sk, RTM_GETTCLASS, NLM_F_DUMP, &tchdr,
                              sizeof(tchdr));
 }
 
@@ -134,7 +133,7 @@ int rtnl_class_build_add_request(struct rtnl_class *class, int flags,
 
 /**
  * Add a new class
- * @arg handle         netlink handle
+ * @arg sk             Netlink socket.
  * @arg class          class to delete
  * @arg flags          additional netlink message flags
  *
@@ -147,8 +146,7 @@ int rtnl_class_build_add_request(struct rtnl_class *class, int flags,
  *
  * @return 0 on success or a negative error code
  */
-int rtnl_class_add(struct nl_handle *handle, struct rtnl_class *class,
-                  int flags)
+int rtnl_class_add(struct nl_sock *sk, struct rtnl_class *class, int flags)
 {
        struct nl_msg *msg;
        int err;
@@ -156,11 +154,11 @@ int rtnl_class_add(struct nl_handle *handle, struct rtnl_class *class,
        if ((err = rtnl_class_build_add_request(class, flags, &msg)) < 0)
                return err;
 
-       if ((err = nl_send_auto_complete(handle, msg)) < 0)
+       if ((err = nl_send_auto_complete(sk, msg)) < 0)
                return err;
 
        nlmsg_free(msg);
-       return nl_wait_for_ack(handle);
+       return nl_wait_for_ack(sk);
 }
 
 /** @} */
@@ -172,7 +170,7 @@ int rtnl_class_add(struct nl_handle *handle, struct rtnl_class *class,
 
 /**
  * Build a class cache including all classes attached to the specified interface
- * @arg handle         netlink handle
+ * @arg sk             Netlink socket.
  * @arg ifindex                interface index of the link the classes are
  *                      attached to.
  *
@@ -181,7 +179,7 @@ int rtnl_class_add(struct nl_handle *handle, struct rtnl_class *class,
  *
  * @return The cache or NULL if an error has occured.
  */
-int rtnl_class_alloc_cache(struct nl_handle *handle, int ifindex,
+int rtnl_class_alloc_cache(struct nl_sock *sk, int ifindex,
                           struct nl_cache **result)
 {
        struct nl_cache * cache;
@@ -193,7 +191,7 @@ int rtnl_class_alloc_cache(struct nl_handle *handle, int ifindex,
 
        cache->c_iarg1 = ifindex;
        
-       if (handle && (err = nl_cache_refill(handle, cache)) < 0) {
+       if (sk && (err = nl_cache_refill(sk, cache)) < 0) {
                nl_cache_free(cache);
                return err;
        }
index 8008bc49cc5b39d9761d72a8cf608d6d93f949de..0f603587a5a93f38a68fbc2e09de2a036ababc88 100644 (file)
@@ -75,7 +75,7 @@ errout:
        return err;
 }
 
-static int cls_request_update(struct nl_cache *cache, struct nl_handle *handle)
+static int cls_request_update(struct nl_cache *cache, struct nl_sock *sk)
 {
        struct tcmsg tchdr = {
                .tcm_family = AF_UNSPEC,
@@ -83,7 +83,7 @@ static int cls_request_update(struct nl_cache *cache, struct nl_handle *handle)
                .tcm_parent = cache->c_iarg2,
        };
 
-       return nl_send_simple(handle, RTM_GETTFILTER, NLM_F_DUMP, &tchdr,
+       return nl_send_simple(sk, RTM_GETTFILTER, NLM_F_DUMP, &tchdr,
                              sizeof(tchdr));
 }
 
@@ -151,7 +151,7 @@ int rtnl_cls_build_add_request(struct rtnl_cls *cls, int flags,
 
 /**
  * Add a new classifier
- * @arg handle         netlink handle
+ * @arg sk             Netlink socket.
  * @arg cls            classifier to add
  * @arg flags          additional netlink message flags
  *
@@ -161,7 +161,7 @@ int rtnl_cls_build_add_request(struct rtnl_cls *cls, int flags,
  *
  * @return 0 on sucess or a negative error if an error occured.
  */
-int rtnl_cls_add(struct nl_handle *handle, struct rtnl_cls *cls, int flags)
+int rtnl_cls_add(struct nl_sock *sk, struct rtnl_cls *cls, int flags)
 {
        struct nl_msg *msg;
        int err;
@@ -169,11 +169,11 @@ int rtnl_cls_add(struct nl_handle *handle, struct rtnl_cls *cls, int flags)
        if ((err = rtnl_cls_build_add_request(cls, flags, &msg)) < 0)
                return err;
        
-       if ((err = nl_send_auto_complete(handle, msg)) < 0)
+       if ((err = nl_send_auto_complete(sk, msg)) < 0)
                return err;
 
        nlmsg_free(msg);
-       return nl_wait_for_ack(handle);
+       return nl_wait_for_ack(sk);
 }
 
 /**
@@ -197,7 +197,7 @@ int rtnl_cls_build_change_request(struct rtnl_cls *cls, int flags,
 
 /**
  * Change a classifier
- * @arg handle         netlink handle
+ * @arg sk             Netlink socket.
  * @arg cls            classifier to change
  * @arg flags          additional netlink message flags
  *
@@ -207,8 +207,7 @@ int rtnl_cls_build_change_request(struct rtnl_cls *cls, int flags,
  *
  * @return 0 on sucess or a negative error if an error occured.
  */
-int rtnl_cls_change(struct nl_handle *handle, struct rtnl_cls *cls,
-                   int flags)
+int rtnl_cls_change(struct nl_sock *sk, struct rtnl_cls *cls, int flags)
 {
        struct nl_msg *msg;
        int err;
@@ -216,11 +215,11 @@ int rtnl_cls_change(struct nl_handle *handle, struct rtnl_cls *cls,
        if ((err = rtnl_cls_build_change_request(cls, flags, &msg)) < 0)
                return err;
        
-       if ((err = nl_send_auto_complete(handle, msg)) < 0)
+       if ((err = nl_send_auto_complete(sk, msg)) < 0)
                return err;
 
        nlmsg_free(msg);
-       return nl_wait_for_ack(handle);
+       return nl_wait_for_ack(sk);
 }
 
 /**
@@ -245,7 +244,7 @@ int rtnl_cls_build_delete_request(struct rtnl_cls *cls, int flags,
 
 /**
  * Delete a classifier
- * @arg handle         netlink handle
+ * @arg sk             Netlink socket.
  * @arg cls            classifier to delete
  * @arg flags          additional netlink message flags
  *
@@ -255,7 +254,7 @@ int rtnl_cls_build_delete_request(struct rtnl_cls *cls, int flags,
  *
  * @return 0 on sucess or a negative error if an error occured.
  */
-int rtnl_cls_delete(struct nl_handle *handle, struct rtnl_cls *cls, int flags)
+int rtnl_cls_delete(struct nl_sock *sk, struct rtnl_cls *cls, int flags)
 {
        struct nl_msg *msg;
        int err;
@@ -263,11 +262,11 @@ int rtnl_cls_delete(struct nl_handle *handle, struct rtnl_cls *cls, int flags)
        if ((err = rtnl_cls_build_delete_request(cls, flags, &msg)) < 0)
                return err;
        
-       if ((err = nl_send_auto_complete(handle, msg)) < 0)
+       if ((err = nl_send_auto_complete(sk, msg)) < 0)
                return err;
 
        nlmsg_free(msg);
-       return nl_wait_for_ack(handle);
+       return nl_wait_for_ack(sk);
 }
 
 /** @} */
@@ -280,7 +279,7 @@ int rtnl_cls_delete(struct nl_handle *handle, struct rtnl_cls *cls, int flags)
 /**
  * Build a classifier cache including all classifiers attached to the
  * specified class/qdisc on eht specified interface.
- * @arg handle         netlink handle
+ * @arg sk             Netlink socket.
  * @arg ifindex                interface index of the link the classes are
  *                      attached to.
  * @arg parent          parent qdisc/class
@@ -293,7 +292,7 @@ int rtnl_cls_delete(struct nl_handle *handle, struct rtnl_cls *cls, int flags)
  *       cache after using it.
  * @return 0 on success or a negative error code.
  */
-int rtnl_cls_alloc_cache(struct nl_handle *handle, int ifindex, uint32_t parent,                        struct nl_cache **result)
+int rtnl_cls_alloc_cache(struct nl_sock *sk, int ifindex, uint32_t parent,                      struct nl_cache **result)
 {
        struct nl_cache * cache;
        int err;
@@ -304,7 +303,7 @@ int rtnl_cls_alloc_cache(struct nl_handle *handle, int ifindex, uint32_t parent,
        cache->c_iarg1 = ifindex;
        cache->c_iarg2 = parent;
        
-       if (handle && (err = nl_cache_refill(handle, cache)) < 0) {
+       if (sk && (err = nl_cache_refill(sk, cache)) < 0) {
                nl_cache_free(cache);
                return err;
        }
index 510932fbd919b3d08d641a6628b89f95cc423f60..34bc83b472ec3a1cf3ba9819354f8d5e611cf491 100644 (file)
@@ -78,7 +78,7 @@
  * @code
  * // The first step is to retrieve a list of all available interfaces within
  * // the kernel and put them into a cache.
- * struct nl_cache *cache = rtnl_link_alloc_cache(nl_handle);
+ * struct nl_cache *cache = rtnl_link_alloc_cache(sk);
  *
  * // In a second step, a specific link may be looked up by either interface
  * // index or interface name.
  * // Two ways exist to commit this change request, the first one is to
  * // build the required netlink message and send it out in one single
  * // step:
- * rtnl_link_change(nl_handle, old, request);
+ * rtnl_link_change(sk, old, request);
  *
  * // An alternative way is to build the netlink message and send it
  * // out yourself using nl_send_auto_complete()
  * struct nl_msg *msg = rtnl_link_build_change_request(old, request);
- * nl_send_auto_complete(nl_handle, nlmsg_hdr(msg));
+ * nl_send_auto_complete(sk, nlmsg_hdr(msg));
  * nlmsg_free(msg);
  *
  * // Don't forget to give back the link object ;->
@@ -427,9 +427,9 @@ errout:
        return err;
 }
 
-static int link_request_update(struct nl_cache *c, struct nl_handle *h)
+static int link_request_update(struct nl_cache *cache, struct nl_sock *sk)
 {
-       return nl_rtgen_request(h, RTM_GETLINK, AF_UNSPEC, NLM_F_DUMP);
+       return nl_rtgen_request(sk, RTM_GETLINK, AF_UNSPEC, NLM_F_DUMP);
 }
 
 static int link_dump_brief(struct nl_object *obj, struct nl_dump_params *p)
@@ -861,7 +861,7 @@ void rtnl_link_put(struct rtnl_link *link)
 
 /**
  * Allocate link cache and fill in all configured links.
- * @arg handle         Netlink handle.
+ * @arg sk             Netlink socket.
  * @arg result         Pointer to store resulting cache.
  *
  * Allocates a new link cache, initializes it properly and updates it
@@ -869,9 +869,9 @@ void rtnl_link_put(struct rtnl_link *link)
  *
  * @return 0 on success or a negative error code.
  */
-int rtnl_link_alloc_cache(struct nl_handle *sock, struct nl_cache **result)
+int rtnl_link_alloc_cache(struct nl_sock *sk, struct nl_cache **result)
 {
-       return nl_cache_alloc_and_fill(&rtnl_link_ops, sock, result);
+       return nl_cache_alloc_and_fill(&rtnl_link_ops, sk, result);
 }
 
 /**
@@ -1025,7 +1025,7 @@ nla_put_failure:
 
 /**
  * Change link attributes
- * @arg handle         netlink handle
+ * @arg sk             Netlink socket.
  * @arg old            link to be changed
  * @arg tmpl           template with requested changes
  * @arg flags          additional netlink message flags
@@ -1038,7 +1038,7 @@ nla_put_failure:
  * @note Not all attributes can be changed, see
  *       \ref link_changeable "Changeable Attributes" for more details.
  */
-int rtnl_link_change(struct nl_handle *handle, struct rtnl_link *old,
+int rtnl_link_change(struct nl_sock *sk, struct rtnl_link *old,
                     struct rtnl_link *tmpl, int flags)
 {
        struct nl_msg *msg;
@@ -1047,11 +1047,11 @@ int rtnl_link_change(struct nl_handle *handle, struct rtnl_link *old,
        if ((err = rtnl_link_build_change_request(old, tmpl, flags, &msg)) < 0)
                return err;
        
-       if ((err = nl_send_auto_complete(handle, msg)) < 0)
+       if ((err = nl_send_auto_complete(sk, msg)) < 0)
                return err;
 
        nlmsg_free(msg);
-       return nl_wait_for_ack(handle);
+       return nl_wait_for_ack(sk);
 }
 
 /** @} */
index 3c8fb1c6b8a7fc5b5e31cfd8e80424c3a82b1fee..adb159620abd0d77b0808ee1309754f0cd362349 100644 (file)
@@ -61,7 +61,7 @@
  * @code
  * // The first step is to retrieve a list of all available neighbour within
  * // the kernel and put them into a cache.
- * struct nl_cache *cache = rtnl_neigh_alloc_cache(handle);
+ * struct nl_cache *cache = rtnl_neigh_alloc_cache(sk);
  *
  * // Neighbours can then be looked up by the interface and destination
  * // address:
@@ -86,7 +86,7 @@
  * // block until the operation has been completed. Alternatively the required
  * // netlink message can be built using rtnl_neigh_build_add_request()
  * // to be sent out using nl_send_auto_complete().
- * rtnl_neigh_add(nl_handle, neigh, NLM_F_REPLACE);
+ * rtnl_neigh_add(sk, neigh, NLM_F_REPLACE);
  *
  * // Free the memory
  * rtnl_neigh_put(neigh);
  * // block until the operation has been completed. Alternatively the required
  * // netlink message can be built using rtnl_neigh_build_delete_request()
  * // to be sent out using nl_send_auto_complete().
- * rtnl_neigh_delete(handle, neigh, 0);
+ * rtnl_neigh_delete(sk, neigh, 0);
  *
  * // Free the memory
  * rtnl_neigh_put(neigh);
  * // block until the operation has been completed. Alternatively the required
  * // netlink message can be built using rtnl_neigh_build_change_request()
  * // to be sent out using nl_send_auto_complete().
- * rtnl_neigh_change(handle, neigh, 0);
+ * rtnl_neigh_change(sk, neigh, 0);
  *
  * // Free the memory
  * rtnl_neigh_put(neigh);
@@ -327,7 +327,7 @@ errout:
        return err;
 }
 
-static int neigh_request_update(struct nl_cache *c, struct nl_handle *h)
+static int neigh_request_update(struct nl_cache *c, struct nl_sock *h)
 {
        return nl_rtgen_request(h, RTM_GETNEIGH, AF_UNSPEC, NLM_F_DUMP);
 }
@@ -524,7 +524,7 @@ void rtnl_neigh_put(struct rtnl_neigh *neigh)
 
 /**
  * Build a neighbour cache including all neighbours currently configured in the kernel.
- * @arg handle         netlink handle
+ * @arg sk             Netlink socket.
  * @arg result         Pointer to store resulting cache.
  *
  * Allocates a new neighbour cache, initializes it properly and updates it
@@ -532,7 +532,7 @@ void rtnl_neigh_put(struct rtnl_neigh *neigh)
  *
  * @return 0 on success or a negative error code.
  */
-int rtnl_neigh_alloc_cache(struct nl_handle *sock, struct nl_cache **result)
+int rtnl_neigh_alloc_cache(struct nl_sock *sock, struct nl_cache **result)
 {
        return nl_cache_alloc_and_fill(&rtnl_neigh_ops, sock, result);
 }
@@ -629,7 +629,7 @@ int rtnl_neigh_build_add_request(struct rtnl_neigh *tmpl, int flags,
 
 /**
  * Add a new neighbour
- * @arg handle         netlink handle
+ * @arg sk             Netlink socket.
  * @arg tmpl           template with requested changes
  * @arg flags          additional netlink message flags
  *
@@ -645,7 +645,7 @@ int rtnl_neigh_build_add_request(struct rtnl_neigh *tmpl, int flags,
  *
  * @return 0 on sucess or a negative error if an error occured.
  */
-int rtnl_neigh_add(struct nl_handle *handle, struct rtnl_neigh *tmpl, int flags)
+int rtnl_neigh_add(struct nl_sock *sk, struct rtnl_neigh *tmpl, int flags)
 {
        int err;
        struct nl_msg *msg;
@@ -653,11 +653,11 @@ int rtnl_neigh_add(struct nl_handle *handle, struct rtnl_neigh *tmpl, int flags)
        if ((err = rtnl_neigh_build_add_request(tmpl, flags, &msg)) < 0)
                return err;
 
-       if ((err = nl_send_auto_complete(handle, msg)) < 0)
+       if ((err = nl_send_auto_complete(sk, msg)) < 0)
                return err;
 
        nlmsg_free(msg);
-       return nl_wait_for_ack(handle);
+       return nl_wait_for_ack(sk);
 }
 
 /** @} */
@@ -689,7 +689,7 @@ int rtnl_neigh_build_delete_request(struct rtnl_neigh *neigh, int flags,
 
 /**
  * Delete a neighbour
- * @arg handle         netlink handle
+ * @arg sk             Netlink socket.
  * @arg neigh          neighbour to delete
  * @arg flags          additional netlink message flags
  *
@@ -699,7 +699,7 @@ int rtnl_neigh_build_delete_request(struct rtnl_neigh *neigh, int flags,
  *
  * @return 0 on sucess or a negative error if an error occured.
  */
-int rtnl_neigh_delete(struct nl_handle *handle, struct rtnl_neigh *neigh,
+int rtnl_neigh_delete(struct nl_sock *sk, struct rtnl_neigh *neigh,
                      int flags)
 {
        struct nl_msg *msg;
@@ -708,11 +708,11 @@ int rtnl_neigh_delete(struct nl_handle *handle, struct rtnl_neigh *neigh,
        if ((err = rtnl_neigh_build_delete_request(neigh, flags, &msg)) < 0)
                return err;
 
-       if ((err = nl_send_auto_complete(handle, msg)) < 0)
+       if ((err = nl_send_auto_complete(sk, msg)) < 0)
                return err;
 
        nlmsg_free(msg);
-       return nl_wait_for_ack(handle);
+       return nl_wait_for_ack(sk);
 }
 
 /** @} */
@@ -747,7 +747,7 @@ int rtnl_neigh_build_change_request(struct rtnl_neigh *neigh, int flags,
 
 /**
  * Change neighbour attributes
- * @arg handle         netlink handle
+ * @arg sk             Netlink socket.
  * @arg neigh          neighbour to be changed
  * @arg flags          additional netlink message flags
  *
@@ -759,8 +759,7 @@ int rtnl_neigh_build_change_request(struct rtnl_neigh *neigh, int flags,
  * @note Not all attributes can be changed, see
  *       \ref neigh_changeable "Changeable Attributes" for a list.
  */
-int rtnl_neigh_change(struct nl_handle *handle, struct rtnl_neigh *neigh,
-                     int flags)
+int rtnl_neigh_change(struct nl_sock *sk, struct rtnl_neigh *neigh, int flags)
 {
        struct nl_msg *msg;
        int err;
@@ -768,11 +767,11 @@ int rtnl_neigh_change(struct nl_handle *handle, struct rtnl_neigh *neigh,
        if ((err = rtnl_neigh_build_change_request(neigh, flags, &msg)) < 0)
                return err;
 
-       if ((err = nl_send_auto_complete(handle, msg)) < 0)
+       if ((err = nl_send_auto_complete(sk, msg)) < 0)
                return err;
 
        nlmsg_free(msg);
-       return nl_wait_for_ack(handle);
+       return nl_wait_for_ack(sk);
 }
 
 /** @} */
index 6010da004084267c35fe1af05b2e23458d2318cf..e58aef67d7436721a73d818f9a478ca9a796ba3b 100644 (file)
@@ -226,7 +226,7 @@ errout:
        return err;
 }
 
-static int neightbl_request_update(struct nl_cache *c, struct nl_handle *h)
+static int neightbl_request_update(struct nl_cache *c, struct nl_sock *h)
 {
        return nl_rtgen_request(h, RTM_GETNEIGHTBL, AF_UNSPEC, NLM_F_DUMP);
 }
@@ -394,7 +394,7 @@ void rtnl_neightbl_put(struct rtnl_neightbl *neightbl)
 
 /**
  * Build a neighbour table cache including all neighbour tables currently configured in the kernel.
- * @arg handle         netlink handle
+ * @arg sk             Netlink socket.
  * @arg result         Pointer to store resulting cache.
  *
  * Allocates a new neighbour table cache, initializes it properly and
@@ -403,9 +403,9 @@ void rtnl_neightbl_put(struct rtnl_neightbl *neightbl)
  *
  * @return 0 on success or a negative error code.
  */
-int rtnl_neightbl_alloc_cache(struct nl_handle *sock, struct nl_cache **result)
+int rtnl_neightbl_alloc_cache(struct nl_sock *sk, struct nl_cache **result)
 {
-       return nl_cache_alloc_and_fill(&rtnl_neightbl_ops, sock, result);
+       return nl_cache_alloc_and_fill(&rtnl_neightbl_ops, sk, result);
 }
 
 /**
@@ -570,7 +570,7 @@ nla_put_failure:
 
 /**
  * Change neighbour table attributes
- * @arg handle         netlink handle
+ * @arg sk             Netlink socket.
  * @arg old            neighbour table to be changed
  * @arg tmpl           template with requested changes
  *
@@ -581,7 +581,7 @@ nla_put_failure:
  *
  * @return 0 on success or a negative error code
  */
-int rtnl_neightbl_change(struct nl_handle *handle, struct rtnl_neightbl *old,
+int rtnl_neightbl_change(struct nl_sock *sk, struct rtnl_neightbl *old,
                         struct rtnl_neightbl *tmpl)
 {
        struct nl_msg *msg;
@@ -590,11 +590,11 @@ int rtnl_neightbl_change(struct nl_handle *handle, struct rtnl_neightbl *old,
        if ((err = rtnl_neightbl_build_change_request(old, tmpl, &msg)) < 0)
                return err;
 
-       if ((err = nl_send_auto_complete(handle, msg)) < 0)
+       if ((err = nl_send_auto_complete(sk, msg)) < 0)
                return err;
 
        nlmsg_free(msg);
-       return nl_wait_for_ack(handle);
+       return nl_wait_for_ack(sk);
 }
 
 /** @} */
index 8b2de2fce3cd842e44656e3590e4a3ae8b572cf5..b23d72d03f021d79f284affaa8959ee9837489ce 100644 (file)
@@ -133,14 +133,14 @@ errout:
        return err;
 }
 
-static int qdisc_request_update(struct nl_cache *c, struct nl_handle *h)
+static int qdisc_request_update(struct nl_cache *c, struct nl_sock *sk)
 {
        struct tcmsg tchdr = {
                .tcm_family = AF_UNSPEC,
                .tcm_ifindex = c->c_iarg1,
        };
 
-       return nl_send_simple(h, RTM_GETQDISC, NLM_F_DUMP, &tchdr,
+       return nl_send_simple(sk, RTM_GETQDISC, NLM_F_DUMP, &tchdr,
                              sizeof(tchdr));
 }
 
@@ -211,7 +211,7 @@ int rtnl_qdisc_build_add_request(struct rtnl_qdisc *qdisc, int flags,
 
 /**
  * Add a new qdisc
- * @arg handle         netlink handle
+ * @arg sk             Netlink socket.
  * @arg qdisc          qdisc to delete
  * @arg flags          additional netlink message flags
  *
@@ -224,7 +224,7 @@ int rtnl_qdisc_build_add_request(struct rtnl_qdisc *qdisc, int flags,
  *
  * @return 0 on success or a negative error code
  */
-int rtnl_qdisc_add(struct nl_handle *handle, struct rtnl_qdisc *qdisc,
+int rtnl_qdisc_add(struct nl_sock *sk, struct rtnl_qdisc *qdisc,
                   int flags)
 {
        struct nl_msg *msg;
@@ -233,11 +233,11 @@ int rtnl_qdisc_add(struct nl_handle *handle, struct rtnl_qdisc *qdisc,
        if ((err = rtnl_qdisc_build_add_request(qdisc, flags, &msg)) < 0)
                return err;
 
-       if ((err = nl_send_auto_complete(handle, msg)) < 0)
+       if ((err = nl_send_auto_complete(sk, msg)) < 0)
                return err;
 
        nlmsg_free(msg);
-       return nl_wait_for_ack(handle);
+       return nl_wait_for_ack(sk);
 }
 
 /** @} */
@@ -269,7 +269,7 @@ int rtnl_qdisc_build_change_request(struct rtnl_qdisc *qdisc,
 
 /**
  * Change attributes of a qdisc
- * @arg handle         netlink handle
+ * @arg sk             Netlink socket.
  * @arg qdisc          qdisc to change
  * @arg new            new qdisc attributes
  *
@@ -279,7 +279,7 @@ int rtnl_qdisc_build_change_request(struct rtnl_qdisc *qdisc,
  *
  * @return 0 on success or a negative error code
  */
-int rtnl_qdisc_change(struct nl_handle *handle, struct rtnl_qdisc *qdisc,
+int rtnl_qdisc_change(struct nl_sock *sk, struct rtnl_qdisc *qdisc,
                      struct rtnl_qdisc *new)
 {
        struct nl_msg *msg;
@@ -288,11 +288,11 @@ int rtnl_qdisc_change(struct nl_handle *handle, struct rtnl_qdisc *qdisc,
        if ((err = rtnl_qdisc_build_change_request(qdisc, new, &msg)) < 0)
                return err;
 
-       if ((err = nl_send_auto_complete(handle, msg)) < 0)
+       if ((err = nl_send_auto_complete(sk, msg)) < 0)
                return err;
 
        nlmsg_free(msg);
-       return nl_wait_for_ack(handle);
+       return nl_wait_for_ack(sk);
 }
 
 /** @} */
@@ -343,7 +343,7 @@ int rtnl_qdisc_build_delete_request(struct rtnl_qdisc *qdisc,
 
 /**
  * Delete a qdisc
- * @arg handle         netlink handle
+ * @arg sk             Netlink socket.
  * @arg qdisc          qdisc to delete
  *
  * Builds a netlink message by calling rtnl_qdisc_build_delete_request(),
@@ -352,7 +352,7 @@ int rtnl_qdisc_build_delete_request(struct rtnl_qdisc *qdisc,
  *
  * @return 0 on success or a negative error code
  */
-int rtnl_qdisc_delete(struct nl_handle *handle, struct rtnl_qdisc *qdisc)
+int rtnl_qdisc_delete(struct nl_sock *sk, struct rtnl_qdisc *qdisc)
 {
        struct nl_msg *msg;
        int err;
@@ -360,11 +360,11 @@ int rtnl_qdisc_delete(struct nl_handle *handle, struct rtnl_qdisc *qdisc)
        if ((err = rtnl_qdisc_build_delete_request(qdisc, &msg)) < 0)
                return err;
 
-       if ((err = nl_send_auto_complete(handle, msg)) < 0)
+       if ((err = nl_send_auto_complete(sk, msg)) < 0)
                return err;
 
        nlmsg_free(msg);
-       return nl_wait_for_ack(handle);
+       return nl_wait_for_ack(sk);
 }
 
 /** @} */
@@ -377,7 +377,7 @@ int rtnl_qdisc_delete(struct nl_handle *handle, struct rtnl_qdisc *qdisc)
 /**
  * Build a qdisc cache including all qdiscs currently configured in
  * the kernel
- * @arg sock           netlink handle
+ * @arg sk             Netlink socket.
  * @arg result         Pointer to store resulting message.
  *
  * Allocates a new cache, initializes it properly and updates it to
@@ -385,9 +385,9 @@ int rtnl_qdisc_delete(struct nl_handle *handle, struct rtnl_qdisc *qdisc)
  *
  * @return 0 on success or a negative error code.
  */
-int rtnl_qdisc_alloc_cache(struct nl_handle *sock, struct nl_cache **result)
+int rtnl_qdisc_alloc_cache(struct nl_sock *sk, struct nl_cache **result)
 {
-       return nl_cache_alloc_and_fill(&rtnl_qdisc_ops, sock, result);
+       return nl_cache_alloc_and_fill(&rtnl_qdisc_ops, sk, result);
 }
 
 /**
index 823d6954d424ef5c5f0939b5525b854f53122476..1c13e6e0aa658bb62eb641e50e90e5250397a3d7 100644 (file)
@@ -46,7 +46,7 @@ errout:
        return err;
 }
 
-static int route_request_update(struct nl_cache *c, struct nl_handle *h)
+static int route_request_update(struct nl_cache *c, struct nl_sock *h)
 {
        struct rtmsg rhdr = {
                .rtm_family = c->c_iarg1,
@@ -65,7 +65,7 @@ static int route_request_update(struct nl_cache *c, struct nl_handle *h)
 
 /**
  * Build a route cache holding all routes currently configured in the kernel
- * @arg handle         netlink handle
+ * @arg sk             Netlink socket.
  * @arg family         Address family of routes to cover or AF_UNSPEC
  * @arg flags          Flags
  *
@@ -76,7 +76,7 @@ static int route_request_update(struct nl_cache *c, struct nl_handle *h)
  *       cache after using it.
  * @return The cache or NULL if an error has occured.
  */
-int rtnl_route_alloc_cache(struct nl_handle *handle, int family, int flags,
+int rtnl_route_alloc_cache(struct nl_sock *sk, int family, int flags,
                           struct nl_cache **result)
 {
        struct nl_cache *cache;
@@ -88,7 +88,7 @@ int rtnl_route_alloc_cache(struct nl_handle *handle, int family, int flags,
        cache->c_iarg1 = family;
        cache->c_iarg2 = flags;
 
-       if (handle && (err = nl_cache_refill(handle, cache)) < 0) {
+       if (sk && (err = nl_cache_refill(sk, cache)) < 0) {
                free(cache);
                return err;
        }
@@ -129,8 +129,7 @@ int rtnl_route_build_add_request(struct rtnl_route *tmpl, int flags,
                               result);
 }
 
-int rtnl_route_add(struct nl_handle *handle, struct rtnl_route *route,
-                  int flags)
+int rtnl_route_add(struct nl_sock *sk, struct rtnl_route *route, int flags)
 {
        struct nl_msg *msg;
        int err;
@@ -138,12 +137,12 @@ int rtnl_route_add(struct nl_handle *handle, struct rtnl_route *route,
        if ((err = rtnl_route_build_add_request(route, flags, &msg)) < 0)
                return err;
 
-       err = nl_send_auto_complete(handle, msg);
+       err = nl_send_auto_complete(sk, msg);
        nlmsg_free(msg);
        if (err < 0)
                return err;
 
-       return nl_wait_for_ack(handle);
+       return nl_wait_for_ack(sk);
 }
 
 int rtnl_route_build_del_request(struct rtnl_route *tmpl, int flags,
@@ -152,8 +151,7 @@ int rtnl_route_build_del_request(struct rtnl_route *tmpl, int flags,
        return build_route_msg(tmpl, RTM_DELROUTE, flags, result);
 }
 
-int rtnl_route_delete(struct nl_handle *handle, struct rtnl_route *route,
-                     int flags)
+int rtnl_route_delete(struct nl_sock *sk, struct rtnl_route *route, int flags)
 {
        struct nl_msg *msg;
        int err;
@@ -161,12 +159,12 @@ int rtnl_route_delete(struct nl_handle *handle, struct rtnl_route *route,
        if ((err = rtnl_route_build_del_request(route, flags, &msg)) < 0)
                return err;
 
-       err = nl_send_auto_complete(handle, msg);
+       err = nl_send_auto_complete(sk, msg);
        nlmsg_free(msg);
        if (err < 0)
                return err;
 
-       return nl_wait_for_ack(handle);
+       return nl_wait_for_ack(sk);
 }
 
 /** @} */
index 81ddf947f1a4834db7da4bab31d8de988206fa11..f87c5f56a5b26df771889a360eee940efeac1594 100644 (file)
@@ -6,7 +6,7 @@
  *     License as published by the Free Software Foundation version 2.1
  *     of the License.
  *
- * Copyright (c) 2003-2006 Thomas Graf <tgraf@suug.ch>
+ * Copyright (c) 2003-2008 Thomas Graf <tgraf@suug.ch>
  */
 
 /**
@@ -27,7 +27,7 @@
 
 /**
  * Send routing netlink request message
- * @arg handle         Netlink handle.
+ * @arg sk             Netlink socket.
  * @arg type           Netlink message type.
  * @arg family         Address family.
  * @arg flags          Additional netlink message flags.
  *
  * @return 0 on success or a negative error code.
  */
-int nl_rtgen_request(struct nl_handle *handle, int type, int family, int flags)
+int nl_rtgen_request(struct nl_sock *sk, int type, int family, int flags)
 {
        struct rtgenmsg gmsg = {
                .rtgen_family = family,
        };
 
-       return nl_send_simple(handle, type, flags, &gmsg, sizeof(gmsg));
+       return nl_send_simple(sk, type, flags, &gmsg, sizeof(gmsg));
 }
 
 /** @} */
index 4d3c6298e4a54259d4470122625a941539c3e133..00163b0231332d24588edefae296b10757a32303 100644 (file)
@@ -169,7 +169,7 @@ errout_enomem:
        goto errout;
 }
 
-static int rule_request_update(struct nl_cache *c, struct nl_handle *h)
+static int rule_request_update(struct nl_cache *c, struct nl_sock *h)
 {
        return nl_rtgen_request(h, RTM_GETRULE, AF_UNSPEC, NLM_F_DUMP);
 }
@@ -435,7 +435,7 @@ void rtnl_rule_put(struct rtnl_rule *rule)
 
 /**
  * Build a rule cache including all rules currently configured in the kernel.
- * @arg handle         netlink handle
+ * @arg sk             Netlink socket.
  * @arg family         Address family or AF_UNSPEC.
  * @arg result         Pointer to store resulting cache.
  *
@@ -444,7 +444,7 @@ void rtnl_rule_put(struct rtnl_rule *rule)
  *
  * @return 0 on success or a negative error code.
  */
-int rtnl_rule_alloc_cache(struct nl_handle *sock, int family,
+int rtnl_rule_alloc_cache(struct nl_sock *sock, int family,
                          struct nl_cache **result)
 {
        struct nl_cache * cache;
@@ -555,7 +555,7 @@ int rtnl_rule_build_add_request(struct rtnl_rule *tmpl, int flags,
 
 /**
  * Add a new rule
- * @arg handle         netlink handle
+ * @arg sk             Netlink socket.
  * @arg tmpl           template with requested changes
  * @arg flags          additional netlink message flags
  *
@@ -565,7 +565,7 @@ int rtnl_rule_build_add_request(struct rtnl_rule *tmpl, int flags,
  *
  * @return 0 on sucess or a negative error if an error occured.
  */
-int rtnl_rule_add(struct nl_handle *handle, struct rtnl_rule *tmpl, int flags)
+int rtnl_rule_add(struct nl_sock *sk, struct rtnl_rule *tmpl, int flags)
 {
        struct nl_msg *msg;
        int err;
@@ -573,12 +573,12 @@ int rtnl_rule_add(struct nl_handle *handle, struct rtnl_rule *tmpl, int flags)
        if ((err = rtnl_rule_build_add_request(tmpl, flags, &msg)) < 0)
                return err;
 
-       err = nl_send_auto_complete(handle, msg);
+       err = nl_send_auto_complete(sk, msg);
        nlmsg_free(msg);
        if (err < 0)
                return err;
 
-       return nl_wait_for_ack(handle);
+       return nl_wait_for_ack(sk);
 }
 
 /** @} */
@@ -609,7 +609,7 @@ int rtnl_rule_build_delete_request(struct rtnl_rule *rule, int flags,
 
 /**
  * Delete a rule
- * @arg handle         netlink handle
+ * @arg sk             Netlink socket.
  * @arg rule           rule to delete
  * @arg flags          additional netlink message flags
  *
@@ -619,8 +619,7 @@ int rtnl_rule_build_delete_request(struct rtnl_rule *rule, int flags,
  *
  * @return 0 on sucess or a negative error if an error occured.
  */
-int rtnl_rule_delete(struct nl_handle *handle, struct rtnl_rule *rule,
-                    int flags)
+int rtnl_rule_delete(struct nl_sock *sk, struct rtnl_rule *rule, int flags)
 {
        struct nl_msg *msg;
        int err;
@@ -628,12 +627,12 @@ int rtnl_rule_delete(struct nl_handle *handle, struct rtnl_rule *rule,
        if ((err = rtnl_rule_build_delete_request(rule, flags, &msg)) < 0)
                return err;
 
-       err = nl_send_auto_complete(handle, msg);
+       err = nl_send_auto_complete(sk, msg);
        nlmsg_free(msg);
        if (err < 0)
                return err;
 
-       return nl_wait_for_ack(handle);
+       return nl_wait_for_ack(sk);
 }
 
 /** @} */
index 088cd100dee8035681d0974ba51e52223f03040d..3b0d9dc1eb13918003ff0ee2216e5dd0b9b5552f 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * lib/socket.c                Netlink Socket Handle
+ * lib/socket.c                Netlink Socket
  *
  *     This library is free software; you can redistribute it and/or
  *     modify it under the terms of the GNU Lesser General Public
 /**
  * @ingroup nl
  * @defgroup socket Socket
- * @brief Handle representing a netlink socket.
  *
- * The socket is represented in a structure called the netlink handle,
- * besides the socket, it stores various settings and values related
- * to the socket. Every socket handle has a mandatory association with
- * a set of callbacks which can be used to modify the behaviour when
- * sending/receiving data from the socket.
+ * Every socket has a mandatory association with a set of callbacks
+ * which can be used to modify the behaviour when sending/receiving data
+ * from the socket.
  *
  * @par Socket Attributes
  * - \b Local \b Port: The local port is a netlink port identifying the
  *   local endpoint. It is used as source address for outgoing messages
  *   and will be addressed in replies. It must therefore be unique among
- *   all userspace applications. When the socket handle is allocated, a
+ *   all userspace applications. When the socket is allocated, a
  *   unique port number is generated automatically in the form of 22 bits
  *   Process Identifier + 10 bits Arbitary Number. Therefore the library
  *   is capable of generating 1024 unique local port numbers for every
  *   number.)
  * - \b Callbacks \b Configuration:
  *
- * @par 1) Creating the netlink handle
+ * @par 1) Creating the netlink socket
  * @code
- * struct nl_handle *handle;
+ * struct nl_sock *sk;
  *
- * // Allocate and initialize a new netlink handle
- * handle = nl_handle_alloc();
+ * // Allocate and initialize a new netlink socket
+ * sk = nl_socket_alloc();
  *
  * // Use nl_socket_get_fd() to fetch the file description, for example to
  * // put a socket into non-blocking i/o mode.
- * fcntl(nl_socket_get_fd(handle), F_SETFL, O_NONBLOCK);
+ * fcntl(nl_socket_get_fd(sk), F_SETFL, O_NONBLOCK);
  * @endcode
  *
  * @par 2) Group Subscriptions
  * @code
  * // Event notifications are typically sent to multicast addresses which
  * // represented by groups. Join a group to f.e. receive link notifications.
- * nl_socket_add_membership(handle, RTNLGRP_LINK);
+ * nl_socket_add_membership(sk, RTNLGRP_LINK);
  * @endcode
  *
  * @par 6) Cleaning up
  * @code
- * // Finally destroy the netlink handle
- * nl_handle_destroy(handle);
+ * // Finally destroy the netlink socket.
+ * nl_socket_free(sk);
  * @endcode
  * 
  * @{
@@ -161,34 +158,34 @@ static void release_local_port(uint32_t port)
  * @{
  */
 
-static struct nl_handle *__alloc_handle(struct nl_cb *cb)
+static struct nl_sock *__alloc_socket(struct nl_cb *cb)
 {
-       struct nl_handle *handle;
+       struct nl_sock *sk;
 
-       handle = calloc(1, sizeof(*handle));
-       if (!handle)
+       sk = calloc(1, sizeof(*sk));
+       if (!sk)
                return NULL;
 
-       handle->h_fd = -1;
-       handle->h_cb = cb;
-       handle->h_local.nl_family = AF_NETLINK;
-       handle->h_peer.nl_family = AF_NETLINK;
-       handle->h_seq_expect = handle->h_seq_next = time(0);
-       handle->h_local.nl_pid = generate_local_port();
-       if (handle->h_local.nl_pid == UINT_MAX) {
-               nl_handle_destroy(handle);
+       sk->s_fd = -1;
+       sk->s_cb = cb;
+       sk->s_local.nl_family = AF_NETLINK;
+       sk->s_peer.nl_family = AF_NETLINK;
+       sk->s_seq_expect = sk->s_seq_next = time(0);
+       sk->s_local.nl_pid = generate_local_port();
+       if (sk->s_local.nl_pid == UINT_MAX) {
+               nl_socket_free(sk);
                return NULL;
        }
 
-       return handle;
+       return sk;
 }
 
 /**
- * Allocate new netlink socket handle.
+ * Allocate new netlink socket
  *
- * @return Newly allocated netlink socket handle or NULL.
+ * @return Newly allocated netlink socket or NULL.
  */
-struct nl_handle *nl_handle_alloc(void)
+struct nl_sock *nl_socket_alloc(void)
 {
        struct nl_cb *cb;
        
@@ -196,43 +193,43 @@ struct nl_handle *nl_handle_alloc(void)
        if (!cb)
                return NULL;
 
-       return __alloc_handle(cb);
+       return __alloc_socket(cb);
 }
 
 /**
- * Allocate new socket handle with custom callbacks
+ * Allocate new socket with custom callbacks
  * @arg cb             Callback handler
  *
  * The reference to the callback handler is taken into account
- * automatically, it is released again upon calling nl_handle_destroy().
+ * automatically, it is released again upon calling nl_socket_free().
  *
  *@return Newly allocted socket handle or NULL.
  */
-struct nl_handle *nl_handle_alloc_cb(struct nl_cb *cb)
+struct nl_sock *nl_socket_alloc_cb(struct nl_cb *cb)
 {
        if (cb == NULL)
                BUG();
 
-       return __alloc_handle(nl_cb_get(cb));
+       return __alloc_socket(nl_cb_get(cb));
 }
 
 /**
- * Destroy netlink handle.
- * @arg handle         Netlink handle.
+ * Free a netlink socket.
+ * @arg sk             Netlink socket.
  */
-void nl_handle_destroy(struct nl_handle *handle)
+void nl_socket_free(struct nl_sock *sk)
 {
-       if (!handle)
+       if (!sk)
                return;
 
-       if (handle->h_fd >= 0)
-               close(handle->h_fd);
+       if (sk->s_fd >= 0)
+               close(sk->s_fd);
 
-       if (!(handle->h_flags & NL_OWN_PORT))
-               release_local_port(handle->h_local.nl_pid);
+       if (!(sk->s_flags & NL_OWN_PORT))
+               release_local_port(sk->s_local.nl_pid);
 
-       nl_cb_put(handle->h_cb);
-       free(handle);
+       nl_cb_put(sk->s_cb);
+       free(sk);
 }
 
 /** @} */
@@ -250,33 +247,33 @@ static int noop_seq_check(struct nl_msg *msg, void *arg)
 
 /**
  * Disable sequence number checking.
- * @arg handle         Netlink handle.
+ * @arg sk             Netlink socket.
  *
- * Disables checking of sequence numbers on the netlink handle. This is
+ * Disables checking of sequence numbers on the netlink socket This is
  * required to allow messages to be processed which were not requested by
  * a preceding request message, e.g. netlink events.
  *
  * @note This function modifies the NL_CB_SEQ_CHECK configuration in
  * the callback handle associated with the socket.
  */
-void nl_disable_sequence_check(struct nl_handle *handle)
+void nl_disable_sequence_check(struct nl_sock *sk)
 {
-       nl_cb_set(handle->h_cb, NL_CB_SEQ_CHECK,
+       nl_cb_set(sk->s_cb, NL_CB_SEQ_CHECK,
                  NL_CB_CUSTOM, noop_seq_check, NULL);
 }
 
 /**
  * Use next sequence number
- * @arg handle         Netlink handle
+ * @arg sk             Netlink socket.
  *
  * Uses the next available sequence number and increases the counter
  * by one for subsequent calls.
  *
  * @return Unique serial sequence number
  */
-unsigned int nl_socket_use_seq(struct nl_handle *handle)
+unsigned int nl_socket_use_seq(struct nl_sock *sk)
 {
-       return handle->h_seq_next++;
+       return sk->s_seq_next++;
 }
 
 /** @} */
@@ -286,31 +283,31 @@ unsigned int nl_socket_use_seq(struct nl_handle *handle)
  * @{
  */
 
-uint32_t nl_socket_get_local_port(struct nl_handle *handle)
+uint32_t nl_socket_get_local_port(struct nl_sock *sk)
 {
-       return handle->h_local.nl_pid;
+       return sk->s_local.nl_pid;
 }
 
 /**
  * Set local port of socket
- * @arg handle         Netlink handle
+ * @arg sk             Netlink socket.
  * @arg port           Local port identifier
  *
  * Assigns a local port identifier to the socket. If port is 0
  * a unique port identifier will be generated automatically.
  */
-void nl_socket_set_local_port(struct nl_handle *handle, uint32_t port)
+void nl_socket_set_local_port(struct nl_sock *sk, uint32_t port)
 {
        if (port == 0) {
                port = generate_local_port(); 
-               handle->h_flags &= ~NL_OWN_PORT;
+               sk->s_flags &= ~NL_OWN_PORT;
        } else  {
-               if (!(handle->h_flags & NL_OWN_PORT))
-                       release_local_port(handle->h_local.nl_pid);
-               handle->h_flags |= NL_OWN_PORT;
+               if (!(sk->s_flags & NL_OWN_PORT))
+                       release_local_port(sk->s_local.nl_pid);
+               sk->s_flags |= NL_OWN_PORT;
        }
 
-       handle->h_local.nl_pid = port;
+       sk->s_local.nl_pid = port;
 }
 
 /** @} */
@@ -322,7 +319,7 @@ void nl_socket_set_local_port(struct nl_handle *handle, uint32_t port)
 
 /**
  * Join a group
- * @arg handle         Netlink handle
+ * @arg sk             Netlink socket
  * @arg group          Group identifier
  *
  * Joins the specified group using the modern socket option which
@@ -335,14 +332,14 @@ void nl_socket_set_local_port(struct nl_handle *handle, uint32_t port)
  *
  * @return 0 on sucess or a negative error code.
  */
-int nl_socket_add_membership(struct nl_handle *handle, int group)
+int nl_socket_add_membership(struct nl_sock *sk, int group)
 {
        int err;
 
-       if (handle->h_fd == -1)
+       if (sk->s_fd == -1)
                return -NLE_BAD_SOCK;
 
-       err = setsockopt(handle->h_fd, SOL_NETLINK, NETLINK_ADD_MEMBERSHIP,
+       err = setsockopt(sk->s_fd, SOL_NETLINK, NETLINK_ADD_MEMBERSHIP,
                         &group, sizeof(group));
        if (err < 0)
                return -nl_syserr2nlerr(errno);
@@ -352,7 +349,7 @@ int nl_socket_add_membership(struct nl_handle *handle, int group)
 
 /**
  * Leave a group
- * @arg handle         Netlink handle
+ * @arg sk             Netlink socket
  * @arg group          Group identifier
  *
  * Leaves the specified group using the modern socket option
@@ -361,14 +358,14 @@ int nl_socket_add_membership(struct nl_handle *handle, int group)
  * @see nl_socket_add_membership
  * @return 0 on success or a negative error code.
  */
-int nl_socket_drop_membership(struct nl_handle *handle, int group)
+int nl_socket_drop_membership(struct nl_sock *sk, int group)
 {
        int err;
 
-       if (handle->h_fd == -1)
+       if (sk->s_fd == -1)
                return -NLE_BAD_SOCK;
 
-       err = setsockopt(handle->h_fd, SOL_NETLINK, NETLINK_DROP_MEMBERSHIP,
+       err = setsockopt(sk->s_fd, SOL_NETLINK, NETLINK_DROP_MEMBERSHIP,
                         &group, sizeof(group));
        if (err < 0)
                return -nl_syserr2nlerr(errno);
@@ -378,16 +375,16 @@ int nl_socket_drop_membership(struct nl_handle *handle, int group)
 
 /**
  * Join multicast groups (deprecated)
- * @arg handle         Netlink handle.
+ * @arg sk             Netlink socket.
  * @arg groups         Bitmask of groups to join.
  *
  * This function defines the old way of joining multicast group which
  * has to be done prior to calling nl_connect(). It works on any kernel
  * version but is very limited as only 32 groups can be joined.
  */
-void nl_join_groups(struct nl_handle *handle, int groups)
+void nl_join_groups(struct nl_sock *sk, int groups)
 {
-       handle->h_local.nl_groups |= groups;
+       sk->s_local.nl_groups |= groups;
 }
 
 
@@ -398,14 +395,14 @@ void nl_join_groups(struct nl_handle *handle, int groups)
  * @{
  */
 
-uint32_t nl_socket_get_peer_port(struct nl_handle *handle)
+uint32_t nl_socket_get_peer_port(struct nl_sock *sk)
 {
-       return handle->h_peer.nl_pid;
+       return sk->s_peer.nl_pid;
 }
 
-void nl_socket_set_peer_port(struct nl_handle *handle, uint32_t port)
+void nl_socket_set_peer_port(struct nl_sock *sk, uint32_t port)
 {
-       handle->h_peer.nl_pid = port;
+       sk->s_peer.nl_pid = port;
 }
 
 /** @} */
@@ -415,23 +412,23 @@ void nl_socket_set_peer_port(struct nl_handle *handle, uint32_t port)
  * @{
  */
 
-int nl_socket_get_fd(struct nl_handle *handle)
+int nl_socket_get_fd(struct nl_sock *sk)
 {
-       return handle->h_fd;
+       return sk->s_fd;
 }
 
 /**
- * Set file descriptor of socket handle to non-blocking state
- * @arg handle         Netlink socket
+ * Set file descriptor of socket to non-blocking state
+ * @arg sk             Netlink socket.
  *
  * @return 0 on success or a negative error code.
  */
-int nl_socket_set_nonblocking(struct nl_handle *handle)
+int nl_socket_set_nonblocking(struct nl_sock *sk)
 {
-       if (handle->h_fd == -1)
+       if (sk->s_fd == -1)
                return -NLE_BAD_SOCK;
 
-       if (fcntl(handle->h_fd, F_SETFL, O_NONBLOCK) < 0)
+       if (fcntl(sk->s_fd, F_SETFL, O_NONBLOCK) < 0)
                return -nl_syserr2nlerr(errno);
 
        return 0;
@@ -439,20 +436,20 @@ int nl_socket_set_nonblocking(struct nl_handle *handle)
 
 /**
  * Enable use of MSG_PEEK when reading from socket
- * @arg handle         Netlink socket
+ * @arg sk             Netlink socket.
  */
-void nl_socket_enable_msg_peek(struct nl_handle *handle)
+void nl_socket_enable_msg_peek(struct nl_sock *sk)
 {
-       handle->h_flags |= NL_MSG_PEEK;
+       sk->s_flags |= NL_MSG_PEEK;
 }
 
 /**
  * Disable use of MSG_PEEK when reading from socket
- * @arg handle         Netlink socket
+ * @arg sk             Netlink socket.
  */
-void nl_socket_disable_msg_peek(struct nl_handle *handle)
+void nl_socket_disable_msg_peek(struct nl_sock *sk)
 {
-       handle->h_flags &= ~NL_MSG_PEEK;
+       sk->s_flags &= ~NL_MSG_PEEK;
 }
 
 /** @} */
@@ -462,20 +459,20 @@ void nl_socket_disable_msg_peek(struct nl_handle *handle)
  * @{
  */
 
-struct nl_cb *nl_socket_get_cb(struct nl_handle *handle)
+struct nl_cb *nl_socket_get_cb(struct nl_sock *sk)
 {
-       return nl_cb_get(handle->h_cb);
+       return nl_cb_get(sk->s_cb);
 }
 
-void nl_socket_set_cb(struct nl_handle *handle, struct nl_cb *cb)
+void nl_socket_set_cb(struct nl_sock *sk, struct nl_cb *cb)
 {
-       nl_cb_put(handle->h_cb);
-       handle->h_cb = nl_cb_get(cb);
+       nl_cb_put(sk->s_cb);
+       sk->s_cb = nl_cb_get(cb);
 }
 
 /**
  * Modify the callback handler associated to the socket
- * @arg handle         netlink handle
+ * @arg sk             Netlink socket.
  * @arg type           which type callback to set
  * @arg kind           kind of callback
  * @arg func           callback function
@@ -483,11 +480,11 @@ void nl_socket_set_cb(struct nl_handle *handle, struct nl_cb *cb)
  *
  * @see nl_cb_set
  */
-int nl_socket_modify_cb(struct nl_handle *handle, enum nl_cb_type type,
+int nl_socket_modify_cb(struct nl_sock *sk, enum nl_cb_type type,
                        enum nl_cb_kind kind, nl_recvmsg_msg_cb_t func,
                        void *arg)
 {
-       return nl_cb_set(handle->h_cb, type, kind, func, arg);
+       return nl_cb_set(sk->s_cb, type, kind, func, arg);
 }
 
 /** @} */
@@ -498,19 +495,19 @@ int nl_socket_modify_cb(struct nl_handle *handle, enum nl_cb_type type,
  */
 
 /**
- * Set socket buffer size of netlink handle.
- * @arg handle         Netlink handle.
+ * Set socket buffer size of netlink socket.
+ * @arg sk             Netlink socket.
  * @arg rxbuf          New receive socket buffer size in bytes.
  * @arg txbuf          New transmit socket buffer size in bytes.
  *
- * Sets the socket buffer size of a netlink handle to the specified
+ * Sets the socket buffer size of a netlink socket to the specified
  * values \c rxbuf and \c txbuf. Providing a value of \c 0 assumes a
  * good default value.
  *
  * @note It is not required to call this function prior to nl_connect().
  * @return 0 on sucess or a negative error code.
  */
-int nl_set_buffer_size(struct nl_handle *handle, int rxbuf, int txbuf)
+int nl_set_buffer_size(struct nl_sock *sk, int rxbuf, int txbuf)
 {
        int err;
 
@@ -520,66 +517,66 @@ int nl_set_buffer_size(struct nl_handle *handle, int rxbuf, int txbuf)
        if (txbuf <= 0)
                txbuf = 32768;
 
-       if (handle->h_fd == -1)
+       if (sk->s_fd == -1)
                return -NLE_BAD_SOCK;
        
-       err = setsockopt(handle->h_fd, SOL_SOCKET, SO_SNDBUF,
+       err = setsockopt(sk->s_fd, SOL_SOCKET, SO_SNDBUF,
                         &txbuf, sizeof(txbuf));
        if (err < 0)
                return -nl_syserr2nlerr(errno);
 
-       err = setsockopt(handle->h_fd, SOL_SOCKET, SO_RCVBUF,
+       err = setsockopt(sk->s_fd, SOL_SOCKET, SO_RCVBUF,
                         &rxbuf, sizeof(rxbuf));
        if (err < 0)
                return -nl_syserr2nlerr(errno);
 
-       handle->h_flags |= NL_SOCK_BUFSIZE_SET;
+       sk->s_flags |= NL_SOCK_BUFSIZE_SET;
 
        return 0;
 }
 
 /**
- * Enable/disable credential passing on netlink handle.
- * @arg handle         Netlink handle
+ * Enable/disable credential passing on netlink socket.
+ * @arg sk             Netlink socket.
  * @arg state          New state (0 - disabled, 1 - enabled)
  *
  * @return 0 on success or a negative error code
  */
-int nl_set_passcred(struct nl_handle *handle, int state)
+int nl_set_passcred(struct nl_sock *sk, int state)
 {
        int err;
 
-       if (handle->h_fd == -1)
+       if (sk->s_fd == -1)
                return -NLE_BAD_SOCK;
 
-       err = setsockopt(handle->h_fd, SOL_SOCKET, SO_PASSCRED,
+       err = setsockopt(sk->s_fd, SOL_SOCKET, SO_PASSCRED,
                         &state, sizeof(state));
        if (err < 0)
                return -nl_syserr2nlerr(errno);
 
        if (state)
-               handle->h_flags |= NL_SOCK_PASSCRED;
+               sk->s_flags |= NL_SOCK_PASSCRED;
        else
-               handle->h_flags &= ~NL_SOCK_PASSCRED;
+               sk->s_flags &= ~NL_SOCK_PASSCRED;
 
        return 0;
 }
 
 /**
  * Enable/disable receival of additional packet information
- * @arg handle         Netlink handle
+ * @arg sk             Netlink socket.
  * @arg state          New state (0 - disabled, 1 - enabled)
  *
  * @return 0 on success or a negative error code
  */
-int nl_socket_recv_pktinfo(struct nl_handle *handle, int state)
+int nl_socket_recv_pktinfo(struct nl_sock *sk, int state)
 {
        int err;
 
-       if (handle->h_fd == -1)
+       if (sk->s_fd == -1)
                return -NLE_BAD_SOCK;
 
-       err = setsockopt(handle->h_fd, SOL_NETLINK, NETLINK_PKTINFO,
+       err = setsockopt(sk->s_fd, SOL_NETLINK, NETLINK_PKTINFO,
                         &state, sizeof(state));
        if (err < 0)
                return -nl_syserr2nlerr(errno);