diff options
Diffstat (limited to 'src/skadns')
-rw-r--r-- | src/skadns/skadns_cancel.c | 6 | ||||
-rw-r--r-- | src/skadns/skadns_end.c | 2 | ||||
-rw-r--r-- | src/skadns/skadns_packet.c | 2 | ||||
-rw-r--r-- | src/skadns/skadns_packetlen.c | 2 | ||||
-rw-r--r-- | src/skadns/skadns_release.c | 4 | ||||
-rw-r--r-- | src/skadns/skadns_send.c | 17 | ||||
-rw-r--r-- | src/skadns/skadns_update.c | 17 | ||||
-rw-r--r-- | src/skadns/skadnsd.c | 24 |
8 files changed, 41 insertions, 33 deletions
diff --git a/src/skadns/skadns_cancel.c b/src/skadns/skadns_cancel.c index a9673ed..3595585 100644 --- a/src/skadns/skadns_cancel.c +++ b/src/skadns/skadns_cancel.c @@ -1,13 +1,13 @@ /* ISC license. */ -/* OpenBSD sucks */ +/* OpenBSD sucks. In other news, the sky is blue. */ #ifndef _BSD_SOURCE #define _BSD_SOURCE #endif #include <stdint.h> #include <errno.h> -#include <skalibs/uint16.h> +#include <skalibs/types.h> #include <skalibs/error.h> #include <skalibs/tai.h> #include <skalibs/gensetdyn.h> @@ -18,7 +18,7 @@ int skadns_cancel (skadns_t *a, uint16_t id, tain_t const *deadline, tain_t *sta { char pack[3] = "--q" ; char err ; - register skadnsanswer_t *p = GENSETDYN_P(skadnsanswer_t, &a->q, id) ; + skadnsanswer_t *p = GENSETDYN_P(skadnsanswer_t, &a->q, id) ; if (!error_isagain(p->status)) return skadns_release(a, id) ; uint16_pack_big(pack, id) ; if (!skaclient_send(&a->connection, pack, 3, &skaclient_default_cb, &err, deadline, stamp)) return 0 ; diff --git a/src/skadns/skadns_end.c b/src/skadns/skadns_end.c index e6e8045..252e959 100644 --- a/src/skadns/skadns_end.c +++ b/src/skadns/skadns_end.c @@ -9,7 +9,7 @@ static int skadnsanswer_free (char *p, void *stuff) { - register skadnsanswer_t *q = (skadnsanswer_t_ref)p ; + skadnsanswer_t *q = (skadnsanswer_t_ref)p ; alloc_free(&q->data) ; (void)stuff ; return 1 ; diff --git a/src/skadns/skadns_packet.c b/src/skadns/skadns_packet.c index 8ef8f1d..c77bb04 100644 --- a/src/skadns/skadns_packet.c +++ b/src/skadns/skadns_packet.c @@ -7,7 +7,7 @@ char const *skadns_packet (skadns_t const *a, uint16_t id) { - register skadnsanswer_t *p = GENSETDYN_P(skadnsanswer_t, &a->q, id) ; + skadnsanswer_t *p = GENSETDYN_P(skadnsanswer_t, &a->q, id) ; switch (p->status) { case 0 : return (char const *)p->data ; diff --git a/src/skadns/skadns_packetlen.c b/src/skadns/skadns_packetlen.c index f69e43f..77e3ba1 100644 --- a/src/skadns/skadns_packetlen.c +++ b/src/skadns/skadns_packetlen.c @@ -7,7 +7,7 @@ int skadns_packetlen (skadns_t const *a, uint16_t id) { - register skadnsanswer_t *p = GENSETDYN_P(skadnsanswer_t, &a->q, id) ; + skadnsanswer_t *p = GENSETDYN_P(skadnsanswer_t, &a->q, id) ; switch (p->status) { case 0 : return p->len ; diff --git a/src/skadns/skadns_release.c b/src/skadns/skadns_release.c index 3ce2fc3..f563dbe 100644 --- a/src/skadns/skadns_release.c +++ b/src/skadns/skadns_release.c @@ -1,6 +1,6 @@ /* ISC license. */ -/* OpenBSD sucks */ +/* OpenBSD sucks. More news at 11. */ #ifndef _BSD_SOURCE #define _BSD_SOURCE #endif @@ -13,7 +13,7 @@ int skadns_release (skadns_t *a, uint16_t id) { - register skadnsanswer_t *p = GENSETDYN_P(skadnsanswer_t, &a->q, id) ; + skadnsanswer_t *p = GENSETDYN_P(skadnsanswer_t, &a->q, id) ; switch (p->status) { case 0 : diff --git a/src/skadns/skadns_send.c b/src/skadns/skadns_send.c index f485c92..35177c2 100644 --- a/src/skadns/skadns_send.c +++ b/src/skadns/skadns_send.c @@ -1,10 +1,10 @@ /* ISC license. */ +#include <sys/uio.h> +#include <string.h> #include <stdint.h> #include <errno.h> -#include <skalibs/uint16.h> -#include <skalibs/bytestr.h> -#include <skalibs/siovec.h> +#include <skalibs/types.h> #include <skalibs/tai.h> #include <skalibs/stralloc.h> #include <skalibs/gensetdyn.h> @@ -19,14 +19,19 @@ int skadns_send (skadns_t *a, uint16_t *u, s6dns_domain_t const *d, uint16_t qty unsigned int i ; char tmp[17] = "--Q" ; char err ; - siovec_t v[2] = { { .s = tmp, .len = 17 }, { .s = (char *)d->s, .len = d->len } } ; + struct iovec v[2] = { { .iov_base = tmp, .iov_len = 17 }, { .iov_base = (void *)d->s, .iov_len = d->len } } ; if (!gensetdyn_new(&a->q, &i)) return 0 ; + if (i > UINT16_MAX) + { + gensetdyn_delete(&a->q, i) ; + return (errno = EMFILE, 0) ; + } uint16_pack_big(tmp, (uint16_t)i) ; uint16_pack_big(tmp + 3, qtype) ; - if (limit) tain_pack(tmp + 5, limit) ; else byte_zero(tmp + 5, 12) ; + if (limit) tain_pack(tmp + 5, limit) ; else memset(tmp + 5, 0, 12) ; if (!skaclient_sendv(&a->connection, v, 2, &skaclient_default_cb, &err, deadline, stamp)) { - register int e = errno ; + int e = errno ; gensetdyn_delete(&a->q, i) ; errno = e ; return 0 ; diff --git a/src/skadns/skadns_update.c b/src/skadns/skadns_update.c index 73edba2..24b1e2e 100644 --- a/src/skadns/skadns_update.c +++ b/src/skadns/skadns_update.c @@ -1,15 +1,16 @@ /* ISC license. */ -/* OpenBSD sucks */ +/* Hey, OpenBSD, are you aware ECANCELED is POSIX? */ #ifndef _BSD_SOURCE #define _BSD_SOURCE #endif +#include <string.h> +#include <stdint.h> #include <errno.h> #include <skalibs/error.h> -#include <skalibs/uint16.h> +#include <skalibs/types.h> #include <skalibs/alloc.h> -#include <skalibs/bytestr.h> #include <skalibs/genalloc.h> #include <skalibs/gensetdyn.h> #include <skalibs/unixmessage.h> @@ -20,7 +21,7 @@ static int msghandler (unixmessage_t const *m, void *context) { skadns_t *a = (skadns_t *)context ; skadnsanswer_t *p ; - uint16 id ; + uint16_t id ; if (m->len < 3 || m->nfds) return (errno = EPROTO, 0) ; uint16_unpack_big(m->s, &id) ; p = GENSETDYN_P(skadnsanswer_t, &a->q, id) ; @@ -30,21 +31,21 @@ static int msghandler (unixmessage_t const *m, void *context) return gensetdyn_delete(&a->q, id) ; } if (!error_isagain(p->status)) return (errno = EINVAL, 0) ; - if (!genalloc_readyplus(uint16, &a->list, 1)) return 0 ; + if (!genalloc_readyplus(uint16_t, &a->list, 1)) return 0 ; if (!m->s[2]) { p->data = alloc(m->len-3) ; if (!p->data) return 0 ; - byte_copy(p->data, m->len-3, m->s+3) ; + memcpy(p->data, m->s+3, m->len-3) ; p->len = m->len-3 ; } p->status = m->s[2] ; - genalloc_append(uint16, &a->list, &id) ; + genalloc_append(uint16_t, &a->list, &id) ; return 1 ; } int skadns_update (skadns_t *a) { - genalloc_setlen(uint16, &a->list, 0) ; + genalloc_setlen(uint16_t, &a->list, 0) ; return skaclient_update(&a->connection, &msghandler, a) ; } diff --git a/src/skadns/skadnsd.c b/src/skadns/skadnsd.c index 2682ace..b1b0687 100644 --- a/src/skadns/skadnsd.c +++ b/src/skadns/skadnsd.c @@ -1,9 +1,11 @@ /* ISC license. */ +#include <sys/uio.h> +#include <string.h> #include <stdint.h> #include <errno.h> #include <signal.h> -#include <skalibs/uint16.h> +#include <skalibs/types.h> #include <skalibs/error.h> #include <skalibs/strerr2.h> #include <skalibs/sig.h> @@ -72,7 +74,7 @@ static int parse_protocol (unixmessage_t const *m, void *context) break ; } uint16_unpack_big(m->s + 3, &qtype) ; - if (byte_diff(m->s + 5, 12, "\0\0\0\0\0\0\0\0\0\0\0")) + if (memcmp(m->s + 5, "\0\0\0\0\0\0\0\0\0\0\0", 12)) tain_unpack(m->s + 5, &limit) ; else tain_add_g(&limit, &tain_infinite_relative) ; if (!s6dns_engine_init_g(&a[sp].dt, &s6dns_rci_here.servers, 1, m->s + 17, m->len - 17, qtype, &limit)) @@ -86,7 +88,7 @@ static int parse_protocol (unixmessage_t const *m, void *context) } case 'q' : /* cancel a query */ { - register unsigned int i = 0 ; + unsigned int i = 0 ; for (; i < sp ; i++) if (a[i].id == id) break ; if (i >= sp) { @@ -122,14 +124,14 @@ int main (void) } { static dnsio_t const zero = DNSIO_ZERO ; - register unsigned int i = 0 ; + unsigned int i = 0 ; for (; i < SKADNS_MAXCONCURRENCY ; i++) a[i] = zero ; } for (;;) { iopause_fd x[3 + sp] ; - register int r ; + int r ; x[0].fd = 0 ; x[0].events = IOPAUSE_EXCEPT | IOPAUSE_READ ; x[1].fd = 1 ; x[1].events = IOPAUSE_EXCEPT | (unixmessage_sender_isempty(unixmessage_sender_1) ? 0 : IOPAUSE_WRITE) ; @@ -137,10 +139,10 @@ int main (void) x[2].events = IOPAUSE_EXCEPT | (unixmessage_sender_isempty(unixmessage_sender_x) ? 0 : IOPAUSE_WRITE) ; { tain_t deadline = TAIN_INFINITE ; - register unsigned int i = 0 ; + unsigned int i = 0 ; for (; i < sp ; i++) { - register unsigned int j = 3 + i ; + unsigned int j = 3 + i ; s6dns_engine_nextdeadline(&a[i].dt, &deadline) ; x[j].fd = a[i].dt.fd ; x[j].events = 0 ; @@ -153,7 +155,7 @@ int main (void) if (r < 0) strerr_diefu1sys(111, "iopause") ; if (!r) { - register unsigned int i = 0 ; + unsigned int i = 0 ; for (; i < sp ; i++) if (s6dns_engine_timeout_g(&a[i].dt)) fail(i--) ; continue ; @@ -167,15 +169,15 @@ int main (void) strerr_diefu1sys(111, "flush asyncout") ; { - register unsigned int i = 0 ; + unsigned int i = 0 ; for (; i < sp ; i++) if (x[a[i].xindex].revents) { - register int r = s6dns_engine_event_g(&a[i].dt) ; + int r = s6dns_engine_event_g(&a[i].dt) ; if (r < 0) fail(i--) ; else if (r) { char pack[3] ; - siovec_t v[2] = { { .s = pack, .len = 3 }, { .s = s6dns_engine_packet(&a[i].dt), .len = s6dns_engine_packetlen(&a[i].dt) } } ; + struct iovec v[2] = { { .iov_base = pack, .iov_len = 3 }, { .iov_base = s6dns_engine_packet(&a[i].dt), .iov_len = s6dns_engine_packetlen(&a[i].dt) } } ; unixmessage_v_t mv = { .v = v, .vlen = 2, .fds = 0, .nfds = 0 } ; uint16_pack_big(pack, a[i].id) ; pack[2] = 0 ; |