mirror of
https://github.com/yuzu-emu/mbedtls.git
synced 2024-11-22 11:45:42 +01:00
- Made net_htons() endian-clean for big endian.
This commit is contained in:
parent
2b245ebd9f
commit
1d4f30ca4d
@ -14,6 +14,8 @@ PolarSSL ChangeLog
|
||||
Olsson).
|
||||
* Centralized file opening and reading for x509 files into
|
||||
load_file()
|
||||
* Made definition of net_htons() endian-clean for big endian
|
||||
systems (Found by Gernot).
|
||||
|
||||
= Version 0.10.0 released on 2009-01-12
|
||||
* Migrated XySSL to PolarSSL
|
||||
|
@ -55,6 +55,7 @@ static int wsa_init_done = 0;
|
||||
#include <fcntl.h>
|
||||
#include <netdb.h>
|
||||
#include <errno.h>
|
||||
#include <endian.h>
|
||||
|
||||
#endif
|
||||
|
||||
@ -64,18 +65,18 @@ static int wsa_init_done = 0;
|
||||
#include <time.h>
|
||||
|
||||
/*
|
||||
* htons() is not always available
|
||||
* htons() is not always available.
|
||||
* By default go for LITTLE_ENDIAN variant. Otherwise hope for _BYTE_ORDER and __BIG_ENDIAN
|
||||
* to help determine endianess.
|
||||
*/
|
||||
static unsigned short net_htons( int port )
|
||||
{
|
||||
unsigned char buf[4];
|
||||
#if defined(__BYTE_ORDER) && defined(__BIG_ENDIAN) && __BYTE_ORDER == __BIG_ENDIAN
|
||||
#define HTONS(n) (n)
|
||||
#else
|
||||
#define HTONS(n) (((((unsigned short)(n) & 0xFF)) << 8) | (((unsigned short)(n) & 0xFF00) >> 8))
|
||||
#endif
|
||||
|
||||
buf[0] = (unsigned char)( port >> 8 );
|
||||
buf[1] = (unsigned char)( port );
|
||||
buf[2] = buf[3] = 0;
|
||||
|
||||
return( *(unsigned short *) buf );
|
||||
}
|
||||
unsigned short net_htons(unsigned short n);
|
||||
#define net_htons(n) HTONS(n)
|
||||
|
||||
/*
|
||||
* Initiate a TCP connection with host:port
|
||||
|
Loading…
Reference in New Issue
Block a user