netlink.h
Go to the documentation of this file.00001
#ifndef __LINUX_NETLINK_H
00002
#define __LINUX_NETLINK_H
00003
00004 #define NETLINK_ROUTE 0
00005 #define NETLINK_SKIP 1
00006 #define NETLINK_USERSOCK 2
00007 #define NETLINK_FIREWALL 3
00008 #define NETLINK_TCPDIAG 4
00009 #define NETLINK_NFLOG 5
00010 #define NETLINK_ARPD 8
00011 #define NETLINK_ROUTE6 11
00012 #define NETLINK_IP6_FW 13
00013 #define NETLINK_DNRTMSG 14
00014 #define NETLINK_TAPBASE 16
00015
00016 #define MAX_LINKS 32
00017
00018 struct sockaddr_nl
00019 {
00020 sa_family_t
nl_family;
00021 unsigned short nl_pad;
00022 __u32
nl_pid;
00023 __u32
nl_groups;
00024 };
00025
00026 struct nlmsghdr
00027 {
00028 __u32
nlmsg_len;
00029 __u16
nlmsg_type;
00030 __u16
nlmsg_flags;
00031 __u32
nlmsg_seq;
00032 __u32
nlmsg_pid;
00033 };
00034
00035
00036
00037 #define NLM_F_REQUEST 1
00038 #define NLM_F_MULTI 2
00039 #define NLM_F_ACK 4
00040 #define NLM_F_ECHO 8
00041
00042
00043 #define NLM_F_ROOT 0x100
00044 #define NLM_F_MATCH 0x200
00045 #define NLM_F_ATOMIC 0x400
00046 #define NLM_F_DUMP (NLM_F_ROOT|NLM_F_MATCH)
00047
00048
00049 #define NLM_F_REPLACE 0x100
00050 #define NLM_F_EXCL 0x200
00051 #define NLM_F_CREATE 0x400
00052 #define NLM_F_APPEND 0x800
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063 #define NLMSG_ALIGNTO 4
00064 #define NLMSG_ALIGN(len) ( ((len)+NLMSG_ALIGNTO-1) & ~(NLMSG_ALIGNTO-1) )
00065 #define NLMSG_LENGTH(len) ((len)+NLMSG_ALIGN(sizeof(struct nlmsghdr)))
00066 #define NLMSG_SPACE(len) NLMSG_ALIGN(NLMSG_LENGTH(len))
00067 #define NLMSG_DATA(nlh) ((void*)(((char*)nlh) + NLMSG_LENGTH(0)))
00068 #define NLMSG_NEXT(nlh,len) ((len) -= NLMSG_ALIGN((nlh)->nlmsg_len), \
00069
(struct nlmsghdr*)(((char*)(nlh)) + NLMSG_ALIGN((nlh)->nlmsg_len)))
00070 #define NLMSG_OK(nlh,len) ((len) > 0 && (nlh)->nlmsg_len >= sizeof(struct nlmsghdr) && \
00071
(nlh)->nlmsg_len <= (len))
00072 #define NLMSG_PAYLOAD(nlh,len) ((nlh)->nlmsg_len - NLMSG_SPACE((len)))
00073
00074 #define NLMSG_NOOP 0x1
00075 #define NLMSG_ERROR 0x2
00076 #define NLMSG_DONE 0x3
00077 #define NLMSG_OVERRUN 0x4
00078
00079 struct nlmsgerr
00080 {
00081 int error;
00082 struct nlmsghdr msg;
00083 };
00084
00085 #define NET_MAJOR 36
00086
00087
#ifdef __KERNEL__
00088
00089 struct netlink_skb_parms
00090 {
00091 struct ucred creds;
00092 __u32
pid;
00093 __u32
groups;
00094 __u32
dst_pid;
00095 __u32
dst_groups;
00096 kernel_cap_t
eff_cap;
00097 };
00098
00099 #define NETLINK_CB(skb) (*(struct netlink_skb_parms*)&((skb)->cb))
00100 #define NETLINK_CREDS(skb) (&NETLINK_CB((skb)).creds)
00101
00102
00103
extern int netlink_attach(
int unit,
int (*function)(
int,
struct sk_buff *skb));
00104
extern void netlink_detach(
int unit);
00105
extern int netlink_post(
int unit,
struct sk_buff *skb);
00106
extern int init_netlink(
void);
00107
extern struct sock *
netlink_kernel_create(
int unit,
void (*input)(
struct sock *sk,
int len));
00108
extern void netlink_ack(
struct sk_buff *in_skb,
struct nlmsghdr *nlh,
int err);
00109
extern int netlink_unicast(
struct sock *ssk,
struct sk_buff *skb, __u32 pid,
int nonblock);
00110
extern void netlink_broadcast(
struct sock *ssk,
struct sk_buff *skb, __u32 pid,
00111 __u32 group,
int allocation);
00112
extern void netlink_set_err(
struct sock *ssk, __u32 pid, __u32 group,
int code);
00113
extern int netlink_register_notifier(
struct notifier_block *nb);
00114
extern int netlink_unregister_notifier(
struct notifier_block *nb);
00115
00116
00117
00118
00119
00120
00121 #define NLMSG_GOODSIZE (PAGE_SIZE - ((sizeof(struct sk_buff)+0xF)&~0xF))
00122
00123
00124 struct netlink_callback
00125 {
00126 struct sk_buff *
skb;
00127 struct nlmsghdr *
nlh;
00128 int (*dump)(
struct sk_buff *
skb,
struct netlink_callback *cb);
00129 int (*done)(
struct netlink_callback *cb);
00130 int family;
00131 long args[4];
00132 };
00133
00134 struct netlink_notify
00135 {
00136 int pid;
00137 int protocol;
00138 };
00139
00140
static __inline__
struct nlmsghdr *
00141 __nlmsg_put(
struct sk_buff *skb, u32 pid, u32 seq,
int type,
int len)
00142 {
00143
struct nlmsghdr *nlh;
00144
int size =
NLMSG_LENGTH(len);
00145
00146 nlh = (
struct nlmsghdr*)
skb_put(skb,
NLMSG_ALIGN(size));
00147 nlh->nlmsg_type = type;
00148 nlh->nlmsg_len = size;
00149 nlh->nlmsg_flags = 0;
00150 nlh->nlmsg_pid = pid;
00151 nlh->nlmsg_seq = seq;
00152
return nlh;
00153 }
00154
00155 #define NLMSG_PUT(skb, pid, seq, type, len) \
00156
({ if (skb_tailroom(skb) < (int)NLMSG_SPACE(len)) goto nlmsg_failure; \
00157
__nlmsg_put(skb, pid, seq, type, len); })
00158
00159
extern int netlink_dump_start(
struct sock *ssk,
struct sk_buff *skb,
00160
struct nlmsghdr *nlh,
00161
int (*dump)(
struct sk_buff *skb,
struct netlink_callback*),
00162
int (*done)(
struct netlink_callback*));
00163
00164 #define NL_NONROOT_RECV 0x1
00165 #define NL_NONROOT_SEND 0x2
00166
extern void netlink_set_nonroot(
int protocol,
unsigned flag);
00167
00168
00169
#endif
00170
00171
#endif
Generated on Wed Dec 1 21:25:32 2004 for Linux 2.4.23 Networking by
1.3.8