1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251
|
.\" t
.\" Don't change the first line, it tells man that tbl is needed.
.\" This man page copyright 1998 by Andi Kleen. Subject to the GPL.
.\" This manpage copyright 1998 by Andi Kleen. Subject to the GPL.
.\" Based on the original comments from Alexey Kuznetsov
.\" $Id: netlink.7,v 1.1.1.1 2000/12/27 12:24:46 BitBIRD Exp $
.\" İ Copyright (c) 2000 LetBrightBitBIRD www.linuxforum.net
.TH NETLINK 7 "27 Apr 1999" "Linux Man Page" "Linux Programmer's Manual"
.SH NAME
netlink, PF_NETLINK \- ںû֮ͨѶ
.SH SYNOPSIS
.nf
.\" XXX
.B #include <asm/types.h>
.br
.B #include <sys/socket.h>
.br
.B #include <linux/netlink.h>
.br
.PP
.BI "netlink_socket = socket(PF_NETLINK, " socket_type ", " netlink_family );
.SH DESCRIPTION
Netlink ںģûַռеĽ֮䴫Ϣġ
û̵ĻڱֵĽӿںںģһڲ
APIйڲĽӿڵûаڴֲҳСͬ
һʱͨ netlink ַ豸ĽӿҲûаڴˣֻṩ
¼ԡ
Netlink һݰķ
.B SOCK_RAW
.B SOCK_DGRAM
.IR socket_type
ЧֵȻ netlink Эݰ datagram ԭ֣raw sockets
֡
.I netlink_family
ѡģ netlink ͨѶпָ netlink У
.TP
.B NETLINK_ROUTE
·ɸϢ IPv4 ·ɱ(μ
.BR rtnetlink (7))
.TP
.B NETLINK_FIREWALL
IPv4 ǽ뷢͵ݰ
.TP
.B NETLINK_ARPD
άûַռ arp
.TP
.B NETLINK_ROUTE6
պͷ IPv6 ·ɱϢ
.TP
.B NETLINK_IP6_FW
δͨ IPv6 ǽݰ(δʵ)
.TP
.BR NETLINK_TAPBASE ... NETLINK_TAPBASE+15
.B ethertap
豸ʵEthertap Ǵûռ̫
ġαͨ豸
.TP
.B NETLINK_SKIP
Enskip ıѡ
.TP
.B NETLINK_USERSOCK
ΪûռЭñѡ
.PP
Netlink Ϣɾһ
.B nlmsghdr
ݱͷЧݵֽɡڷֳɶݰ Netlink Ϣ
ݱͷе
.B NLM_F_MULTI
־λãһıͷб־
.BR NLMSG_DONE ⡣
ֽӦֻñ
.B NLMSG_*
ʣ
.BR netlink (3).
Netlink ǿɿЭ顣ֻǾܵؽϢ䵽Ŀĵأڴ
ʱᶪʧϢΪ֤Ϣɿ䣬ñ־
.B NLM_F_ACK
Ҫշȷϡݽȷһ
.B NLMSG_ERROR
ݰеijֶΪ 0ӦóԼյϢȷϢ
ϢУںһֱ()ÿݰ
.B NLMSG_ERROR
ϢûҲӦѭһ
ÿһ netlink һ32λ㲥飬
ֵ
.BR bind (2)
ʱ
.B sockaddr_nl
е
.B nl_groups
ֶóҪĹ㲥λ롣ĬֵΪ 0ʾκι㲥
һֿԶһַ㲥㲥ϢֻҪڵ
.BR sendmsg (2)
.BR connect (2)
ʱλ
.B nl_groups
óҪϢĹ㲥ֵͿˡ
ֻоЧ uid Ϊ 0 û
.B CAP_NET_ADMIN
Ȩûſܷͻ netlink ַ㲥Ϣ
κһԶַ㲥ϢӦ跢ؽ̱ʶ pid 㲥ַ
.RS
.nf
.ta 4 13 25
struct nlmsghdr
{
__u32 nlmsg_len; /* ͷڵϢ*/
__u16 nlmsg_type; /* Ϣ */
__u16 nlmsg_flags; /* ӱ־*/
__u32 nlmsg_seq; /* к*/
__u32 nlmsg_pid; /* ͽ̺ PID */
};
struct nlmsgerr
{
int error; /* ʾij errno Ϊ 0 Ҫȷ acks*/
struct nlmsghdr msg; /* ɳϢͷ*/
};
.ta
.fi
.RE
ÿ
.B nlmsghdr
Чݡ
.B nlmsg_type
ԳΪϢͣ
.B NLMSG_NOOP
ԺԵϢ
.B NLMSG_ERROR
Ϣйаһ
.I nlmsgerr
ṹ
.B NLMSG_DONE
һݰϢϢ
.\" 2.1.130 ʹ
.\" .B NLMSG_OVERRUN
.\" ݶ.
һ netlink ָͨϢͣйֲҳ
.IR NETLINK_ROUTE .
е
.BR rtnetlink (7)
.TS
tab(:);
l s
l l.
nlmsg_flags ı־λ
NLM_F_REQUEST: ȫϢ
NLM_F_MULTI:T{
ϢǶݰϢ֮һͨ־
.B NLMSG_DONE
.\" XXX describe that
T}
NLM_F_ACK: ݳɹշȷϢ
NLM_F_ECHO: ҪӦϢ
.TE
.TS
tab(:);
l s
l l.
Ϊ GET ĸӱ־λ
NLM_F_ROOT: ضǵ
NLM_F_MATCH: δʵ
NLM_F_ATOMIC: ضԭӿ(atomic snapshot)
NLM_F_DUMP: δĵ
.TE
.TS
tab(:);
l s
l l.
½ NEW ĸӱ־λ
NLM_F_REPLACE: 滻еĶ
NLM_F_EXCL: Ѵڣ滻
NLM_F_CREATE:
NLM_F_APPEND: Ӷ
.TE
ע NLM_F_ATOMIC Ҫû CAP_NET_ADMIN ûȨ
.SH ַʽ
.B sockaddr_nl
ûռںĿռһ netlink ͻݽṹ
һ sockaddr_nl ǵַ㲥һ netlink ַ
(nl_groups Ϊ 0).
.RS
.nf
struct sockaddr_nl
{
sa_family_t nl_family; /* AF_NETLINK */
unsigned short nl_pad; /* */
pid_t nl_pid; /* ̱ʶpid */
__u32 nl_groups; /* ַ㲥*/
};
.fi
.RE
.B nl_pid
ûռ netlink Ḻ̌ʶ pidںʱֵΪ 0
.B nl_groups
һ neltlink ŵλ롣
.\" XXX describe what that is.
.SH BUGS
ֲҳ
.SH NOTES ע
ͨ
.B libnetlink
netlink ͨͨͲں˽ӿҪúЩ
.SH VERSIONS 汾
netlink ֽӿ Linux 2.2
Linux 2.0 ָ֧Ļnetlinkӿڵԭʼ豸(Ϊ¼ԣ
Щ豸ĿǰԿʹáɽӿûڴ
.SH
.BR cmsg (3),
.BR rtnetlink (7),
.BR netlink (3).
.PP
.BR ftp://ftp.inr.ac.ru/ip-routing/iproute2*
й libnetlink
.SH "[İά]"
LetBright E-mail:letbright@netease.com
.SH "[ݸ]" 2000/11/09
.br
.B й Linux ̳ man ֲҳƻ:www.cmpp.net/
|