Update incl. fix to MacOS Makefile
Merge branch 'master' of https://github.com/USNavalResearchLaboratory/normpull/86/head
commit
78052bdb29
|
|
@ -152,15 +152,15 @@ namespace ProtoPktSOCKS
|
||||||
|
|
||||||
UINT8 GetVersion() const
|
UINT8 GetVersion() const
|
||||||
{return ((pkt_length > OFFSET_VERSION) ?
|
{return ((pkt_length > OFFSET_VERSION) ?
|
||||||
(((UINT8*)buffer_ptr)[OFFSET_VERSION]) : 0);}
|
GetUINT8(OFFSET_VERSION) : 0);}
|
||||||
|
|
||||||
Command GetCommand() const
|
Command GetCommand() const
|
||||||
{return ((pkt_length > OFFSET_COMMAND) ?
|
{return ((pkt_length > OFFSET_COMMAND) ?
|
||||||
(Command)(((UINT8*)buffer_ptr)[OFFSET_COMMAND]) : CMD_INVALID);}
|
(Command)GetUINT8(OFFSET_COMMAND) : CMD_INVALID);}
|
||||||
|
|
||||||
AddrType GetAddressType() const
|
AddrType GetAddressType() const
|
||||||
{return ((pkt_length > OFFSET_ATYPE) ?
|
{return ((pkt_length > OFFSET_ATYPE) ?
|
||||||
(AddrType)(((UINT8*)buffer_ptr)[OFFSET_ATYPE]) : ADDR_INVALID);}
|
(AddrType)GetUINT8(OFFSET_ATYPE) : ADDR_INVALID);}
|
||||||
|
|
||||||
UINT8 GetAddressLength() const;
|
UINT8 GetAddressLength() const;
|
||||||
|
|
||||||
|
|
@ -175,18 +175,18 @@ namespace ProtoPktSOCKS
|
||||||
|
|
||||||
void SetVersion(UINT8 version)
|
void SetVersion(UINT8 version)
|
||||||
{
|
{
|
||||||
((UINT8*)buffer_ptr)[OFFSET_VERSION] = version;
|
SetUINT8(OFFSET_VERSION, version);
|
||||||
pkt_length = 1;
|
pkt_length = 1;
|
||||||
}
|
}
|
||||||
void SetCommand(Command cmd)
|
void SetCommand(Command cmd)
|
||||||
{
|
{
|
||||||
((UINT8*)buffer_ptr)[OFFSET_COMMAND] = (UINT8)cmd;
|
SetUINT8(OFFSET_COMMAND, (UINT8)cmd);
|
||||||
pkt_length = 2;
|
pkt_length = 2;
|
||||||
}
|
}
|
||||||
void SetAddressType(AddrType addrType)
|
void SetAddressType(AddrType addrType)
|
||||||
{
|
{
|
||||||
((UINT8*)buffer_ptr)[OFFSET_RESERVED] = 0;
|
((UINT8*)buffer_ptr)[OFFSET_RESERVED] = 0;
|
||||||
((UINT8*)buffer_ptr)[OFFSET_ATYPE] = (UINT8)addrType;
|
SetUINT8(OFFSET_ATYPE, (UINT8)addrType);
|
||||||
pkt_length = 4;
|
pkt_length = 4;
|
||||||
}
|
}
|
||||||
bool SetAddress(const ProtoAddress& theAddr); // note this sets port, too
|
bool SetAddress(const ProtoAddress& theAddr); // note this sets port, too
|
||||||
|
|
@ -244,15 +244,15 @@ namespace ProtoPktSOCKS
|
||||||
|
|
||||||
UINT8 GetVersion() const
|
UINT8 GetVersion() const
|
||||||
{return ((pkt_length > OFFSET_VERSION) ?
|
{return ((pkt_length > OFFSET_VERSION) ?
|
||||||
(((UINT8*)buffer_ptr)[OFFSET_VERSION]) : 0);}
|
GetUINT8(OFFSET_VERSION) : 0);}
|
||||||
|
|
||||||
Type GetType() const
|
Type GetType() const
|
||||||
{return ((pkt_length > OFFSET_TYPE) ?
|
{return ((pkt_length > OFFSET_TYPE) ?
|
||||||
(Type)(((UINT8*)buffer_ptr)[OFFSET_TYPE]) : TYPE_INVALID);}
|
(Type)GetUINT8(OFFSET_TYPE) : TYPE_INVALID);}
|
||||||
|
|
||||||
AddrType GetAddressType() const
|
AddrType GetAddressType() const
|
||||||
{return ((pkt_length > OFFSET_ATYPE) ?
|
{return ((pkt_length > OFFSET_ATYPE) ?
|
||||||
(AddrType)(((UINT8*)buffer_ptr)[OFFSET_ATYPE]) : ADDR_INVALID);}
|
(AddrType)GetUINT8(OFFSET_ATYPE) : ADDR_INVALID);}
|
||||||
|
|
||||||
UINT8 GetAddressLength() const;
|
UINT8 GetAddressLength() const;
|
||||||
|
|
||||||
|
|
@ -266,12 +266,12 @@ namespace ProtoPktSOCKS
|
||||||
// Reply building (call these in order
|
// Reply building (call these in order
|
||||||
void SetVersion(UINT8 version)
|
void SetVersion(UINT8 version)
|
||||||
{
|
{
|
||||||
((UINT8*)buffer_ptr)[OFFSET_VERSION] = version;
|
SetUINT8(OFFSET_VERSION, version);
|
||||||
pkt_length = 1;
|
pkt_length = 1;
|
||||||
}
|
}
|
||||||
void SetType(Type replyType)
|
void SetType(Type replyType)
|
||||||
{
|
{
|
||||||
((UINT8*)buffer_ptr)[OFFSET_TYPE] = (UINT8)replyType;
|
SetUINT8(OFFSET_TYPE, (UINT8)replyType);
|
||||||
pkt_length = 2;
|
pkt_length = 2;
|
||||||
}
|
}
|
||||||
void SetAddress(AddrType addrType, const char* addrPtr, UINT8 addrLen);
|
void SetAddress(AddrType addrType, const char* addrPtr, UINT8 addrLen);
|
||||||
|
|
@ -316,11 +316,11 @@ namespace ProtoPktSOCKS
|
||||||
|
|
||||||
UINT8 GetFrag() const
|
UINT8 GetFrag() const
|
||||||
{return ((pkt_length > OFFSET_FRAG) ?
|
{return ((pkt_length > OFFSET_FRAG) ?
|
||||||
(((UINT8*)buffer_ptr)[OFFSET_FRAG]) : 0);}
|
GetUINT8(OFFSET_FRAG) : 0);}
|
||||||
|
|
||||||
AddrType GetAddressType() const
|
AddrType GetAddressType() const
|
||||||
{return ((pkt_length > OFFSET_ATYPE) ?
|
{return ((pkt_length > OFFSET_ATYPE) ?
|
||||||
(AddrType)(((UINT8*)buffer_ptr)[OFFSET_ATYPE]) : ADDR_INVALID);}
|
(AddrType)GetUINT8(OFFSET_ATYPE) : ADDR_INVALID);}
|
||||||
|
|
||||||
UINT8 GetAddressLength() const;
|
UINT8 GetAddressLength() const;
|
||||||
|
|
||||||
|
|
@ -342,7 +342,8 @@ namespace ProtoPktSOCKS
|
||||||
void SetFragment(UINT8 fragId)
|
void SetFragment(UINT8 fragId)
|
||||||
{
|
{
|
||||||
((UINT8*)buffer_ptr)[OFFSET_RESERVED] = 0;
|
((UINT8*)buffer_ptr)[OFFSET_RESERVED] = 0;
|
||||||
((UINT8*)buffer_ptr)[OFFSET_FRAG] = fragId;
|
SetUINT8(OFFSET_RESERVED, 0);
|
||||||
|
SetUINT8(OFFSET_FRAG, fragId);
|
||||||
pkt_length = OFFSET_FRAG + 1;
|
pkt_length = OFFSET_FRAG + 1;
|
||||||
}
|
}
|
||||||
void SetAddress(AddrType addrType, const char* addrPtr, UINT8 addrLen);
|
void SetAddress(AddrType addrType, const char* addrPtr, UINT8 addrLen);
|
||||||
|
|
|
||||||
|
|
@ -533,6 +533,7 @@ bool NorpSession::PutClientAuthReply()
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// AuthReply was fully sent
|
// AuthReply was fully sent
|
||||||
|
TRACE("AuthReply fully sent %d bytes ...\n", remote_index);
|
||||||
socks_client_socket.StopOutputNotification();
|
socks_client_socket.StopOutputNotification();
|
||||||
socks_state = SOCKS_GET_REQUEST;
|
socks_state = SOCKS_GET_REQUEST;
|
||||||
remote_pending = remote_index = 0;
|
remote_pending = remote_index = 0;
|
||||||
|
|
|
||||||
|
|
@ -136,6 +136,7 @@ bool NormFile::Open(const char* thePath, int theFlags)
|
||||||
if((fd = open(thePath, theFlags, 0640)) >= 0)
|
if((fd = open(thePath, theFlags, 0640)) >= 0)
|
||||||
{
|
{
|
||||||
offset = 0;
|
offset = 0;
|
||||||
|
flags = theFlags;
|
||||||
return true; // no error
|
return true; // no error
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
@ -246,9 +247,11 @@ bool NormFile::Rename(const char* oldName, const char* newName)
|
||||||
#endif // WIN32
|
#endif // WIN32
|
||||||
// In Win32, the old file can't be open and on Unix (Linux at least), it's better
|
// In Win32, the old file can't be open and on Unix (Linux at least), it's better
|
||||||
// performance to close/reopen a file being renamed
|
// performance to close/reopen a file being renamed
|
||||||
|
bool wasOpen = false;
|
||||||
int oldFlags = 0;
|
int oldFlags = 0;
|
||||||
if (IsOpen())
|
if (IsOpen())
|
||||||
{
|
{
|
||||||
|
wasOpen = true;
|
||||||
oldFlags = flags;
|
oldFlags = flags;
|
||||||
oldFlags &= ~(O_CREAT | O_TRUNC); // unset these
|
oldFlags &= ~(O_CREAT | O_TRUNC); // unset these
|
||||||
Close();
|
Close();
|
||||||
|
|
@ -321,22 +324,19 @@ bool NormFile::Rename(const char* oldName, const char* newName)
|
||||||
{
|
{
|
||||||
PLOG(PL_ERROR, "NormFile::Rename() rename() error: %s\n", GetErrorString());
|
PLOG(PL_ERROR, "NormFile::Rename() rename() error: %s\n", GetErrorString());
|
||||||
#endif // if/else _WIN32_WCE / WIN32|UNIX
|
#endif // if/else _WIN32_WCE / WIN32|UNIX
|
||||||
if (oldFlags)
|
if (wasOpen && !Open(oldName, oldFlags))
|
||||||
{
|
PLOG(PL_ERROR, "NormFile::Rename() error re-opening file w/ old name\n");
|
||||||
if (!Open(oldName, oldFlags))
|
|
||||||
PLOG(PL_ERROR, "NormFile::Rename() error re-opening file w/ old name\n");
|
|
||||||
}
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (oldFlags)
|
if (wasOpen && !Open(newName, oldFlags))
|
||||||
{
|
{
|
||||||
if (!Open(newName, oldFlags))
|
PLOG(PL_ERROR, "NormFile::Rename() error opening file w/ new name\n");
|
||||||
PLOG(PL_ERROR, "NormFile::Rename() error opening file w/ new name\n");
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
} // end NormFile::Rename()
|
} // end NormFile::Rename()
|
||||||
|
|
||||||
size_t NormFile::Read(char* buffer, size_t len)
|
size_t NormFile::Read(char* buffer, size_t len)
|
||||||
|
|
@ -388,10 +388,11 @@ size_t NormFile::Write(const char* buffer, size_t len)
|
||||||
#endif // if/else _WIN32_WCE
|
#endif // if/else _WIN32_WCE
|
||||||
#else
|
#else
|
||||||
size_t result = write(fd, buffer+put, len-put);
|
size_t result = write(fd, buffer+put, len-put);
|
||||||
|
if (result <= 0) perror("NormFile::Write() write() error");
|
||||||
#endif // if/else WIN32
|
#endif // if/else WIN32
|
||||||
if (result <= 0)
|
if (result <= 0)
|
||||||
{
|
{
|
||||||
#ifndef _WIN32_WCE
|
#ifndef _WIN32_WCE
|
||||||
if (EINTR != errno)
|
if (EINTR != errno)
|
||||||
#endif // !_WIN32_WCE
|
#endif // !_WIN32_WCE
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue