return nla_put(nlmsg, attr, &value, sizeof(value));
}
+extern int nla_put_u16(struct nlmsg *nlmsg, int attr, ushort value)
+{
+ return nla_put(nlmsg, attr, &value, 2);
+}
+
extern int nla_put_attr(struct nlmsg *nlmsg, int attr)
{
return nla_put(nlmsg, attr, NULL, 0);
return ret;
}
+#ifndef NLMSG_ERROR
+#define NLMSG_ERROR 0x2
+#endif
extern int netlink_transaction(struct nl_handler *handler,
struct nlmsg *request, struct nlmsg *answer)
{
if (answer->nlmsghdr.nlmsg_type == NLMSG_ERROR) {
struct nlmsgerr *err = (struct nlmsgerr*)NLMSG_DATA(answer);
errno = -err->error;
+ if (errno)
+ perror("Error configuring kernel");
return -errno;
}
*/
int nla_put_u32(struct nlmsg *nlmsg, int attr, int value);
+/*
+ * nla_put_u16: copy an integer to a netlink message attribute
+ *
+ * @nlmsg: the netlink message to be filled
+ * @attr: the attribute name of the unsigned 16-bit value
+ * @value: 16-bit attribute data value to be copied to the netlink message
+ *
+ * Returns 0 on success, < 0 otherwise
+ */
+int nla_put_u16(struct nlmsg *nlmsg, int attr, ushort value);
+
/*
* nla_put_attr: add an attribute name to a netlink
*
return 0;
}
+
+/* borrowed from iproute2 */
+extern int get_u16(ushort *val, const char *arg, int base)
+{
+ unsigned long res;
+ char *ptr;
+
+ if (!arg || !*arg)
+ return -1;
+
+ res = strtoul(arg, &ptr, base);
+ if (!ptr || ptr == arg || *ptr || res > 0xFFFF)
+ return -1;
+
+ *val = res;
+
+ return 0;
+}
+
extern int lxc_close_inherited_fd(int fd);
extern int lxc_close_all_inherited_fd(void);
extern int lxc_setup_fs(void);
+extern int get_u16(ushort *val, const char *arg, int base);