summaryrefslogtreecommitdiff
path: root/src/libs6net
diff options
context:
space:
mode:
authorLaurent Bercot <ska-skaware@skarnet.org>2017-01-10 02:17:16 +0000
committerLaurent Bercot <ska-skaware@skarnet.org>2017-01-10 02:17:16 +0000
commit334d807b924427434b42d4fbae745d3d1b38a218 (patch)
tree6daf12c1e2fa07d2ac6255ef4439e2fb95a57f57 /src/libs6net
parent43cb3ee4227de70e0225e9ac142b4d397f93cc41 (diff)
downloads6-networking-334d807b924427434b42d4fbae745d3d1b38a218.tar.xz
Types fix, first pass
XXX marks what must change when skalibs changes. Also started writing functions for client certificate support in sbearssl, but it's not working yet (need more high-level support from BearSSL before it can work)
Diffstat (limited to 'src/libs6net')
-rw-r--r--src/libs6net/s6net_ident_client.c8
-rw-r--r--src/libs6net/s6net_ident_reply_get.c10
-rw-r--r--src/libs6net/s6net_ident_reply_parse.c14
3 files changed, 18 insertions, 14 deletions
diff --git a/src/libs6net/s6net_ident_client.c b/src/libs6net/s6net_ident_client.c
index c6b9ac0..e4f4b87 100644
--- a/src/libs6net/s6net_ident_client.c
+++ b/src/libs6net/s6net_ident_client.c
@@ -1,17 +1,17 @@
/* ISC license. */
+#include <stdint.h>
#include <errno.h>
-#include <skalibs/uint16.h>
#include <skalibs/bytestr.h>
#include <skalibs/tai.h>
#include <skalibs/ip46.h>
#include <s6-networking/ident.h>
-int s6net_ident_client (char *s, unsigned int max, ip46_t const *remoteip, uint16 remoteport, ip46_t const *localip, uint16 localport, tain_t const *deadline, tain_t *stamp)
+int s6net_ident_client (char *s, size_t max, ip46_t const *remoteip, uint16_t remoteport, ip46_t const *localip, uint16_t localport, tain_t const *deadline, tain_t *stamp)
{
char buf[S6NET_IDENT_REPLY_SIZE] ;
- unsigned int len ;
- register int r = s6net_ident_reply_get(buf, remoteip, remoteport, localip, localport, deadline, stamp) ;
+ size_t len ;
+ register ssize_t r = s6net_ident_reply_get(buf, remoteip, remoteport, localip, localport, deadline, stamp) ;
if (r < 0) return errno == EPIPE ? (errno = EIO, 0) : -1 ; /* the RFC says so */
len = r ;
r = s6net_ident_reply_parse(buf, remoteport, localport) ;
diff --git a/src/libs6net/s6net_ident_reply_get.c b/src/libs6net/s6net_ident_reply_get.c
index b12925f..ee8c87e 100644
--- a/src/libs6net/s6net_ident_reply_get.c
+++ b/src/libs6net/s6net_ident_reply_get.c
@@ -1,5 +1,7 @@
/* ISC license. */
+#include <sys/types.h>
+#include <stdint.h>
#include <errno.h>
#include <skalibs/uint16.h>
#include <skalibs/allreadwrite.h>
@@ -11,9 +13,9 @@
#include <skalibs/unix-timed.h>
#include <s6-networking/ident.h>
-int s6net_ident_reply_get (char *s, ip46_t const *remoteip, uint16 remoteport, ip46_t const *localip, uint16 localport, tain_t const *deadline, tain_t *stamp)
+ssize_t s6net_ident_reply_get (char *s, ip46_t const *remoteip, uint16_t remoteport, ip46_t const *localip, uint16_t localport, tain_t const *deadline, tain_t *stamp)
{
- unsigned int len ;
+ unsigned int len ; /* XXX: change when skalibs changes */
int fd ;
if (ip46_is6(remoteip) != ip46_is6(localip)) return (errno = EAFNOSUPPORT, -1) ;
fd = socket_tcp46(ip46_is6(remoteip)) ;
@@ -24,7 +26,7 @@ int s6net_ident_reply_get (char *s, ip46_t const *remoteip, uint16 remoteport, i
char buf[S6NET_IDENT_REPLY_SIZE + 1] ;
char fmt[UINT16_FMT] ;
buffer b = BUFFER_INIT(&buffer_write, fd, buf, 256) ;
- unsigned int n = uint16_fmt(fmt, remoteport) ;
+ size_t n = uint16_fmt(fmt, remoteport) ;
buffer_putnoflush(&b, fmt, n) ;
buffer_putnoflush(&b, " , ", 3) ;
n = uint16_fmt(fmt, localport) ;
@@ -37,7 +39,7 @@ int s6net_ident_reply_get (char *s, ip46_t const *remoteip, uint16 remoteport, i
fd_close(fd) ;
if (!len--) return (errno = EPROTO, -1) ;
s[len] = 0 ;
- return (int)len ;
+ return len ;
err:
fd_close(fd) ;
diff --git a/src/libs6net/s6net_ident_reply_parse.c b/src/libs6net/s6net_ident_reply_parse.c
index a895d60..dd3e84c 100644
--- a/src/libs6net/s6net_ident_reply_parse.c
+++ b/src/libs6net/s6net_ident_reply_parse.c
@@ -1,25 +1,27 @@
/* ISC license. */
+#include <sys/types.h>
+#include <stdint.h>
#include <errno.h>
#include <skalibs/uint16.h>
#include <skalibs/bytestr.h>
#include <skalibs/error.h>
#include <s6-networking/ident.h>
-static unsigned int skipspace (char const *s)
+static size_t skipspace (char const *s)
{
- register unsigned int n = 0 ;
+ register size_t n = 0 ;
while ((s[n] == ' ') || (s[n] == '\t')) n++ ;
return n ;
}
-int s6net_ident_reply_parse (char const *s, uint16 rp, uint16 lp)
+ssize_t s6net_ident_reply_parse (char const *s, uint16_t rp, uint16_t lp)
{
- unsigned int n = 0 ;
+ size_t n = 0 ;
n += skipspace(s+n) ; if (!s[n]) goto err ;
{
- unsigned int i ;
- uint16 u ;
+ size_t i ;
+ uint16_t u ;
i = uint16_scan(s+n, &u) ; if (!i) goto err ; n += i ;
if (u != rp) goto err ;
n += skipspace(s+n) ; if (!s[n]) goto err ;