stun

simple point to point tunnel
git clone git://git.2f30.org/stun.git
Log | Files | Refs | README

commit a30d4ecf40de330a8b4968810b2a047b813a5a89
parent 74dc4b115f83ed38f81845687c0bae5326da2af7
Author: sin <sin@2f30.org>
Date:   Tue May  3 15:09:57 +0100

Rename netconfig to netcfg

Diffstat:
client.c | 2+-
dev_bsd.c | 8++++----
dev_linux.c | 4++--
stun.c | 28++++++++++++++--------------
stun.h | 2+-
util.c | 12++++++------
6 files changed, 28 insertions(+), 28 deletions(-)
diff --git a/client.c b/client.c @@ -23,7 +23,7 @@ clientconnect(char *host, char *port) } for (p = ai; p; p = p->ai_next) { - if (p->ai_family != netconfig.proto) + if (p->ai_family != netcfg.proto) continue; if ((netfd = socket(p->ai_family, p->ai_socktype, p->ai_protocol)) < 0) diff --git a/dev_bsd.c b/dev_bsd.c @@ -32,13 +32,13 @@ devopen(char *ifname) fatal("open %s", dev); if (ioctl(fd, TUNGIFINFO, &ti) < 0) fatal("TUNGIFINFO %s", dev); - if (netconfig.devtype == TUNDEV) + if (netcfg.devtype == TUNDEV) ti.mtu = MAXPAYLOADLEN; else ti.mtu = MAXPAYLOADLEN - 14; /* make room for ethernet header */ if (ioctl(fd, TUNSIFINFO, &ti) < 0) fatal("TUNSIFINFO %s", dev); - if (netconfig.devtype == TUNDEV) { + if (netcfg.devtype == TUNDEV) { #if defined(TUNSIFHEAD) int one = 1; if (ioctl(fd, TUNSIFHEAD, &one) < 0) @@ -55,7 +55,7 @@ devwrite(int fd, unsigned char *buf, int len) uint32_t type; int n, af; - switch (netconfig.devtype) { + switch (netcfg.devtype) { case TAPDEV: do { n = write(fd, buf, len); @@ -86,7 +86,7 @@ devread(int fd, unsigned char *buf, int len) uint32_t type; int n; - switch (netconfig.devtype) { + switch (netcfg.devtype) { case TAPDEV: do { n = read(fd, buf, len); diff --git a/dev_linux.c b/dev_linux.c @@ -22,7 +22,7 @@ devopen(char *ifname) fatal("open %s", "/dev/net/tun"); memset(&ifr, 0, sizeof(ifr)); - ifr.ifr_flags = (netconfig.devtype == TUNDEV ? IFF_TUN : IFF_TAP); + ifr.ifr_flags = (netcfg.devtype == TUNDEV ? IFF_TUN : IFF_TAP); ifr.ifr_flags |= IFF_NO_PI; strncpy(ifr.ifr_name, ifname, IF_NAMESIZE); ifr.ifr_name[IF_NAMESIZE - 1] = '\0'; @@ -32,7 +32,7 @@ devopen(char *ifname) /* dummy socket so we can manipulate the params */ if ((s = socket(AF_INET, SOCK_STREAM, 0)) < 0) fatal("socket"); - if (netconfig.devtype == TUNDEV) + if (netcfg.devtype == TUNDEV) ifr.ifr_mtu = MAXPAYLOADLEN; else ifr.ifr_mtu = MAXPAYLOADLEN - 14; /* make room for ethernet header */ diff --git a/stun.c b/stun.c @@ -21,7 +21,7 @@ char *argv0; * Config options are passed via this global to each stun * instance. */ -struct netcfg netconfig; +struct netcfg netcfg; struct pident { pid_t pid; @@ -36,23 +36,23 @@ chldrun(void) signal(SIGPIPE, SIG_IGN); - setproctitle("network: %s", netconfig.name); + setproctitle("network: %s", netcfg.name); /* initialize tun/tap device */ - devfd = devopen(netconfig.ifname); + devfd = devopen(netcfg.ifname); /* initialize crypto engine */ - setcipher(netconfig.cipher); - derivekey(netconfig.passwd); + setcipher(netcfg.cipher); + derivekey(netcfg.passwd); cryptoinit(); /* initialize networking engine */ netinit(); - if (netconfig.bindaddr[0] != '\0') { + if (netcfg.bindaddr[0] != '\0') { /* invoked as server */ - listenfd = serverinit(netconfig.bindaddr, netconfig.port); - revokeprivs(netconfig.user); + listenfd = serverinit(netcfg.bindaddr, netcfg.port); + revokeprivs(netcfg.user); if (mypledge("stdio inet", NULL) < 0) fatal("pledge"); for (;;) { @@ -68,14 +68,14 @@ chldrun(void) } } else { /* invoked as client */ - revokeprivs(netconfig.user); + revokeprivs(netcfg.user); if (mypledge("stdio dns inet", NULL) < 0) fatal("pledge"); for (;;) { - if ((netfd = clientconnect(netconfig.host, - netconfig.port)) < 0) { + if ((netfd = clientconnect(netcfg.host, + netcfg.port)) < 0) { netreset(); - sleep(netconfig.timeout); + sleep(netcfg.timeout); continue; } logdbgx("connected to %s", peer_ntop(netfd)); @@ -83,7 +83,7 @@ chldrun(void) logdbgx("disconnected from %s", peer_ntop(netfd)); close(netfd); netreset(); - sleep(netconfig.timeout); + sleep(netcfg.timeout); } } } @@ -146,7 +146,7 @@ main(int argc, char *argv[]) ret = 0; TAILQ_FOREACH(n, &netcfgs, entry) { /* global options per stun instance */ - netconfig = *n; + netcfg = *n; switch (pid = fork()) { case -1: ret = 1; diff --git a/stun.h b/stun.h @@ -56,7 +56,7 @@ struct netcfg { TAILQ_HEAD(netcfgs, netcfg) netcfgs; /* stun.c */ -extern struct netcfg netconfig; +extern struct netcfg netcfg; /* auth.c */ int challenge(int); diff --git a/util.c b/util.c @@ -137,21 +137,21 @@ setsockopts(int fd) { int val; - val = !!(netconfig.tcpflags & TCPFLAG_KEEPALIVE); + val = !!(netcfg.tcpflags & TCPFLAG_KEEPALIVE); if (setsockopt(fd, SOL_SOCKET, SO_KEEPALIVE, &val, sizeof(val)) < 0) logwarn("setsockopt SO_KEEPALIVE"); - val = !!(netconfig.tcpflags & TCPFLAG_NODELAY); + val = !!(netcfg.tcpflags & TCPFLAG_NODELAY); if (setsockopt(fd, IPPROTO_TCP, TCP_NODELAY, &val, sizeof(val)) < 0) logwarn("setsockopt TCP_NODELAY"); - if (netconfig.tcpflags & TCPFLAG_RCVBUFSZ) { - val = netconfig.rcvbufsz; + if (netcfg.tcpflags & TCPFLAG_RCVBUFSZ) { + val = netcfg.rcvbufsz; if (setsockopt(fd, SOL_SOCKET, SO_RCVBUF, &val, sizeof(val)) < 0) logwarn("setsockopt SO_RCVBUF"); } - if (netconfig.tcpflags & TCPFLAG_SNDBUFSZ) { - val = netconfig.sndbufsz; + if (netcfg.tcpflags & TCPFLAG_SNDBUFSZ) { + val = netcfg.sndbufsz; if (setsockopt(fd, SOL_SOCKET, SO_SNDBUF, &val, sizeof(val)) < 0) logwarn("setsockopt SO_SNDBUF");