~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

Linux Cross Reference
Linux/include/linux/netlink.h

Version: ~ [ 2.4.0 ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 #ifndef __LINUX_NETLINK_H
  2 #define __LINUX_NETLINK_H
  3 
  4 #define NETLINK_ROUTE           0       /* Routing/device hook                          */
  5 #define NETLINK_SKIP            1       /* Reserved for ENskip                          */
  6 #define NETLINK_USERSOCK        2       /* Reserved for user mode socket protocols      */
  7 #define NETLINK_FIREWALL        3       /* Firewalling hook                             */
  8 #define NETLINK_ARPD            8
  9 #define NETLINK_ROUTE6          11      /* af_inet6 route comm channel */
 10 #define NETLINK_IP6_FW          13
 11 #define NETLINK_DNRTMSG         14      /* DECnet routing messages */
 12 #define NETLINK_TAPBASE         16      /* 16 to 31 are ethertap */
 13 
 14 #define MAX_LINKS 32            
 15 
 16 struct sockaddr_nl
 17 {
 18         sa_family_t     nl_family;      /* AF_NETLINK   */
 19         unsigned short  nl_pad;         /* zero         */
 20         __u32           nl_pid;         /* process pid  */
 21         __u32           nl_groups;      /* multicast groups mask */
 22 };
 23 
 24 struct nlmsghdr
 25 {
 26         __u32           nlmsg_len;      /* Length of message including header */
 27         __u16           nlmsg_type;     /* Message content */
 28         __u16           nlmsg_flags;    /* Additional flags */
 29         __u32           nlmsg_seq;      /* Sequence number */
 30         __u32           nlmsg_pid;      /* Sending process PID */
 31 };
 32 
 33 /* Flags values */
 34 
 35 #define NLM_F_REQUEST           1       /* It is request message.       */
 36 #define NLM_F_MULTI             2       /* Multipart message, terminated by NLMSG_DONE */
 37 #define NLM_F_ACK               4       /* If succeed, reply with ack   */
 38 #define NLM_F_ECHO              8       /* Echo this request            */
 39 
 40 /* Modifiers to GET request */
 41 #define NLM_F_ROOT      0x100   /* specify tree root    */
 42 #define NLM_F_MATCH     0x200   /* return all matching  */
 43 #define NLM_F_ATOMIC    0x400   /* atomic GET           */
 44 #define NLM_F_DUMP      (NLM_F_ROOT|NLM_F_MATCH)
 45 
 46 /* Modifiers to NEW request */
 47 #define NLM_F_REPLACE   0x100   /* Override existing            */
 48 #define NLM_F_EXCL      0x200   /* Do not touch, if it exists   */
 49 #define NLM_F_CREATE    0x400   /* Create, if it does not exist */
 50 #define NLM_F_APPEND    0x800   /* Add to end of list           */
 51 
 52 /*
 53    4.4BSD ADD           NLM_F_CREATE|NLM_F_EXCL
 54    4.4BSD CHANGE        NLM_F_REPLACE
 55 
 56    True CHANGE          NLM_F_CREATE|NLM_F_REPLACE
 57    Append               NLM_F_CREATE
 58    Check                NLM_F_EXCL
 59  */
 60 
 61 #define NLMSG_ALIGNTO   4
 62 #define NLMSG_ALIGN(len) ( ((len)+NLMSG_ALIGNTO-1) & ~(NLMSG_ALIGNTO-1) )
 63 #define NLMSG_LENGTH(len) ((len)+NLMSG_ALIGN(sizeof(struct nlmsghdr)))
 64 #define NLMSG_SPACE(len) NLMSG_ALIGN(NLMSG_LENGTH(len))
 65 #define NLMSG_DATA(nlh)  ((void*)(((char*)nlh) + NLMSG_LENGTH(0)))
 66 #define NLMSG_NEXT(nlh,len)      ((len) -= NLMSG_ALIGN((nlh)->nlmsg_len), \
 67                                   (struct nlmsghdr*)(((char*)(nlh)) + NLMSG_ALIGN((nlh)->nlmsg_len)))
 68 #define NLMSG_OK(nlh,len) ((len) > 0 && (nlh)->nlmsg_len >= sizeof(struct nlmsghdr) && \
 69                            (nlh)->nlmsg_len <= (len))
 70 #define NLMSG_PAYLOAD(nlh,len) ((nlh)->nlmsg_len - NLMSG_SPACE((len)))
 71 
 72 #define NLMSG_NOOP              0x1     /* Nothing.             */
 73 #define NLMSG_ERROR             0x2     /* Error                */
 74 #define NLMSG_DONE              0x3     /* End of a dump        */
 75 #define NLMSG_OVERRUN           0x4     /* Data lost            */
 76 
 77 struct nlmsgerr
 78 {
 79         int             error;
 80         struct nlmsghdr msg;
 81 };
 82 
 83 #define NET_MAJOR 36            /* Major 36 is reserved for networking                                          */
 84 
 85 #ifdef __KERNEL__
 86 
 87 struct netlink_skb_parms
 88 {
 89         struct ucred            creds;          /* Skb credentials      */
 90         __u32                   pid;
 91         __u32                   groups;
 92         __u32                   dst_pid;
 93         __u32                   dst_groups;
 94         kernel_cap_t            eff_cap;
 95 };
 96 
 97 #define NETLINK_CB(skb)         (*(struct netlink_skb_parms*)&((skb)->cb))
 98 #define NETLINK_CREDS(skb)      (&NETLINK_CB((skb)).creds)
 99 
100 
101 extern int netlink_attach(int unit, int (*function)(int,struct sk_buff *skb));
102 extern void netlink_detach(int unit);
103 extern int netlink_post(int unit, struct sk_buff *skb);
104 extern int init_netlink(void);
105 extern struct sock *netlink_kernel_create(int unit, void (*input)(struct sock *sk, int len));
106 extern void netlink_ack(struct sk_buff *in_skb, struct nlmsghdr *nlh, int err);
107 extern int netlink_unicast(struct sock *ssk, struct sk_buff *skb, __u32 pid, int nonblock);
108 extern void netlink_broadcast(struct sock *ssk, struct sk_buff *skb, __u32 pid,
109                               __u32 group, int allocation);
110 extern void netlink_set_err(struct sock *ssk, __u32 pid, __u32 group, int code);
111 
112 /*
113  *      skb should fit one page. This choice is good for headerless malloc.
114  *
115  *      FIXME: What is the best size for SLAB???? --ANK
116  */
117 #define NLMSG_GOODSIZE (PAGE_SIZE - ((sizeof(struct sk_buff)+0xF)&~0xF))
118 
119 
120 struct netlink_callback
121 {
122         struct sk_buff  *skb;
123         struct nlmsghdr *nlh;
124         int             (*dump)(struct sk_buff * skb, struct netlink_callback *cb);
125         int             (*done)(struct netlink_callback *cb);
126         int             family;
127         long            args[4];
128 };
129 
130 extern __inline__ struct nlmsghdr *
131 __nlmsg_put(struct sk_buff *skb, u32 pid, u32 seq, int type, int len)
132 {
133         struct nlmsghdr *nlh;
134         int size = NLMSG_LENGTH(len);
135 
136         nlh = (struct nlmsghdr*)skb_put(skb, NLMSG_ALIGN(size));
137         nlh->nlmsg_type = type;
138         nlh->nlmsg_len = size;
139         nlh->nlmsg_flags = 0;
140         nlh->nlmsg_pid = pid;
141         nlh->nlmsg_seq = seq;
142         return nlh;
143 }
144 
145 #define NLMSG_PUT(skb, pid, seq, type, len) \
146 ({ if (skb_tailroom(skb) < (int)NLMSG_SPACE(len)) goto nlmsg_failure; \
147    __nlmsg_put(skb, pid, seq, type, len); })
148 
149 extern int netlink_dump_start(struct sock *ssk, struct sk_buff *skb,
150                               struct nlmsghdr *nlh,
151                               int (*dump)(struct sk_buff *skb, struct netlink_callback*),
152                               int (*done)(struct netlink_callback*));
153 
154 
155 #endif /* __KERNEL__ */
156 
157 #endif  /* __LINUX_NETLINK_H */
158 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

This page was automatically generated by the LXR engine.
Visit the LXR main site for more information.