aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTushar Pankaj <tushar.s.pankaj@gmail.com>2018-11-12 17:13:32 -0600
committerTushar Pankaj <tushar.s.pankaj@gmail.com>2018-11-12 17:13:32 -0600
commit5d717e37baaa9882ea2356fa24a2b85beaf51558 (patch)
tree1e0d243960a62af56528c8e1ecdcb2d08c18046c
parentStyle fixes (diff)
downloadwg-dynamic-5d717e37baaa9882ea2356fa24a2b85beaf51558.tar.xz
wg-dynamic-5d717e37baaa9882ea2356fa24a2b85beaf51558.zip
Add IP addr structs to protocol
Signed-off-by: Tushar Pankaj <tushar.s.pankaj@gmail.com>
-rw-r--r--protocol.capnp20
-rw-r--r--protocol.capnp.c86
-rw-r--r--protocol.capnp.h50
3 files changed, 133 insertions, 23 deletions
diff --git a/protocol.capnp b/protocol.capnp
index 64463e9..69f5db4 100644
--- a/protocol.capnp
+++ b/protocol.capnp
@@ -14,11 +14,21 @@ struct WgClientMsg {
}
}
+# IPv4 address
+struct WgIpv4Addr {
+ addr @0 :UInt32; # IPv4 address
+ cidr @1 :UInt8; # CIDR of IPv4 address
+}
+
+# IPv6 address
+struct WgIpv6Addr {
+ addr @0 :Data; # IPv6 address
+ cidr @1: UInt8; # CIDR of IPv6 address
+}
+
# server response message
struct WgServerSimpleMsg {
- leasedIpv4 @0 :UInt32; # dynamic IPv4 leased to client
- leasedIpv4Cidr @1 :UInt32; # CIDR of dynamic IPv4 leased to client
- leaseTimeout @2 :UInt32; # activity timeout for the IP lease in seconds
- route @3 :UInt32; # route for client
- routeCidr @4 :UInt32; # CIDR of route for client
+ leasedIpv4 @0 :WgIpv4Addr; # dynamic IPv4 leased to client
+ leaseTimeout @1 :UInt32; # activity timeout for the IP lease in seconds
+ ipv4Routes @2 :List(WgIpv4Addr); # IPv4 routes for client
}
diff --git a/protocol.capnp.c b/protocol.capnp.c
index a536f31..b13f7c6 100644
--- a/protocol.capnp.c
+++ b/protocol.capnp.c
@@ -40,33 +40,95 @@ void set_WgClientMsg(const struct WgClientMsg *s, WgClientMsg_list l, int i) {
write_WgClientMsg(s, p);
}
+WgIpv4Addr_ptr new_WgIpv4Addr(struct capn_segment *s) {
+ WgIpv4Addr_ptr p;
+ p.p = capn_new_struct(s, 8, 0);
+ return p;
+}
+WgIpv4Addr_list new_WgIpv4Addr_list(struct capn_segment *s, int len) {
+ WgIpv4Addr_list p;
+ p.p = capn_new_list(s, len, 8, 0);
+ return p;
+}
+void read_WgIpv4Addr(struct WgIpv4Addr *s capnp_unused, WgIpv4Addr_ptr p) {
+ capn_resolve(&p.p);
+ capnp_use(s);
+ s->addr = capn_read32(p.p, 0);
+ s->cidr = capn_read8(p.p, 4);
+}
+void write_WgIpv4Addr(const struct WgIpv4Addr *s capnp_unused, WgIpv4Addr_ptr p) {
+ capn_resolve(&p.p);
+ capnp_use(s);
+ capn_write32(p.p, 0, s->addr);
+ capn_write8(p.p, 4, s->cidr);
+}
+void get_WgIpv4Addr(struct WgIpv4Addr *s, WgIpv4Addr_list l, int i) {
+ WgIpv4Addr_ptr p;
+ p.p = capn_getp(l.p, i, 0);
+ read_WgIpv4Addr(s, p);
+}
+void set_WgIpv4Addr(const struct WgIpv4Addr *s, WgIpv4Addr_list l, int i) {
+ WgIpv4Addr_ptr p;
+ p.p = capn_getp(l.p, i, 0);
+ write_WgIpv4Addr(s, p);
+}
+
+WgIpv6Addr_ptr new_WgIpv6Addr(struct capn_segment *s) {
+ WgIpv6Addr_ptr p;
+ p.p = capn_new_struct(s, 8, 1);
+ return p;
+}
+WgIpv6Addr_list new_WgIpv6Addr_list(struct capn_segment *s, int len) {
+ WgIpv6Addr_list p;
+ p.p = capn_new_list(s, len, 8, 1);
+ return p;
+}
+void read_WgIpv6Addr(struct WgIpv6Addr *s capnp_unused, WgIpv6Addr_ptr p) {
+ capn_resolve(&p.p);
+ capnp_use(s);
+ s->addr = capn_get_data(p.p, 0);
+ s->cidr = capn_read8(p.p, 0);
+}
+void write_WgIpv6Addr(const struct WgIpv6Addr *s capnp_unused, WgIpv6Addr_ptr p) {
+ capn_resolve(&p.p);
+ capnp_use(s);
+ capn_setp(p.p, 0, s->addr.p);
+ capn_write8(p.p, 0, s->cidr);
+}
+void get_WgIpv6Addr(struct WgIpv6Addr *s, WgIpv6Addr_list l, int i) {
+ WgIpv6Addr_ptr p;
+ p.p = capn_getp(l.p, i, 0);
+ read_WgIpv6Addr(s, p);
+}
+void set_WgIpv6Addr(const struct WgIpv6Addr *s, WgIpv6Addr_list l, int i) {
+ WgIpv6Addr_ptr p;
+ p.p = capn_getp(l.p, i, 0);
+ write_WgIpv6Addr(s, p);
+}
+
WgServerSimpleMsg_ptr new_WgServerSimpleMsg(struct capn_segment *s) {
WgServerSimpleMsg_ptr p;
- p.p = capn_new_struct(s, 24, 0);
+ p.p = capn_new_struct(s, 8, 2);
return p;
}
WgServerSimpleMsg_list new_WgServerSimpleMsg_list(struct capn_segment *s, int len) {
WgServerSimpleMsg_list p;
- p.p = capn_new_list(s, len, 24, 0);
+ p.p = capn_new_list(s, len, 8, 2);
return p;
}
void read_WgServerSimpleMsg(struct WgServerSimpleMsg *s capnp_unused, WgServerSimpleMsg_ptr p) {
capn_resolve(&p.p);
capnp_use(s);
- s->leasedIpv4 = capn_read32(p.p, 0);
- s->leasedIpv4Cidr = capn_read32(p.p, 4);
- s->leaseTimeout = capn_read32(p.p, 8);
- s->route = capn_read32(p.p, 12);
- s->routeCidr = capn_read32(p.p, 16);
+ s->leasedIpv4.p = capn_getp(p.p, 0, 0);
+ s->leaseTimeout = capn_read32(p.p, 0);
+ s->ipv4Routes.p = capn_getp(p.p, 1, 0);
}
void write_WgServerSimpleMsg(const struct WgServerSimpleMsg *s capnp_unused, WgServerSimpleMsg_ptr p) {
capn_resolve(&p.p);
capnp_use(s);
- capn_write32(p.p, 0, s->leasedIpv4);
- capn_write32(p.p, 4, s->leasedIpv4Cidr);
- capn_write32(p.p, 8, s->leaseTimeout);
- capn_write32(p.p, 12, s->route);
- capn_write32(p.p, 16, s->routeCidr);
+ capn_setp(p.p, 0, s->leasedIpv4.p);
+ capn_write32(p.p, 0, s->leaseTimeout);
+ capn_setp(p.p, 1, s->ipv4Routes.p);
}
void get_WgServerSimpleMsg(struct WgServerSimpleMsg *s, WgServerSimpleMsg_list l, int i) {
WgServerSimpleMsg_ptr p;
diff --git a/protocol.capnp.h b/protocol.capnp.h
index ea2f2e2..bf8a949 100644
--- a/protocol.capnp.h
+++ b/protocol.capnp.h
@@ -21,12 +21,18 @@ extern "C" {
#endif
struct WgClientMsg;
+struct WgIpv4Addr;
+struct WgIpv6Addr;
struct WgServerSimpleMsg;
typedef struct {capn_ptr p;} WgClientMsg_ptr;
+typedef struct {capn_ptr p;} WgIpv4Addr_ptr;
+typedef struct {capn_ptr p;} WgIpv6Addr_ptr;
typedef struct {capn_ptr p;} WgServerSimpleMsg_ptr;
typedef struct {capn_ptr p;} WgClientMsg_list;
+typedef struct {capn_ptr p;} WgIpv4Addr_list;
+typedef struct {capn_ptr p;} WgIpv6Addr_list;
typedef struct {capn_ptr p;} WgServerSimpleMsg_list;
enum WgClientMsg_WgClientRequestType {
@@ -43,36 +49,68 @@ static const size_t WgClientMsg_pointer_count = 0;
static const size_t WgClientMsg_struct_bytes_count = 8;
+struct WgIpv4Addr {
+ uint32_t addr;
+ uint8_t cidr;
+};
+
+static const size_t WgIpv4Addr_word_count = 1;
+
+static const size_t WgIpv4Addr_pointer_count = 0;
+
+static const size_t WgIpv4Addr_struct_bytes_count = 8;
+
+struct WgIpv6Addr {
+ capn_data addr;
+ uint8_t cidr;
+};
+
+static const size_t WgIpv6Addr_word_count = 1;
+
+static const size_t WgIpv6Addr_pointer_count = 1;
+
+static const size_t WgIpv6Addr_struct_bytes_count = 16;
+
struct WgServerSimpleMsg {
- uint32_t leasedIpv4;
- uint32_t leasedIpv4Cidr;
+ WgIpv4Addr_ptr leasedIpv4;
uint32_t leaseTimeout;
- uint32_t route;
- uint32_t routeCidr;
+ WgIpv4Addr_list ipv4Routes;
};
-static const size_t WgServerSimpleMsg_word_count = 3;
+static const size_t WgServerSimpleMsg_word_count = 1;
-static const size_t WgServerSimpleMsg_pointer_count = 0;
+static const size_t WgServerSimpleMsg_pointer_count = 2;
static const size_t WgServerSimpleMsg_struct_bytes_count = 24;
WgClientMsg_ptr new_WgClientMsg(struct capn_segment*);
+WgIpv4Addr_ptr new_WgIpv4Addr(struct capn_segment*);
+WgIpv6Addr_ptr new_WgIpv6Addr(struct capn_segment*);
WgServerSimpleMsg_ptr new_WgServerSimpleMsg(struct capn_segment*);
WgClientMsg_list new_WgClientMsg_list(struct capn_segment*, int len);
+WgIpv4Addr_list new_WgIpv4Addr_list(struct capn_segment*, int len);
+WgIpv6Addr_list new_WgIpv6Addr_list(struct capn_segment*, int len);
WgServerSimpleMsg_list new_WgServerSimpleMsg_list(struct capn_segment*, int len);
void read_WgClientMsg(struct WgClientMsg*, WgClientMsg_ptr);
+void read_WgIpv4Addr(struct WgIpv4Addr*, WgIpv4Addr_ptr);
+void read_WgIpv6Addr(struct WgIpv6Addr*, WgIpv6Addr_ptr);
void read_WgServerSimpleMsg(struct WgServerSimpleMsg*, WgServerSimpleMsg_ptr);
void write_WgClientMsg(const struct WgClientMsg*, WgClientMsg_ptr);
+void write_WgIpv4Addr(const struct WgIpv4Addr*, WgIpv4Addr_ptr);
+void write_WgIpv6Addr(const struct WgIpv6Addr*, WgIpv6Addr_ptr);
void write_WgServerSimpleMsg(const struct WgServerSimpleMsg*, WgServerSimpleMsg_ptr);
void get_WgClientMsg(struct WgClientMsg*, WgClientMsg_list, int i);
+void get_WgIpv4Addr(struct WgIpv4Addr*, WgIpv4Addr_list, int i);
+void get_WgIpv6Addr(struct WgIpv6Addr*, WgIpv6Addr_list, int i);
void get_WgServerSimpleMsg(struct WgServerSimpleMsg*, WgServerSimpleMsg_list, int i);
void set_WgClientMsg(const struct WgClientMsg*, WgClientMsg_list, int i);
+void set_WgIpv4Addr(const struct WgIpv4Addr*, WgIpv4Addr_list, int i);
+void set_WgIpv6Addr(const struct WgIpv6Addr*, WgIpv6Addr_list, int i);
void set_WgServerSimpleMsg(const struct WgServerSimpleMsg*, WgServerSimpleMsg_list, int i);
#ifdef __cplusplus