From e33e19d0587146859d48a134ec9fd94e7b7ba5cd Mon Sep 17 00:00:00 2001 From: "FWoltermann@gmail.com" Date: Thu, 8 Dec 2011 14:53:40 +0000 Subject: Initial upload --- NetEx/NetAddr.h | 58 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 NetEx/NetAddr.h (limited to 'NetEx/NetAddr.h') diff --git a/NetEx/NetAddr.h b/NetEx/NetAddr.h new file mode 100644 index 0000000..562dc64 --- /dev/null +++ b/NetEx/NetAddr.h @@ -0,0 +1,58 @@ +/* Project nGenEx + Destroyer Studios LLC + Copyright © 1997-2004. All Rights Reserved. + + SUBSYSTEM: NetEx.lib + FILE: NetAddr.h + AUTHOR: John DiCamillo + + + OVERVIEW + ======== + Network Address (specifically, Internet Protocol) +*/ + + +#ifndef NetAddr_h +#define NetAddr_h + +#include + +// +-------------------------------------------------------------------+ + +class NetAddr +{ +public: + static const char* TYPENAME() { return "NetAddr"; } + + NetAddr(const char* a, WORD p=0); + NetAddr(DWORD a=0, WORD p=0); + NetAddr(const NetAddr& n); + + int operator == (const NetAddr& a) const { return addr==a.addr && port==a.port; } + + DWORD IPAddr() const { return addr; } + BYTE B4() const { return (BYTE) ((addr & 0xff000000) >> 24); } + BYTE B3() const { return (BYTE) ((addr & 0x00ff0000) >> 16); } + BYTE B2() const { return (BYTE) ((addr & 0x0000ff00) >> 8); } + BYTE B1() const { return (BYTE) ((addr & 0x000000ff) ); } + + WORD Port() const { return port; } + void SetPort(WORD p) { port = p; } + + sockaddr* GetSockAddr() const; + size_t GetSockAddrLength() const; + + void SetSockAddr(sockaddr* s, int size); + void InitFromSockAddr(); + +private: + void Init(); + + DWORD addr; // IP addr in host byte order + WORD port; // IP port in host byte order + sockaddr_in sadr; +}; + + +#endif NetAddr_h \ No newline at end of file -- cgit v1.1