autoconf: Tolerate missing file when grepping.
[sliver-openvswitch.git] / lib / netlink.h
index 64452e9..9cb1f81 100644 (file)
@@ -1,17 +1,17 @@
 /*
- * Copyright (c) 2008, 2009 Nicira Networks.
+ * Copyright (c) 2008, 2009, 2010 Nicira Networks.
  *
- * Permission to use, copy, modify, and/or distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
  *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
  */
 
 #ifndef NETLINK_H
@@ -49,6 +49,19 @@ int nl_sock_transact(struct nl_sock *, const struct ofpbuf *request,
                      struct ofpbuf **reply);
 
 void nl_sock_wait(const struct nl_sock *, short int events);
+
+/* Table dumping. */
+struct nl_dump {
+    struct nl_sock *sock;       /* Socket being dumped. */
+    uint32_t seq;               /* Expected nlmsg_seq for replies. */
+    struct ofpbuf *buffer;      /* Receive buffer currently being iterated. */
+    int status;                 /* 0=OK, EOF=done, or positive errno value. */
+};
+
+void nl_dump_start(struct nl_dump *, struct nl_sock *,
+                   const struct ofpbuf *request);
+bool nl_dump_next(struct nl_dump *, struct ofpbuf *reply);
+int nl_dump_done(struct nl_dump *);
 \f
 /* Netlink messages. */
 
@@ -59,11 +72,10 @@ bool nl_msg_nlmsgerr(const struct ofpbuf *, int *error);
 void nl_msg_reserve(struct ofpbuf *, size_t);
 
 /* Appending headers and raw data. */
-void nl_msg_put_nlmsghdr(struct ofpbuf *, struct nl_sock *,
-                         size_t expected_payload,
+void nl_msg_put_nlmsghdr(struct ofpbuf *, size_t expected_payload,
                          uint32_t type, uint32_t flags);
-void nl_msg_put_genlmsghdr(struct ofpbuf *, struct nl_sock *,
-                           size_t expected_payload, int family, uint32_t flags,
+void nl_msg_put_genlmsghdr(struct ofpbuf *, size_t expected_payload,
+                           int family, uint32_t flags,
                            uint8_t cmd, uint8_t version);
 void nl_msg_put(struct ofpbuf *, const void *, size_t);
 void *nl_msg_put_uninit(struct ofpbuf *, size_t);
@@ -77,7 +89,14 @@ void nl_msg_put_u16(struct ofpbuf *, uint16_t type, uint16_t value);
 void nl_msg_put_u32(struct ofpbuf *, uint16_t type, uint32_t value);
 void nl_msg_put_u64(struct ofpbuf *, uint16_t type, uint64_t value);
 void nl_msg_put_string(struct ofpbuf *, uint16_t type, const char *value);
-void nl_msg_put_nested(struct ofpbuf *, uint16_t type, struct ofpbuf *);
+
+size_t nl_msg_start_nested(struct ofpbuf *, uint16_t type);
+void nl_msg_end_nested(struct ofpbuf *, size_t offset);
+void nl_msg_put_nested(struct ofpbuf *, uint16_t type,
+                       const void *data, size_t size);
+
+/* Separating buffers into individual messages. */
+struct nlmsghdr *nl_msg_next(struct ofpbuf *buffer, struct ofpbuf *msg);
 \f
 /* Netlink attribute types. */
 enum nl_attr_type
@@ -104,6 +123,7 @@ uint16_t nl_attr_get_u16(const struct nlattr *);
 uint32_t nl_attr_get_u32(const struct nlattr *);
 uint64_t nl_attr_get_u64(const struct nlattr *);
 const char *nl_attr_get_string(const struct nlattr *);
+void nl_attr_get_nested(const struct nlattr *, struct ofpbuf *);
 
 /* Netlink attribute policy.
  *
@@ -119,6 +139,8 @@ struct nl_policy
 bool nl_policy_parse(const struct ofpbuf *, size_t offset,
                      const struct nl_policy[],
                      struct nlattr *[], size_t n_attrs);
+bool nl_parse_nested(const struct nlattr *, const struct nl_policy[],
+                     struct nlattr *[], size_t n_attrs);
 \f
 /* Miscellaneous. */