/usr/include/groupsock/NetAddress.hh is in liblivemedia-dev 2018.02.18-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 | /**********
This library is free software; you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License as published by the
Free Software Foundation; either version 3 of the License, or (at your
option) any later version. (See <http://www.gnu.org/copyleft/lesser.html>.)
This library is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
more details.
You should have received a copy of the GNU Lesser General Public License
along with this library; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
**********/
// "mTunnel" multicast access service
// Copyright (c) 1996-2018 Live Networks, Inc. All rights reserved.
// Network Addresses
// C++ header
#ifndef _NET_ADDRESS_HH
#define _NET_ADDRESS_HH
#ifndef _HASH_TABLE_HH
#include "HashTable.hh"
#endif
#ifndef _NET_COMMON_H
#include "NetCommon.h"
#endif
#ifndef _USAGE_ENVIRONMENT_HH
#include "UsageEnvironment.hh"
#endif
// Definition of a type representing a low-level network address.
// At present, this is 32-bits, for IPv4. Later, generalize it,
// to allow for IPv6.
typedef u_int32_t netAddressBits;
class NetAddress {
public:
NetAddress(u_int8_t const* data,
unsigned length = 4 /* default: 32 bits */);
NetAddress(unsigned length = 4); // sets address data to all-zeros
NetAddress(NetAddress const& orig);
NetAddress& operator=(NetAddress const& rightSide);
virtual ~NetAddress();
unsigned length() const { return fLength; }
u_int8_t const* data() const // always in network byte order
{ return fData; }
private:
void assign(u_int8_t const* data, unsigned length);
void clean();
unsigned fLength;
u_int8_t* fData;
};
class NetAddressList {
public:
NetAddressList(char const* hostname);
NetAddressList(NetAddressList const& orig);
NetAddressList& operator=(NetAddressList const& rightSide);
virtual ~NetAddressList();
unsigned numAddresses() const { return fNumAddresses; }
NetAddress const* firstAddress() const;
// Used to iterate through the addresses in a list:
class Iterator {
public:
Iterator(NetAddressList const& addressList);
NetAddress const* nextAddress(); // NULL iff none
private:
NetAddressList const& fAddressList;
unsigned fNextIndex;
};
private:
void assign(netAddressBits numAddresses, NetAddress** addressArray);
void clean();
friend class Iterator;
unsigned fNumAddresses;
NetAddress** fAddressArray;
};
typedef u_int16_t portNumBits;
class Port {
public:
Port(portNumBits num /* in host byte order */);
portNumBits num() const { return fPortNum; } // in network byte order
private:
portNumBits fPortNum; // stored in network byte order
#ifdef IRIX
portNumBits filler; // hack to overcome a bug in IRIX C++ compiler
#endif
};
UsageEnvironment& operator<<(UsageEnvironment& s, const Port& p);
// A generic table for looking up objects by (address1, address2, port)
class AddressPortLookupTable {
public:
AddressPortLookupTable();
virtual ~AddressPortLookupTable();
void* Add(netAddressBits address1, netAddressBits address2, Port port, void* value);
// Returns the old value if different, otherwise 0
Boolean Remove(netAddressBits address1, netAddressBits address2, Port port);
void* Lookup(netAddressBits address1, netAddressBits address2, Port port);
// Returns 0 if not found
void* RemoveNext() { return fTable->RemoveNext(); }
// Used to iterate through the entries in the table
class Iterator {
public:
Iterator(AddressPortLookupTable& table);
virtual ~Iterator();
void* next(); // NULL iff none
private:
HashTable::Iterator* fIter;
};
private:
friend class Iterator;
HashTable* fTable;
};
Boolean IsMulticastAddress(netAddressBits address);
// A mechanism for displaying an IPv4 address in ASCII. This is intended to replace "inet_ntoa()", which is not thread-safe.
class AddressString {
public:
AddressString(struct sockaddr_in const& addr);
AddressString(struct in_addr const& addr);
AddressString(netAddressBits addr); // "addr" is assumed to be in host byte order here
virtual ~AddressString();
char const* val() const { return fVal; }
private:
void init(netAddressBits addr); // used to implement each of the constructors
private:
char* fVal; // The result ASCII string: allocated by the constructor; deleted by the destructor
};
#endif
|