[89] | 1 | /*
|
---|
| 2 | * Licensed to the Apache Software Foundation (ASF) under one or more
|
---|
| 3 | * contributor license agreements. See the NOTICE file distributed with
|
---|
| 4 | * this work for additional information regarding copyright ownership.
|
---|
| 5 | * The ASF licenses this file to You under the Apache License, Version 2.0
|
---|
| 6 | * (the "License"); you may not use this file except in compliance with
|
---|
| 7 | * the License. You may obtain a copy of the License at
|
---|
| 8 | *
|
---|
| 9 | * http://www.apache.org/licenses/LICENSE-2.0
|
---|
| 10 | *
|
---|
| 11 | * Unless required by applicable law or agreed to in writing, software
|
---|
| 12 | * distributed under the License is distributed on an "AS IS" BASIS,
|
---|
| 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
---|
| 14 | * See the License for the specific language governing permissions and
|
---|
| 15 | * limitations under the License.
|
---|
| 16 | */
|
---|
| 17 |
|
---|
| 18 | #ifndef _LOG4CXX_HELPER_INETADDRESS_H
|
---|
| 19 | #define _LOG4CXX_HELPER_INETADDRESS_H
|
---|
| 20 |
|
---|
| 21 | #if defined(_MSC_VER)
|
---|
| 22 | #pragma warning ( push )
|
---|
| 23 | #pragma warning ( disable: 4231 4251 4275 4786 )
|
---|
| 24 | #endif
|
---|
| 25 |
|
---|
| 26 |
|
---|
| 27 |
|
---|
| 28 | #include <log4cxx/helpers/objectimpl.h>
|
---|
| 29 | #include <log4cxx/helpers/objectptr.h>
|
---|
| 30 | #include <log4cxx/logstring.h>
|
---|
| 31 | #include <vector>
|
---|
| 32 | #include <log4cxx/helpers/exception.h>
|
---|
| 33 |
|
---|
| 34 | namespace log4cxx
|
---|
| 35 | {
|
---|
| 36 | namespace helpers
|
---|
| 37 | {
|
---|
| 38 | class LOG4CXX_EXPORT UnknownHostException : public Exception
|
---|
| 39 | {
|
---|
| 40 | public:
|
---|
| 41 | UnknownHostException(const LogString& msg);
|
---|
| 42 | UnknownHostException(const UnknownHostException& src);
|
---|
| 43 | UnknownHostException& operator=(const UnknownHostException& src);
|
---|
| 44 | };
|
---|
| 45 |
|
---|
| 46 |
|
---|
| 47 | class InetAddress;
|
---|
| 48 | LOG4CXX_PTR_DEF(InetAddress);
|
---|
| 49 | LOG4CXX_LIST_DEF(InetAddressList, InetAddressPtr);
|
---|
| 50 |
|
---|
| 51 | class LOG4CXX_EXPORT InetAddress : public ObjectImpl
|
---|
| 52 | {
|
---|
| 53 | public:
|
---|
| 54 | DECLARE_ABSTRACT_LOG4CXX_OBJECT(InetAddress)
|
---|
| 55 | BEGIN_LOG4CXX_CAST_MAP()
|
---|
| 56 | LOG4CXX_CAST_ENTRY(InetAddress)
|
---|
| 57 | END_LOG4CXX_CAST_MAP()
|
---|
| 58 |
|
---|
| 59 | InetAddress(const LogString& hostName, const LogString& hostAddr);
|
---|
| 60 |
|
---|
| 61 | /** Determines all the IP addresses of a host, given the host's name.
|
---|
| 62 | */
|
---|
| 63 | static InetAddressList getAllByName(const LogString& host);
|
---|
| 64 |
|
---|
| 65 | /** Determines the IP address of a host, given the host's name.
|
---|
| 66 | */
|
---|
| 67 | static InetAddressPtr getByName(const LogString& host);
|
---|
| 68 |
|
---|
| 69 | /** Returns the IP address string "%d.%d.%d.%d".
|
---|
| 70 | */
|
---|
| 71 | LogString getHostAddress() const;
|
---|
| 72 |
|
---|
| 73 | /** Gets the host name for this IP address.
|
---|
| 74 | */
|
---|
| 75 | LogString getHostName() const;
|
---|
| 76 |
|
---|
| 77 | /** Returns the local host.
|
---|
| 78 | */
|
---|
| 79 | static InetAddressPtr getLocalHost();
|
---|
| 80 |
|
---|
| 81 | /** Returns an InetAddress which can be used as any
|
---|
| 82 | * address, for example when listening on a port from any
|
---|
| 83 | * remote addresss.
|
---|
| 84 | */
|
---|
| 85 | static InetAddressPtr anyAddress();
|
---|
| 86 |
|
---|
| 87 | /** Converts this IP address to a String.
|
---|
| 88 | */
|
---|
| 89 | LogString toString() const;
|
---|
| 90 |
|
---|
| 91 | private:
|
---|
| 92 | LogString ipAddrString;
|
---|
| 93 |
|
---|
| 94 | LogString hostNameString;
|
---|
| 95 |
|
---|
| 96 | }; // class InetAddress
|
---|
| 97 | } // namespace helpers
|
---|
| 98 | } // namespace log4cxx
|
---|
| 99 |
|
---|
| 100 | #if defined(_MSC_VER)
|
---|
| 101 | #pragma warning ( pop )
|
---|
| 102 | #endif
|
---|
| 103 |
|
---|
| 104 |
|
---|
| 105 | #endif // _LOG4CXX_HELPER_INETADDRESS_H
|
---|
| 106 |
|
---|