diff options
author | Stefano Brivio <sbrivio@redhat.com> | 2021-10-05 21:15:01 +0200 |
---|---|---|
committer | Stefano Brivio <sbrivio@redhat.com> | 2021-10-05 21:22:59 +0200 |
commit | 16f4b983de5509660f470992f3ce8e5cd1d59c3b (patch) | |
tree | 9c1bbda04a8b406a40389c2c37537fd0e48b08b1 /dhcp.c | |
parent | a26722b8755d36acc17e787399ac085a02a2e3bd (diff) | |
download | passt-16f4b983de5509660f470992f3ce8e5cd1d59c3b.tar passt-16f4b983de5509660f470992f3ce8e5cd1d59c3b.tar.gz passt-16f4b983de5509660f470992f3ce8e5cd1d59c3b.tar.bz2 passt-16f4b983de5509660f470992f3ce8e5cd1d59c3b.tar.lz passt-16f4b983de5509660f470992f3ce8e5cd1d59c3b.tar.xz passt-16f4b983de5509660f470992f3ce8e5cd1d59c3b.tar.zst passt-16f4b983de5509660f470992f3ce8e5cd1d59c3b.zip |
passt: Shrink binary size by dropping static initialisers
...from 11MiB to 155KiB for 'make avx2', 95KiB with -Os and stripped.
Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
Diffstat (limited to 'dhcp.c')
-rw-r--r-- | dhcp.c | 24 |
1 files changed, 17 insertions, 7 deletions
@@ -46,11 +46,8 @@ struct opt { unsigned char c[255]; }; -static struct opt opts[255] = { - [1] = { 0, 4, { 0 }, 0, { 0 }, }, /* Mask */ - [3] = { 0, 4, { 0 }, 0, { 0 }, }, /* Router */ - [51] = { 0, 4, { 0xff, 0xff, 0xff, 0xff }, 0, { 0 }, }, /* Lease time */ - [53] = { 0, 1, { 0 }, 0, { 0 }, }, /* Type */ +static struct opt opts[255]; + #define DHCPDISCOVER 1 #define DHCPOFFER 2 #define DHCPREQUEST 3 @@ -60,8 +57,21 @@ static struct opt opts[255] = { #define DHCPRELEASE 7 #define DHCPINFORM 8 #define DHCPFORCERENEW 9 - [54] = { 0, 4, { 0 }, 0, { 0 }, }, /* Server ID */ -}; + +/** + * dhcp_init() - Initialise DHCP options + */ +void dhcp_init(void) +{ + opts[1] = (struct opt) { 0, 4, { 0 }, 0, { 0 }, }; /* Mask */ + opts[3] = (struct opt) { 0, 4, { 0 }, 0, { 0 }, }; /* Router */ + opts[51] = (struct opt) { 0, 4, { 0xff, + 0xff, + 0xff, + 0xff }, 0, { 0 }, }; /* Lease time */ + opts[53] = (struct opt) { 0, 1, { 0 }, 0, { 0 }, }; /* Type */ + opts[54] = (struct opt) { 0, 4, { 0 }, 0, { 0 }, }; /* Server ID */ +} /** * struct msg - BOOTP/DHCP message |