rc: wireguard.c: constify args in some functions

arm-master
pedro 6 months ago
parent 816736d0c4
commit f720a85f8c

@ -43,7 +43,7 @@
char port[BUF_SIZE_8];
static void wg_build_firewall(int unit, char *port, char *iface) {
static void wg_build_firewall(const int unit, const char *port, const char *iface) {
FILE *fp;
char buffer[BUF_SIZE_64];
char *dns;
@ -189,7 +189,7 @@ static void wg_build_firewall(int unit, char *port, char *iface) {
logmsg(LOG_DEBUG, "*** %s: Done", __FUNCTION__);
}
static int wg_quick_iface(char *iface, char *file, int up)
static int wg_quick_iface(char *iface, const char *file, const int up)
{
char buffer[BUF_SIZE_32];
char *up_down = (up == 1 ? "up" : "down");
@ -219,7 +219,7 @@ static int wg_quick_iface(char *iface, char *file, int up)
return 0;
}
static void find_port(int unit, char *port)
static void find_port(const int unit, char *port)
{
char *b;
@ -274,7 +274,7 @@ static int wg_create_iface(char *iface)
return 0;
}
static int wg_set_iface_addr(char *iface, char *addr)
static int wg_set_iface_addr(char *iface, const char *addr)
{
char *nv, *b;
@ -315,7 +315,7 @@ static int wg_set_iface_port(char *iface, char *port)
return 0;
}
static int wg_set_iface_privkey(char *iface, char *privkey)
static int wg_set_iface_privkey(char *iface, const char *privkey)
{
FILE *fp;
char buffer[BUF_SIZE];
@ -397,7 +397,7 @@ static int wg_set_iface_up(char *iface)
return -1;
}
static int wg_iface_script(int unit, char *script_name)
static int wg_iface_script(const int unit, const char *script_name)
{
char *script;
char buffer[BUF_SIZE_32];
@ -445,27 +445,27 @@ static int wg_iface_script(int unit, char *script_name)
return 0;
}
static void wg_iface_pre_up(int unit)
static void wg_iface_pre_up(const int unit)
{
wg_iface_script(unit, "preup");
}
static void wg_iface_post_up(int unit)
static void wg_iface_post_up(const int unit)
{
wg_iface_script(unit, "postup");
}
static void wg_iface_pre_down(int unit)
static void wg_iface_pre_down(const int unit)
{
wg_iface_script(unit, "predown");
}
static void wg_iface_post_down(int unit)
static void wg_iface_post_down(const int unit)
{
wg_iface_script(unit, "postdown");
}
static int wg_set_peer_psk(char *iface, char *pubkey, char *presharedkey)
static int wg_set_peer_psk(char *iface, char *pubkey, const char *presharedkey)
{
FILE *fp;
char buffer[BUF_SIZE];
@ -503,7 +503,7 @@ static int wg_set_peer_keepalive(char *iface, char *pubkey, char *keepalive)
return 0;
}
static int wg_set_peer_endpoint(char *iface, char *pubkey, char *endpoint, char *port)
static int wg_set_peer_endpoint(char *iface, char *pubkey, const char *endpoint, const char *port)
{
char buffer[BUF_SIZE_64];
@ -558,7 +558,7 @@ static int wg_route_peer_custom(char *iface, char *route, char *table)
return 0;
}
static int wg_route_peer_allowed_ips(char *iface, char *allowed_ips, char *fwmark)
static int wg_route_peer_allowed_ips(char *iface, const char *allowed_ips, const char *fwmark)
{
char *aip, *b, *table, *rt, *tp, *ip, *nm;
int route_type = 1, result = 0;
@ -606,7 +606,7 @@ static int wg_route_peer_allowed_ips(char *iface, char *allowed_ips, char *fwmar
return result;
}
static int wg_set_peer_allowed_ips(char *iface, char *pubkey, char *allowed_ips, char *fwmark)
static int wg_set_peer_allowed_ips(char *iface, char *pubkey, char *allowed_ips, const char *fwmark)
{
if (eval("wg", "set", iface, "peer", pubkey, "allowed-ips", allowed_ips)) {
logmsg(LOG_WARNING, "unable to add peer %s to wireguard interface %s!", pubkey, iface);
@ -618,7 +618,7 @@ static int wg_set_peer_allowed_ips(char *iface, char *pubkey, char *allowed_ips,
return wg_route_peer_allowed_ips(iface, allowed_ips, fwmark);
}
static int wg_add_peer(char *iface, char *pubkey, char *allowed_ips, char *presharedkey, char *keepalive, char *endpoint, char *fwmark, char *port)
static int wg_add_peer(char *iface, char *pubkey, char *allowed_ips, const char *presharedkey, char *keepalive, const char *endpoint, const char *fwmark, const char *port)
{
/* set allowed ips / create peer */
wg_set_peer_allowed_ips(iface, pubkey, allowed_ips, fwmark);
@ -703,7 +703,7 @@ static bool key_from_base64(uint8_t key[static WG_KEY_LEN], const char *base64)
return 1 & ((ret - 1) >> 8);
}
static void wg_pubkey(char *privkey, char *pubkey)
static void wg_pubkey(const char *privkey, char *pubkey)
{
uint8_t key[WG_KEY_LEN] __attribute__((aligned(sizeof(uintptr_t))));
@ -712,7 +712,7 @@ static void wg_pubkey(char *privkey, char *pubkey)
key_to_base64(pubkey, key);
}
static int wg_add_peer_privkey(char *iface, char *privkey, char *allowed_ips, char *presharedkey, char *keepalive, char *endpoint, char *fwmark)
static int wg_add_peer_privkey(char *iface, const char *privkey, char *allowed_ips, const char *presharedkey, char *keepalive, const char *endpoint, const char *fwmark)
{
char pubkey[64];
@ -803,7 +803,7 @@ void stop_wg_all(void)
modprobe_r("wireguard");
}
void start_wireguard(int unit)
void start_wireguard(const int unit)
{
char *nv, *nvp, *rka, *b;
char *priv, *name, *key, *psk, *ip, *ka, *aip, *ep;
@ -918,7 +918,7 @@ out:
stop_wireguard(unit);
}
void stop_wireguard(int unit)
void stop_wireguard(const int unit)
{
char iface[IF_SIZE];
char buffer[BUF_SIZE];

Loading…
Cancel
Save