Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
michael@0 | 2 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 3 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 4 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 5 | |
michael@0 | 6 | /* |
michael@0 | 7 | ** Base class definitions for network access functions (ref: prnetdb.h) |
michael@0 | 8 | */ |
michael@0 | 9 | |
michael@0 | 10 | #if defined(_RCNETDB_H) |
michael@0 | 11 | #else |
michael@0 | 12 | #define _RCNETDB_H |
michael@0 | 13 | |
michael@0 | 14 | #include "rclock.h" |
michael@0 | 15 | #include "rcbase.h" |
michael@0 | 16 | |
michael@0 | 17 | #include <prnetdb.h> |
michael@0 | 18 | |
michael@0 | 19 | class PR_IMPLEMENT(RCNetAddr): public RCBase |
michael@0 | 20 | { |
michael@0 | 21 | public: |
michael@0 | 22 | typedef enum { |
michael@0 | 23 | any = PR_IpAddrAny, /* assign logical INADDR_ANY */ |
michael@0 | 24 | loopback = PR_IpAddrLoopback /* assign logical INADDR_LOOPBACK */ |
michael@0 | 25 | } HostValue; |
michael@0 | 26 | |
michael@0 | 27 | RCNetAddr(); /* default constructor is unit'd object */ |
michael@0 | 28 | RCNetAddr(const RCNetAddr&); /* copy constructor */ |
michael@0 | 29 | RCNetAddr(HostValue, PRUint16 port);/* init'd w/ 'special' assignments */ |
michael@0 | 30 | RCNetAddr(const RCNetAddr&, PRUint16 port); |
michael@0 | 31 | /* copy w/ port reassigment */ |
michael@0 | 32 | |
michael@0 | 33 | virtual ~RCNetAddr(); |
michael@0 | 34 | |
michael@0 | 35 | void operator=(const RCNetAddr&); |
michael@0 | 36 | |
michael@0 | 37 | virtual PRBool operator==(const RCNetAddr&) const; |
michael@0 | 38 | /* compare of all relavent fields */ |
michael@0 | 39 | virtual PRBool EqualHost(const RCNetAddr&) const; |
michael@0 | 40 | /* compare of just host field */ |
michael@0 | 41 | |
michael@0 | 42 | |
michael@0 | 43 | public: |
michael@0 | 44 | |
michael@0 | 45 | void operator=(const PRNetAddr*); /* construction from more primitive data */ |
michael@0 | 46 | operator const PRNetAddr*() const; /* extraction of underlying representation */ |
michael@0 | 47 | virtual PRStatus FromString(const char* string); |
michael@0 | 48 | /* initialization from an ASCII string */ |
michael@0 | 49 | virtual PRStatus ToString(char *string, PRSize size) const; |
michael@0 | 50 | /* convert internal fromat to a string */ |
michael@0 | 51 | |
michael@0 | 52 | private: |
michael@0 | 53 | |
michael@0 | 54 | PRNetAddr address; |
michael@0 | 55 | |
michael@0 | 56 | }; /* RCNetAddr */ |
michael@0 | 57 | |
michael@0 | 58 | /* |
michael@0 | 59 | ** Class: RCHostLookup |
michael@0 | 60 | ** |
michael@0 | 61 | ** Abstractions to look up host names and addresses. |
michael@0 | 62 | ** |
michael@0 | 63 | ** This is a stateful class. One looks up the host by name or by |
michael@0 | 64 | ** address, then enumerates over a possibly empty array of network |
michael@0 | 65 | ** addresses. The storage for the addresses is owned by the class. |
michael@0 | 66 | */ |
michael@0 | 67 | |
michael@0 | 68 | class RCHostLookup: public RCBase |
michael@0 | 69 | { |
michael@0 | 70 | public: |
michael@0 | 71 | virtual ~RCHostLookup(); |
michael@0 | 72 | |
michael@0 | 73 | RCHostLookup(); |
michael@0 | 74 | |
michael@0 | 75 | virtual PRStatus ByName(const char* name); |
michael@0 | 76 | virtual PRStatus ByAddress(const RCNetAddr&); |
michael@0 | 77 | |
michael@0 | 78 | virtual const RCNetAddr* operator[](PRUintn); |
michael@0 | 79 | |
michael@0 | 80 | private: |
michael@0 | 81 | RCLock ml; |
michael@0 | 82 | PRIntn max_index; |
michael@0 | 83 | RCNetAddr* address; |
michael@0 | 84 | |
michael@0 | 85 | RCHostLookup(const RCHostLookup&); |
michael@0 | 86 | RCHostLookup& operator=(const RCHostLookup&); |
michael@0 | 87 | }; |
michael@0 | 88 | |
michael@0 | 89 | inline RCNetAddr::RCNetAddr(): RCBase() { } |
michael@0 | 90 | inline RCNetAddr::operator const PRNetAddr*() const { return &address; } |
michael@0 | 91 | |
michael@0 | 92 | |
michael@0 | 93 | #endif /* defined(_RCNETDB_H) */ |
michael@0 | 94 | |
michael@0 | 95 | /* RCNetdb.h */ |
michael@0 | 96 | |
michael@0 | 97 |