diff options
author | Andreas Schneider <asn@cryptomilk.org> | 2016-11-07 09:39:19 +0100 |
---|---|---|
committer | Andreas Schneider <asn@cryptomilk.org> | 2016-11-07 09:43:09 +0100 |
commit | 410f722ae57a503c31135d99137eabf5d5d0e751 (patch) | |
tree | 43c873dff9da49aa8a716e35d23485944c153d9e /include/libssh | |
parent | 8155b3c0a0f94ff088d05b877708b519b0e7d507 (diff) | |
download | libssh-410f722ae57a503c31135d99137eabf5d5d0e751.tar.gz libssh-410f722ae57a503c31135d99137eabf5d5d0e751.tar.xz libssh-410f722ae57a503c31135d99137eabf5d5d0e751.zip |
misc: Use simpler macros for htonll and ntohll
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
(cherry picked from commit 52efbc3a23fd62640177c96a14df76c42a1b462c)
Diffstat (limited to 'include/libssh')
-rw-r--r-- | include/libssh/misc.h | 9 | ||||
-rw-r--r-- | include/libssh/priv.h | 18 |
2 files changed, 18 insertions, 9 deletions
diff --git a/include/libssh/misc.h b/include/libssh/misc.h index 1e69b069..128e2ba9 100644 --- a/include/libssh/misc.h +++ b/include/libssh/misc.h @@ -33,15 +33,6 @@ int ssh_analyze_banner(ssh_session session, int server, int *ssh1, int *ssh2); int ssh_is_ipaddr_v4(const char *str); int ssh_is_ipaddr(const char *str); -#ifndef HAVE_NTOHLL -/* macro for byte ordering */ -uint64_t ntohll(uint64_t); -#endif - -#ifndef HAVE_HTONLL -#define htonll(x) ntohll((x)) -#endif - /* list processing */ struct ssh_list { diff --git a/include/libssh/priv.h b/include/libssh/priv.h index 97cbcfc1..5a74915e 100644 --- a/include/libssh/priv.h +++ b/include/libssh/priv.h @@ -361,6 +361,24 @@ int match_hostname(const char *host, const char *pattern, unsigned int len); #define CLOSE_SOCKET(s) do { if ((s) != SSH_INVALID_SOCKET) { _XCLOSESOCKET(s); (s) = SSH_INVALID_SOCKET;} } while(0) +#ifndef HAVE_HTONLL +# ifdef WORDS_BIGENDIAN +# define htonll(x) (x) +# else +# define htonll(x) \ + (((uint64_t)htonl((x) & 0xFFFFFFFF) << 32) | htonl((x) >> 32)) +# endif +#endif + +#ifndef HAVE_NTOHLL +# ifdef WORDS_BIGENDIAN +# define ntohll(x) (x) +# else +# define ntohll(x) \ + (((uint64_t)ntohl((x) & 0xFFFFFFFF) << 32) | ntohl((x) >> 32)) +# endif +#endif + void ssh_agent_state_free(void *data); #endif /* _LIBSSH_PRIV_H */ |