warp-vpn

point to point VPN implementation
git clone git://git.2f30.org/warp-vpn
Log | Files | Refs | README

commit 7aa3b6b812e821c9b08fd6c2287290841a5c0262
parent b9e077813144354ef11e5988b93ed59beca45a38
Author: sin <sin@2f30.org>
Date:   Wed, 13 Apr 2016 09:50:10 +0100

rename states

Diffstat:
Mnetpkt.c | 46+++++++++++++++++++++++-----------------------
1 file changed, 23 insertions(+), 23 deletions(-)

diff --git a/netpkt.c b/netpkt.c @@ -11,13 +11,13 @@ /* the various states the input handler can be in */ enum { - STATEINITIAL, - STATENONCE, - STATEHDR, - STATEPAYLOAD, - STATETAG, - STATEDECRYPT, - STATEDISCARD + INPUTINITIAL, + INPUTNONCE, + INPUTHDR, + INPUTPAYLOAD, + INPUTTAG, + INPUTDECRYPT, + INPUTDISCARD }; /* output buffer for writing data to the network */ @@ -86,22 +86,22 @@ netread(int fd, unsigned char *pt, size_t ptlen, size_t *outlen) for (;;) { switch (state) { - case STATEINITIAL: + case INPUTINITIAL: rbuftotal = 0; rbufrem = noncelen; - state = STATENONCE; + state = INPUTNONCE; break; - case STATENONCE: + case INPUTNONCE: if ((n = read(fd, rbuf + rbuftotal, rbufrem)) <= 0) goto out; rbuftotal += n; rbufrem -= n; if (rbufrem == 0) { rbufrem = HDRLEN; - state = STATEHDR; + state = INPUTHDR; } break; - case STATEHDR: + case INPUTHDR: if ((n = read(fd, rbuf + rbuftotal, rbufrem)) <= 0) goto out; rbuftotal += n; @@ -109,33 +109,33 @@ netread(int fd, unsigned char *pt, size_t ptlen, size_t *outlen) if (rbufrem == 0) { ctlen = unpack16(&rbuf[noncelen]); if (ctlen > ptlen) { - state = STATEDISCARD; + state = INPUTDISCARD; } else { rbufrem = ctlen; - state = STATEPAYLOAD; + state = INPUTPAYLOAD; } } break; - case STATEPAYLOAD: + case INPUTPAYLOAD: if ((n = read(fd, rbuf + rbuftotal, rbufrem)) <= 0) goto out; rbuftotal += n; rbufrem -= n; if (rbufrem == 0) { rbufrem = taglen; - state = STATETAG; + state = INPUTTAG; } break; - case STATETAG: + case INPUTTAG: if ((n = read(fd, rbuf + rbuftotal, rbufrem)) <= 0) goto out; rbuftotal += n; rbufrem -= n; if (rbufrem == 0) - state = STATEDECRYPT; + state = INPUTDECRYPT; break; - case STATEDECRYPT: - state = STATEINITIAL; + case INPUTDECRYPT: + state = INPUTINITIAL; if (!cryptoopen(pt, outlen, ptlen, rbuf, noncelen, &rbuf[noncelen + HDRLEN], rbuftotal - noncelen - HDRLEN, @@ -144,8 +144,8 @@ netread(int fd, unsigned char *pt, size_t ptlen, size_t *outlen) return PKTPARTIAL; } return PKTCOMPLETE; - case STATEDISCARD: - state = STATEINITIAL; + case INPUTDISCARD: + state = INPUTINITIAL; for (;;) if ((n = read(fd, rbuf, maxbuflen)) <= 0) goto out; @@ -164,7 +164,7 @@ out: void netreset(void) { - state = STATEINITIAL; + state = INPUTINITIAL; } void