mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-23 09:04:13 +00:00
portbility fixes for mswindows
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@36829 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
9151fe541b
commit
f20a131f27
5 changed files with 23 additions and 10 deletions
|
@ -1,3 +1,11 @@
|
|||
2013-07-04 Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
* Source\GSSocksParser\GSSocksParser.h:
|
||||
* Source\GSSocksParser\GSSocksParserPrivate.m:
|
||||
* Source\GSSocksParser\GSSocks4Parser.m:
|
||||
* Source\GSSocksParser\GSSocks5Parser.m:
|
||||
More portability fixes ... this tme for mswindows.
|
||||
|
||||
2013-07-04 Ibadinov Marat <ibadinov@me.com>
|
||||
|
||||
* GSSocksParser/GSSocks5Parser.m:
|
||||
|
|
|
@ -27,7 +27,6 @@
|
|||
|
||||
#import "GSSocks4Parser.h"
|
||||
#import "GSSocksParserPrivate.h"
|
||||
#import <arpa/inet.h>
|
||||
|
||||
typedef enum GSSocks4InternalError {
|
||||
GSSocks4InternalErrorIPv6 = 0x4a
|
||||
|
@ -83,7 +82,7 @@ typedef enum GSSocks4ResponseStatus {
|
|||
bytes = [data mutableBytes];
|
||||
bytes[0] = 0x4;
|
||||
bytes[1] = 0x1;
|
||||
*(uint16_t *)(bytes + 2) = htons((uint16_t)port);
|
||||
*(uint16_t *)(bytes + 2) = NSSwapHostShortToBig((uint16_t)port);
|
||||
if (addressType == GSSocksAddressTypeDomain)
|
||||
{
|
||||
bytes[4] = bytes[5] = bytes[6] = 0;
|
||||
|
@ -93,7 +92,7 @@ typedef enum GSSocks4ResponseStatus {
|
|||
{
|
||||
const uint32_t *addressBytes = [[self addressData] bytes];
|
||||
|
||||
*(uint32_t *)(bytes + 4) = htonl(*addressBytes);
|
||||
*(uint32_t *)(bytes + 4) = NSSwapHostLongToBig(*addressBytes);
|
||||
}
|
||||
zero = 0x0;
|
||||
user = [configuration objectForKey: NSStreamSOCKSProxyUserKey];
|
||||
|
@ -152,8 +151,8 @@ typedef enum GSSocks4ResponseStatus {
|
|||
return;
|
||||
}
|
||||
|
||||
bndPort = ntohs(*(uint16_t *)(bytes + 2));
|
||||
addressBytes = ntohl(*(uint32_t *)(bytes + 4));
|
||||
bndPort = NSSwapBigShortToHost(*(uint16_t *)(bytes + 2));
|
||||
addressBytes = NSSwapBigLongToHost(*(uint32_t *)(bytes + 4));
|
||||
addressData = [NSData dataWithBytesNoCopy: &addressBytes
|
||||
length: 4
|
||||
freeWhenDone: NO];
|
||||
|
|
|
@ -27,7 +27,6 @@
|
|||
|
||||
#import "GSSocks5Parser.h"
|
||||
#import "GSSocksParserPrivate.h"
|
||||
#import <arpa/inet.h>
|
||||
|
||||
typedef enum GSSocks5ParserState {
|
||||
GSSocks5ParserStateHandshake,
|
||||
|
@ -222,7 +221,7 @@ typedef enum GSSocks5ResponseStatus {
|
|||
[data appendBytes: &length length: 1];
|
||||
}
|
||||
[data appendData: addressData];
|
||||
portWithNetworkEndianness = htons((uint16_t)port);
|
||||
portWithNetworkEndianness = NSSwapHostShortToBig((uint16_t)port);
|
||||
[data appendBytes: &portWithNetworkEndianness length: 2];
|
||||
|
||||
state = GSSocks5ParserStateResponse;
|
||||
|
@ -269,7 +268,7 @@ typedef enum GSSocks5ResponseStatus {
|
|||
length: addressSize];
|
||||
bndAddress = [self addressFromData: data
|
||||
withType: addressType];
|
||||
bndPort = ntohs(*(uint16_t *)(bytes + addressSize));
|
||||
bndPort = NSSwapBigShortToHost(*(uint16_t *)(bytes + addressSize));
|
||||
[delegate parser: self finishedWithAddress: bndAddress port: bndPort];
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
* $Date$ $Revision$
|
||||
*/
|
||||
|
||||
#import <Foundation/NSByteOrder.h>
|
||||
#import <Foundation/NSData.h>
|
||||
#import <Foundation/NSDictionary.h>
|
||||
#import <Foundation/NSError.h>
|
||||
|
|
|
@ -104,10 +104,16 @@
|
|||
{
|
||||
NSMutableData *result = [NSMutableData dataWithLength: 4];
|
||||
const char *cString = [address UTF8String];
|
||||
int elements[4];
|
||||
uint8_t *bytes = [result mutableBytes];
|
||||
|
||||
sscanf(cString, "%hhu.%hhu.%hhu.%hhu",
|
||||
&bytes[0], &bytes[1], &bytes[2], &bytes[3]);
|
||||
sscanf(cString, "%d.%d.%d.%d",
|
||||
&elements[0], &elements[1], &elements[2], &elements[3]);
|
||||
bytes[0] = (uint8_t)elements[0];
|
||||
bytes[1] = (uint8_t)elements[1];
|
||||
bytes[2] = (uint8_t)elements[2];
|
||||
bytes[3] = (uint8_t)elements[3];
|
||||
|
||||
return result;
|
||||
}
|
||||
case GSSocksAddressTypeIPv6:
|
||||
|
|
Loading…
Reference in a new issue