diff options
Diffstat (limited to 'net/netlabel/netlabel_user.h')
| -rw-r--r-- | net/netlabel/netlabel_user.h | 141 |
1 files changed, 2 insertions, 139 deletions
diff --git a/net/netlabel/netlabel_user.h b/net/netlabel/netlabel_user.h index 385a6c7488c6..3f9386b917df 100644 --- a/net/netlabel/netlabel_user.h +++ b/net/netlabel/netlabel_user.h | |||
| @@ -41,72 +41,6 @@ | |||
| 41 | /* NetLabel NETLINK helper functions */ | 41 | /* NetLabel NETLINK helper functions */ |
| 42 | 42 | ||
| 43 | /** | 43 | /** |
| 44 | * netlbl_netlink_cap_check - Check the NETLINK msg capabilities | ||
| 45 | * @skb: the NETLINK buffer | ||
| 46 | * @req_cap: the required capability | ||
| 47 | * | ||
| 48 | * Description: | ||
| 49 | * Check the NETLINK buffer's capabilities against the required capabilities. | ||
| 50 | * Returns zero on success, negative values on failure. | ||
| 51 | * | ||
| 52 | */ | ||
| 53 | static inline int netlbl_netlink_cap_check(const struct sk_buff *skb, | ||
| 54 | kernel_cap_t req_cap) | ||
| 55 | { | ||
| 56 | if (cap_raised(NETLINK_CB(skb).eff_cap, req_cap)) | ||
| 57 | return 0; | ||
| 58 | return -EPERM; | ||
| 59 | } | ||
| 60 | |||
| 61 | /** | ||
| 62 | * netlbl_getinc_u8 - Read a u8 value from a nlattr stream and move on | ||
| 63 | * @nla: the attribute | ||
| 64 | * @rem_len: remaining length | ||
| 65 | * | ||
| 66 | * Description: | ||
| 67 | * Return a u8 value pointed to by @nla and advance it to the next attribute. | ||
| 68 | * | ||
| 69 | */ | ||
| 70 | static inline u8 netlbl_getinc_u8(struct nlattr **nla, int *rem_len) | ||
| 71 | { | ||
| 72 | u8 val = nla_get_u8(*nla); | ||
| 73 | *nla = nla_next(*nla, rem_len); | ||
| 74 | return val; | ||
| 75 | } | ||
| 76 | |||
| 77 | /** | ||
| 78 | * netlbl_getinc_u16 - Read a u16 value from a nlattr stream and move on | ||
| 79 | * @nla: the attribute | ||
| 80 | * @rem_len: remaining length | ||
| 81 | * | ||
| 82 | * Description: | ||
| 83 | * Return a u16 value pointed to by @nla and advance it to the next attribute. | ||
| 84 | * | ||
| 85 | */ | ||
| 86 | static inline u16 netlbl_getinc_u16(struct nlattr **nla, int *rem_len) | ||
| 87 | { | ||
| 88 | u16 val = nla_get_u16(*nla); | ||
| 89 | *nla = nla_next(*nla, rem_len); | ||
| 90 | return val; | ||
| 91 | } | ||
| 92 | |||
| 93 | /** | ||
| 94 | * netlbl_getinc_u32 - Read a u32 value from a nlattr stream and move on | ||
| 95 | * @nla: the attribute | ||
| 96 | * @rem_len: remaining length | ||
| 97 | * | ||
| 98 | * Description: | ||
| 99 | * Return a u32 value pointed to by @nla and advance it to the next attribute. | ||
| 100 | * | ||
| 101 | */ | ||
| 102 | static inline u32 netlbl_getinc_u32(struct nlattr **nla, int *rem_len) | ||
| 103 | { | ||
| 104 | u32 val = nla_get_u32(*nla); | ||
| 105 | *nla = nla_next(*nla, rem_len); | ||
| 106 | return val; | ||
| 107 | } | ||
| 108 | |||
| 109 | /** | ||
| 110 | * netlbl_netlink_hdr_put - Write the NETLINK buffers into a sk_buff | 44 | * netlbl_netlink_hdr_put - Write the NETLINK buffers into a sk_buff |
| 111 | * @skb: the packet | 45 | * @skb: the packet |
| 112 | * @pid: the PID of the receipient | 46 | * @pid: the PID of the receipient |
| @@ -124,6 +58,7 @@ static inline void *netlbl_netlink_hdr_put(struct sk_buff *skb, | |||
| 124 | u32 pid, | 58 | u32 pid, |
| 125 | u32 seq, | 59 | u32 seq, |
| 126 | int type, | 60 | int type, |
| 61 | int flags, | ||
| 127 | u8 cmd) | 62 | u8 cmd) |
| 128 | { | 63 | { |
| 129 | return genlmsg_put(skb, | 64 | return genlmsg_put(skb, |
| @@ -131,85 +66,13 @@ static inline void *netlbl_netlink_hdr_put(struct sk_buff *skb, | |||
| 131 | seq, | 66 | seq, |
| 132 | type, | 67 | type, |
| 133 | 0, | 68 | 0, |
| 134 | 0, | 69 | flags, |
| 135 | cmd, | 70 | cmd, |
| 136 | NETLBL_PROTO_VERSION); | 71 | NETLBL_PROTO_VERSION); |
| 137 | } | 72 | } |
| 138 | 73 | ||
| 139 | /** | ||
| 140 | * netlbl_netlink_hdr_push - Write the NETLINK buffers into a sk_buff | ||
| 141 | * @skb: the packet | ||
| 142 | * @pid: the PID of the receipient | ||
| 143 | * @seq: the sequence number | ||
| 144 | * @type: the generic NETLINK message family type | ||
| 145 | * @cmd: command | ||
| 146 | * | ||
| 147 | * Description: | ||
| 148 | * Write both a NETLINK nlmsghdr structure and a Generic NETLINK genlmsghdr | ||
| 149 | * struct to the packet. | ||
| 150 | * | ||
| 151 | */ | ||
| 152 | static inline void netlbl_netlink_hdr_push(struct sk_buff *skb, | ||
| 153 | u32 pid, | ||
| 154 | u32 seq, | ||
| 155 | int type, | ||
| 156 | u8 cmd) | ||
| 157 | |||
| 158 | { | ||
| 159 | struct nlmsghdr *nlh; | ||
| 160 | struct genlmsghdr *hdr; | ||
| 161 | |||
| 162 | nlh = (struct nlmsghdr *)skb_push(skb, NLMSG_SPACE(GENL_HDRLEN)); | ||
| 163 | nlh->nlmsg_type = type; | ||
| 164 | nlh->nlmsg_len = skb->len; | ||
| 165 | nlh->nlmsg_flags = 0; | ||
| 166 | nlh->nlmsg_pid = pid; | ||
| 167 | nlh->nlmsg_seq = seq; | ||
| 168 | |||
| 169 | hdr = nlmsg_data(nlh); | ||
| 170 | hdr->cmd = cmd; | ||
| 171 | hdr->version = NETLBL_PROTO_VERSION; | ||
| 172 | hdr->reserved = 0; | ||
| 173 | } | ||
| 174 | |||
| 175 | /** | ||
| 176 | * netlbl_netlink_payload_len - Return the length of the payload | ||
| 177 | * @skb: the NETLINK buffer | ||
| 178 | * | ||
| 179 | * Description: | ||
| 180 | * This function returns the length of the NetLabel payload. | ||
| 181 | * | ||
| 182 | */ | ||
| 183 | static inline u32 netlbl_netlink_payload_len(const struct sk_buff *skb) | ||
| 184 | { | ||
| 185 | return nlmsg_len((struct nlmsghdr *)skb->data) - GENL_HDRLEN; | ||
| 186 | } | ||
| 187 | |||
| 188 | /** | ||
| 189 | * netlbl_netlink_payload_data - Returns a pointer to the start of the payload | ||
| 190 | * @skb: the NETLINK buffer | ||
| 191 | * | ||
| 192 | * Description: | ||
| 193 | * This function returns a pointer to the start of the NetLabel payload. | ||
| 194 | * | ||
| 195 | */ | ||
| 196 | static inline void *netlbl_netlink_payload_data(const struct sk_buff *skb) | ||
| 197 | { | ||
| 198 | return (unsigned char *)nlmsg_data((struct nlmsghdr *)skb->data) + | ||
| 199 | GENL_HDRLEN; | ||
| 200 | } | ||
| 201 | |||
| 202 | /* NetLabel common protocol functions */ | ||
| 203 | |||
| 204 | void netlbl_netlink_send_ack(const struct genl_info *info, | ||
| 205 | u32 genl_family, | ||
| 206 | u8 ack_cmd, | ||
| 207 | u32 ret_code); | ||
| 208 | |||
| 209 | /* NetLabel NETLINK I/O functions */ | 74 | /* NetLabel NETLINK I/O functions */ |
| 210 | 75 | ||
| 211 | int netlbl_netlink_init(void); | 76 | int netlbl_netlink_init(void); |
| 212 | int netlbl_netlink_snd(struct sk_buff *skb, u32 pid); | ||
| 213 | int netlbl_netlink_snd_multicast(struct sk_buff *skb, u32 pid, u32 group); | ||
| 214 | 77 | ||
| 215 | #endif | 78 | #endif |
