2 * NetLabel NETLINK Interface
4 * This file defines the NETLINK interface for the NetLabel system. The
5 * NetLabel system manages static and dynamic label mappings for network
6 * protocols such as CIPSO and RIPSO.
8 * Author: Paul Moore <paul.moore@hp.com>
13 * (c) Copyright Hewlett-Packard Development Company, L.P., 2006
15 * This program is free software; you can redistribute it and/or modify
16 * it under the terms of the GNU General Public License as published by
17 * the Free Software Foundation; either version 2 of the License, or
18 * (at your option) any later version.
20 * This program is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
23 * the GNU General Public License for more details.
25 * You should have received a copy of the GNU General Public License
26 * along with this program; if not, write to the Free Software
27 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
31 #include <linux/init.h>
32 #include <linux/types.h>
33 #include <linux/list.h>
34 #include <linux/socket.h>
36 #include <net/netlink.h>
37 #include <net/genetlink.h>
38 #include <net/netlabel.h>
41 #include "netlabel_mgmt.h"
42 #include "netlabel_unlabeled.h"
43 #include "netlabel_cipso_v4.h"
44 #include "netlabel_user.h"
47 * NetLabel NETLINK Setup Functions
51 * netlbl_netlink_init - Initialize the NETLINK communication channel
54 * Call out to the NetLabel components so they can register their families and
55 * commands with the Generic NETLINK mechanism. Returns zero on success and
56 * non-zero on failure.
59 int netlbl_netlink_init(void)
63 ret_val
= netlbl_mgmt_genl_init();
67 ret_val
= netlbl_cipsov4_genl_init();
71 ret_val
= netlbl_unlabel_genl_init();
79 * NetLabel Common Protocol Functions
83 * netlbl_netlink_send_ack - Send an ACK message
84 * @info: the generic NETLINK information
85 * @genl_family: the generic NETLINK family ID value
86 * @ack_cmd: the generic NETLINK family ACK command value
87 * @ret_code: return code to use
90 * This function sends an ACK message to the sender of the NETLINK message
94 void netlbl_netlink_send_ack(const struct genl_info
*info
,
102 data_size
= GENL_HDRLEN
+ 2 * NETLBL_LEN_U32
;
103 skb
= netlbl_netlink_alloc_skb(0, data_size
, GFP_KERNEL
);
107 if (netlbl_netlink_hdr_put(skb
,
112 goto send_ack_failure
;
114 if (nla_put_u32(skb
, NLA_U32
, info
->snd_seq
) != 0)
115 goto send_ack_failure
;
116 if (nla_put_u32(skb
, NLA_U32
, ret_code
) != 0)
117 goto send_ack_failure
;
119 netlbl_netlink_snd(skb
, info
->snd_pid
);
127 * NETLINK I/O Functions
131 * netlbl_netlink_snd - Send a NetLabel message
132 * @skb: NetLabel message
133 * @pid: destination PID
136 * Sends a unicast NetLabel message over the NETLINK socket.
139 int netlbl_netlink_snd(struct sk_buff
*skb
, u32 pid
)
141 return genlmsg_unicast(skb
, pid
);
145 * netlbl_netlink_snd - Send a NetLabel message
146 * @skb: NetLabel message
148 * @group: multicast group id
151 * Sends a multicast NetLabel message over the NETLINK socket to all members
152 * of @group except @pid.
155 int netlbl_netlink_snd_multicast(struct sk_buff
*skb
, u32 pid
, u32 group
)
157 return genlmsg_multicast(skb
, pid
, group
, GFP_KERNEL
);
This page took 0.046939 seconds and 6 git commands to generate.