2006-08-29 04:19:23 +04:00
|
|
|
/*
|
|
|
|
* Copyright 2002-2006, Haiku, Inc. All Rights Reserved.
|
|
|
|
* Distributed under the terms of the MIT License.
|
2002-11-01 05:49:38 +03:00
|
|
|
*/
|
2006-08-29 04:19:23 +04:00
|
|
|
#ifndef H_NETADDRESS
|
|
|
|
#define H_NETADDRESS
|
2002-11-01 05:49:38 +03:00
|
|
|
|
|
|
|
|
|
|
|
#include <BeBuild.h>
|
|
|
|
#include <SupportDefs.h>
|
|
|
|
#include <Archivable.h>
|
|
|
|
|
2006-08-29 04:19:23 +04:00
|
|
|
#include <netinet/in.h>
|
|
|
|
#include <sys/socket.h>
|
2002-11-01 05:49:38 +03:00
|
|
|
|
|
|
|
|
2006-08-29 04:19:23 +04:00
|
|
|
class BNetAddress : public BArchivable {
|
|
|
|
public:
|
|
|
|
BNetAddress(BMessage* archive);
|
|
|
|
virtual ~BNetAddress();
|
2002-11-01 05:49:38 +03:00
|
|
|
|
2006-08-29 04:19:23 +04:00
|
|
|
virtual status_t Archive(BMessage* into, bool deep = true) const;
|
|
|
|
static BArchivable* Instantiate(BMessage* archive);
|
2002-11-01 05:49:38 +03:00
|
|
|
|
2006-08-29 04:19:23 +04:00
|
|
|
BNetAddress(const char* hostname = 0, unsigned short port = 0);
|
|
|
|
BNetAddress(const struct sockaddr_in& addr);
|
|
|
|
BNetAddress(in_addr addr, int port = 0);
|
|
|
|
BNetAddress(uint32 addr, int port = 0);
|
|
|
|
BNetAddress(const BNetAddress& other);
|
2008-07-13 23:58:35 +04:00
|
|
|
BNetAddress(const char* hostname, const char* protocol,
|
|
|
|
const char* service);
|
2002-11-01 05:49:38 +03:00
|
|
|
|
2006-08-29 04:19:23 +04:00
|
|
|
BNetAddress& operator=(const BNetAddress&);
|
2002-11-01 05:49:38 +03:00
|
|
|
|
2008-07-13 23:58:35 +04:00
|
|
|
status_t InitCheck() const;
|
2002-11-01 05:49:38 +03:00
|
|
|
|
2008-07-13 23:58:35 +04:00
|
|
|
status_t SetTo(const char* hostname, const char* protocol,
|
|
|
|
const char* service);
|
2006-08-29 04:19:23 +04:00
|
|
|
status_t SetTo(const char* hostname = NULL, unsigned short port = 0);
|
|
|
|
status_t SetTo(const struct sockaddr_in& addr);
|
|
|
|
status_t SetTo(in_addr addr, int port = 0);
|
|
|
|
status_t SetTo(uint32 addr = INADDR_ANY, int port = 0);
|
2002-11-01 05:49:38 +03:00
|
|
|
|
2008-07-13 23:58:35 +04:00
|
|
|
status_t GetAddr(char* hostname = NULL,
|
|
|
|
unsigned short* port = NULL) const;
|
2006-08-29 04:19:23 +04:00
|
|
|
status_t GetAddr(struct sockaddr_in& addr) const;
|
|
|
|
status_t GetAddr(in_addr& addr, unsigned short* port = NULL) const;
|
2002-12-17 04:24:44 +03:00
|
|
|
|
2008-07-13 23:58:35 +04:00
|
|
|
// TODO: drop this compatibility cruft method after R1
|
|
|
|
status_t InitCheck();
|
|
|
|
|
2006-08-29 04:19:23 +04:00
|
|
|
private:
|
|
|
|
virtual void _ReservedBNetAddressFBCCruft1();
|
|
|
|
virtual void _ReservedBNetAddressFBCCruft2();
|
|
|
|
virtual void _ReservedBNetAddressFBCCruft3();
|
|
|
|
virtual void _ReservedBNetAddressFBCCruft4();
|
|
|
|
virtual void _ReservedBNetAddressFBCCruft5();
|
|
|
|
virtual void _ReservedBNetAddressFBCCruft6();
|
2002-11-01 05:49:38 +03:00
|
|
|
|
2006-08-29 04:19:23 +04:00
|
|
|
status_t fInit;
|
2008-07-06 02:37:06 +04:00
|
|
|
int16 fFamily;
|
|
|
|
int16 fPort;
|
2006-08-29 04:19:23 +04:00
|
|
|
int32 fAddress;
|
2008-07-06 02:37:06 +04:00
|
|
|
int32 fPrivateData[7];
|
2002-11-01 05:49:38 +03:00
|
|
|
};
|
|
|
|
|
2006-08-29 04:19:23 +04:00
|
|
|
#endif // H_NETADDRESS
|