summaryrefslogtreecommitdiff
path: root/src/libs6net
diff options
context:
space:
mode:
authorLaurent Bercot <ska-skaware@skarnet.org>2017-03-12 19:39:01 +0000
committerLaurent Bercot <ska-skaware@skarnet.org>2017-03-12 19:39:01 +0000
commit53091e3bce487ee82e2805a0231e780551561717 (patch)
treef0fa36ff8eadaf1f01d4510597b5e3a310764dc7 /src/libs6net
parentf85b8a70f3b44510a5cf3895bf7357ae90655f65 (diff)
downloads6-networking-53091e3bce487ee82e2805a0231e780551561717.tar.xz
Adapt to skalibs-2.5.0.0
Diffstat (limited to 'src/libs6net')
-rw-r--r--src/libs6net/s6net_ident_client.c8
-rw-r--r--src/libs6net/s6net_ident_error.c2
-rw-r--r--src/libs6net/s6net_ident_reply_get.c5
-rw-r--r--src/libs6net/s6net_ident_reply_parse.c18
4 files changed, 16 insertions, 17 deletions
diff --git a/src/libs6net/s6net_ident_client.c b/src/libs6net/s6net_ident_client.c
index e4f4b87..a014fe2 100644
--- a/src/libs6net/s6net_ident_client.c
+++ b/src/libs6net/s6net_ident_client.c
@@ -1,22 +1,22 @@
/* ISC license. */
+#include <string.h>
#include <stdint.h>
#include <errno.h>
-#include <skalibs/bytestr.h>
#include <skalibs/tai.h>
#include <skalibs/ip46.h>
#include <s6-networking/ident.h>
-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)
+ssize_t 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] ;
size_t len ;
- register ssize_t r = s6net_ident_reply_get(buf, remoteip, remoteport, localip, localport, deadline, stamp) ;
+ 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) ;
if (r <= 0) return r ;
if (max + r < len + 1) return (errno = ENAMETOOLONG, -1) ;
- byte_copy(s, len - r + 1, buf + r) ;
+ memcpy(s, buf + r, len - r + 1) ;
return len - r + 1 ;
}
diff --git a/src/libs6net/s6net_ident_error.c b/src/libs6net/s6net_ident_error.c
index de01714..fca41fc 100644
--- a/src/libs6net/s6net_ident_error.c
+++ b/src/libs6net/s6net_ident_error.c
@@ -27,7 +27,7 @@ static int const s6net_ident_error_codes[N] =
char const *s6net_ident_error_str (int e)
{
- register unsigned int i = 0 ;
+ unsigned int i = 0 ;
for (; i < N ; i++) if (e == s6net_ident_error_codes[i]) break ;
return s6net_ident_error_strings[i] ;
}
diff --git a/src/libs6net/s6net_ident_reply_get.c b/src/libs6net/s6net_ident_reply_get.c
index ee8c87e..18a833d 100644
--- a/src/libs6net/s6net_ident_reply_get.c
+++ b/src/libs6net/s6net_ident_reply_get.c
@@ -1,9 +1,8 @@
/* ISC license. */
-#include <sys/types.h>
#include <stdint.h>
#include <errno.h>
-#include <skalibs/uint16.h>
+#include <skalibs/types.h>
#include <skalibs/allreadwrite.h>
#include <skalibs/buffer.h>
#include <skalibs/error.h>
@@ -15,7 +14,7 @@
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 ; /* XXX: change when skalibs changes */
+ size_t len ;
int fd ;
if (ip46_is6(remoteip) != ip46_is6(localip)) return (errno = EAFNOSUPPORT, -1) ;
fd = socket_tcp46(ip46_is6(remoteip)) ;
diff --git a/src/libs6net/s6net_ident_reply_parse.c b/src/libs6net/s6net_ident_reply_parse.c
index dd3e84c..f2e3308 100644
--- a/src/libs6net/s6net_ident_reply_parse.c
+++ b/src/libs6net/s6net_ident_reply_parse.c
@@ -1,16 +1,16 @@
/* ISC license. */
-#include <sys/types.h>
+#include <string.h>
#include <stdint.h>
#include <errno.h>
-#include <skalibs/uint16.h>
+#include <skalibs/types.h>
#include <skalibs/bytestr.h>
#include <skalibs/error.h>
#include <s6-networking/ident.h>
static size_t skipspace (char const *s)
{
- register size_t n = 0 ;
+ size_t n = 0 ;
while ((s[n] == ' ') || (s[n] == '\t')) n++ ;
return n ;
}
@@ -33,8 +33,8 @@ ssize_t s6net_ident_reply_parse (char const *s, uint16_t rp, uint16_t lp)
n += skipspace(s+n) ; if (!s[n]) goto err ;
if (s[n++] != ':') goto err ;
n += skipspace(s+n) ; if (!s[n]) goto err ;
- if (!str_diffn(s+n, "ERROR", 5)) goto ERROR ;
- if (!str_diffn(s+n, "USERID", 6)) goto USERID ;
+ if (!strncmp(s+n, "ERROR", 5)) goto ERROR ;
+ if (!strncmp(s+n, "USERID", 6)) goto USERID ;
err:
return (errno = EPROTO, -1) ;
@@ -43,10 +43,10 @@ ssize_t s6net_ident_reply_parse (char const *s, uint16_t rp, uint16_t lp)
n += skipspace(s+n) ; if (!s[n]) goto err ;
if (s[n++] != ':') goto err ;
n += skipspace(s+n) ; if (!s[n]) goto err ;
- if (!str_diffn(s+n, "INVALID-PORT", 12)) return (errno = EINVAL, 0) ;
- if (!str_diffn(s+n, "NO-USER", 7)) return (errno = ESRCH, 0) ;
- if (!str_diffn(s+n, "HIDDEN-USER", 11)) return (errno = EPERM, 0) ;
- if (!str_diffn(s+n, "UNKNOWN-ERROR", 13)) return (errno = EIO, 0) ;
+ if (!strncmp(s+n, "INVALID-PORT", 12)) return (errno = EINVAL, 0) ;
+ if (!strncmp(s+n, "NO-USER", 7)) return (errno = ESRCH, 0) ;
+ if (!strncmp(s+n, "HIDDEN-USER", 11)) return (errno = EPERM, 0) ;
+ if (!strncmp(s+n, "UNKNOWN-ERROR", 13)) return (errno = EIO, 0) ;
if (s[n] == 'X') return (errno = EEXIST, 0) ;
goto err ;