xref: /haiku/headers/os/net/NetworkAddressResolver.h (revision 99d027cd0238c1d86da86d7c3f4200509ccc61a6)
1 /*
2  * Copyright 2010, Haiku, Inc. All Rights Reserved.
3  * Distributed under the terms of the MIT License.
4  */
5 #ifndef _NETWORK_ADDRESS_RESOLVER_H
6 #define _NETWORK_ADDRESS_RESOLVER_H
7 
8 
9 #include <SupportDefs.h>
10 
11 
12 class BNetworkAddress;
13 struct addrinfo;
14 
15 
16 // flags for name resolution
17 enum {
18 	B_NO_ADDRESS_RESOLUTION			= 0x0001,
19 	B_UNCONFIGURED_ADDRESS_FAMILIES	= 0x0002,
20 };
21 
22 
23 class BNetworkAddressResolver {
24 public:
25 								BNetworkAddressResolver();
26 								BNetworkAddressResolver(const char* address,
27 									uint16 port = 0, uint32 flags = 0);
28 								BNetworkAddressResolver(const char* address,
29 									const char* service, uint32 flags = 0);
30 								BNetworkAddressResolver(int family,
31 									const char* address, uint16 port = 0,
32 									uint32 flags = 0);
33 								BNetworkAddressResolver(int family,
34 									const char* address, const char* service,
35 									uint32 flags = 0);
36 								~BNetworkAddressResolver();
37 
38 			status_t			InitCheck() const;
39 
40 			void				Unset();
41 
42 			status_t			SetTo(const char* address, uint16 port = 0,
43 									uint32 flags = 0);
44 			status_t			SetTo(const char* address, const char* service,
45 									uint32 flags = 0);
46 			status_t			SetTo(int family, const char* address,
47 									uint16 port = 0, uint32 flags = 0);
48 			status_t			SetTo(int family, const char* address,
49 									const char* service, uint32 flags = 0);
50 
51 			status_t			GetNextAddress(uint32* cookie,
52 									BNetworkAddress& address) const;
53 			status_t			GetNextAddress(int family, uint32* cookie,
54 									BNetworkAddress& address) const;
55 
56 private:
57 			addrinfo*			fInfo;
58 			status_t			fStatus;
59 };
60 
61 
62 #endif	// _NETWORK_ADDRESS_RESOLVER_H
63