• Home
  • History
  • Annotate
  • Line#
  • Navigate
  • Raw
  • Download
  • only in /netgear-R7000-V1.0.7.12_1.2.5/ap/gpl/conntrack-tools/conntrack-tools-1.4.0/include/
1#ifndef _UDP_H_
2#define _UDP_H_
3
4#include <stdint.h>
5#include <netinet/in.h>
6
7struct udp_conf {
8	int ipproto;
9	int reuseaddr;
10	int checksum;
11	unsigned short port;
12	union {
13		struct {
14			struct in_addr inet_addr;
15		} ipv4;
16		struct {
17			struct in6_addr inet_addr6;
18			int scope_id;
19		} ipv6;
20	} server;
21	union {
22		struct in_addr inet_addr;
23		struct in6_addr inet_addr6;
24	} client;
25	int sndbuf;
26	int rcvbuf;
27};
28
29struct udp_stats {
30	uint64_t bytes;
31	uint64_t messages;
32	uint64_t error;
33};
34
35struct udp_sock {
36	int fd;
37	union {
38		struct sockaddr_in ipv4;
39		struct sockaddr_in6 ipv6;
40	} addr;
41	socklen_t sockaddr_len;
42	struct udp_stats stats;
43};
44
45struct udp_sock *udp_server_create(struct udp_conf *conf);
46void udp_server_destroy(struct udp_sock *m);
47
48struct udp_sock *udp_client_create(struct udp_conf *conf);
49void udp_client_destroy(struct udp_sock *m);
50
51ssize_t udp_send(struct udp_sock *m, const void *data, int size);
52ssize_t udp_recv(struct udp_sock *m, void *data, int size);
53
54int udp_get_fd(struct udp_sock *m);
55int udp_isset(struct udp_sock *m, fd_set *readfds);
56
57int udp_snprintf_stats(char *buf, size_t buflen, char *ifname,
58		       struct udp_stats *s, struct udp_stats *r);
59
60int udp_snprintf_stats2(char *buf, size_t buflen, const char *ifname,
61			const char *status, int active,
62			struct udp_stats *s, struct udp_stats *r);
63
64#endif
65