socket.h

00001 /*
00002  * netlink/socket.h             Netlink Socket
00003  *
00004  *      This library is free software; you can redistribute it and/or
00005  *      modify it under the terms of the GNU Lesser General Public
00006  *      License as published by the Free Software Foundation version 2.1
00007  *      of the License.
00008  *
00009  * Copyright (c) 2003-2008 Thomas Graf <tgraf@suug.ch>
00010  */
00011 
00012 #ifndef NETLINK_SOCKET_H_
00013 #define NETLINK_SOCKET_H_
00014 
00015 #include <netlink/types.h>
00016 #include <netlink/handlers.h>
00017 
00018 #ifdef __cplusplus
00019 extern "C" {
00020 #endif
00021 
00022 extern struct nl_sock * nl_socket_alloc(void);
00023 extern struct nl_sock * nl_socket_alloc_cb(struct nl_cb *);
00024 extern void             nl_socket_free(struct nl_sock *);
00025 
00026 extern uint32_t         nl_socket_get_local_port(const struct nl_sock *);
00027 extern void             nl_socket_set_local_port(struct nl_sock *, uint32_t);
00028 
00029 extern int              nl_socket_add_memberships(struct nl_sock *, int, ...);
00030 extern int              nl_socket_add_membership(struct nl_sock *, int);
00031 extern int              nl_socket_drop_memberships(struct nl_sock *, int, ...);
00032 extern int              nl_socket_drop_membership(struct nl_sock *,
00033                                                           int);
00034 extern void             nl_join_groups(struct nl_sock *, int);
00035 
00036 
00037 extern uint32_t         nl_socket_get_peer_port(const struct nl_sock *);
00038 extern void             nl_socket_set_peer_port(struct nl_sock *,
00039                                                         uint32_t);
00040 extern uint32_t         nl_socket_get_peer_groups(const struct nl_sock *sk);
00041 extern void             nl_socket_set_peer_groups(struct nl_sock *sk, uint32_t groups);
00042 extern struct nl_cb *   nl_socket_get_cb(const struct nl_sock *);
00043 extern void             nl_socket_set_cb(struct nl_sock *,
00044                                                  struct nl_cb *);
00045 extern int              nl_socket_modify_cb(struct nl_sock *, enum nl_cb_type,
00046                                             enum nl_cb_kind,
00047                                             nl_recvmsg_msg_cb_t, void *);
00048 
00049 extern int              nl_socket_set_buffer_size(struct nl_sock *, int, int);
00050 extern int              nl_socket_set_passcred(struct nl_sock *, int);
00051 extern int              nl_socket_recv_pktinfo(struct nl_sock *, int);
00052 
00053 extern void             nl_socket_disable_seq_check(struct nl_sock *);
00054 extern unsigned int     nl_socket_use_seq(struct nl_sock *);
00055 extern void             nl_socket_disable_auto_ack(struct nl_sock *);
00056 extern void             nl_socket_enable_auto_ack(struct nl_sock *);
00057 
00058 extern int              nl_socket_get_fd(const struct nl_sock *);
00059 extern int              nl_socket_set_nonblocking(const struct nl_sock *);
00060 extern void             nl_socket_enable_msg_peek(struct nl_sock *);
00061 extern void             nl_socket_disable_msg_peek(struct nl_sock *);
00062 
00063 #ifdef __cplusplus
00064 }
00065 #endif
00066 
00067 #endif