summaryrefslogtreecommitdiffstats
path: root/include/udp.h
diff options
context:
space:
mode:
authorPablo Neira Ayuso <pablo@netfilter.org>2009-03-13 14:00:59 +0100
committerPablo Neira Ayuso <pablo@netfilter.org>2009-03-13 14:00:59 +0100
commit41e8560ea7c09533d03f523380c1cb5c62d87261 (patch)
tree684fdff336751ef76b1527c8f9de6af968701b4c /include/udp.h
parent338d8fc2da19f5d6a75c339d9e6ecac43b68a1e4 (diff)
sync-mode: add unicast UDP support to propagate state-changes
This patch adds support for unicast UDP to the channel infrastructure. With this patch, you can select UDP unicast to propagate state-changes instead of multicast. Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Diffstat (limited to 'include/udp.h')
-rw-r--r--include/udp.h58
1 files changed, 58 insertions, 0 deletions
diff --git a/include/udp.h b/include/udp.h
new file mode 100644
index 0000000..02b8af1
--- /dev/null
+++ b/include/udp.h
@@ -0,0 +1,58 @@
+#ifndef _UDP_H_
+#define _UDP_H_
+
+#include <stdint.h>
+#include <netinet/in.h>
+
+struct udp_conf {
+ int ipproto;
+ int reuseaddr;
+ int checksum;
+ unsigned short port;
+ union {
+ struct in_addr inet_addr;
+ struct in6_addr inet_addr6;
+ } server;
+ union {
+ struct in_addr inet_addr;
+ struct in6_addr inet_addr6;
+ } client;
+ int sndbuf;
+ int rcvbuf;
+};
+
+struct udp_stats {
+ uint64_t bytes;
+ uint64_t messages;
+ uint64_t error;
+};
+
+struct udp_sock {
+ int fd;
+ union {
+ struct sockaddr_in ipv4;
+ struct sockaddr_in6 ipv6;
+ } addr;
+ socklen_t sockaddr_len;
+ struct udp_stats stats;
+};
+
+struct udp_sock *udp_server_create(struct udp_conf *conf);
+void udp_server_destroy(struct udp_sock *m);
+
+struct udp_sock *udp_client_create(struct udp_conf *conf);
+void udp_client_destroy(struct udp_sock *m);
+
+ssize_t udp_send(struct udp_sock *m, const void *data, int size);
+ssize_t udp_recv(struct udp_sock *m, void *data, int size);
+
+int udp_get_fd(struct udp_sock *m);
+
+int udp_snprintf_stats(char *buf, size_t buflen, char *ifname,
+ struct udp_stats *s, struct udp_stats *r);
+
+int udp_snprintf_stats2(char *buf, size_t buflen, const char *ifname,
+ const char *status, int active,
+ struct udp_stats *s, struct udp_stats *r);
+
+#endif