/usr/include/groupsock/NetInterface.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 | /**********
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 Interfaces
// C++ header
#ifndef _NET_INTERFACE_HH
#define _NET_INTERFACE_HH
#ifndef _NET_ADDRESS_HH
#include "NetAddress.hh"
#endif
class NetInterface {
public:
virtual ~NetInterface();
static UsageEnvironment* DefaultUsageEnvironment;
// if non-NULL, used for each new interfaces
protected:
NetInterface(); // virtual base class
};
class DirectedNetInterface: public NetInterface {
public:
virtual ~DirectedNetInterface();
virtual Boolean write(unsigned char* data, unsigned numBytes) = 0;
virtual Boolean SourceAddrOKForRelaying(UsageEnvironment& env,
unsigned addr) = 0;
protected:
DirectedNetInterface(); // virtual base class
};
class DirectedNetInterfaceSet {
public:
DirectedNetInterfaceSet();
virtual ~DirectedNetInterfaceSet();
DirectedNetInterface* Add(DirectedNetInterface const* interf);
// Returns the old value if different, otherwise 0
Boolean Remove(DirectedNetInterface const* interf);
Boolean IsEmpty() { return fTable->IsEmpty(); }
// Used to iterate through the interfaces in the set
class Iterator {
public:
Iterator(DirectedNetInterfaceSet& interfaces);
virtual ~Iterator();
DirectedNetInterface* next(); // NULL iff none
private:
HashTable::Iterator* fIter;
};
private:
friend class Iterator;
HashTable* fTable;
};
class Socket: public NetInterface {
public:
virtual ~Socket();
void reset(); // closes the socket, and sets "fSocketNum" to -1
virtual Boolean handleRead(unsigned char* buffer, unsigned bufferMaxSize,
unsigned& bytesRead,
struct sockaddr_in& fromAddress) = 0;
// Returns False on error; resultData == NULL if data ignored
int socketNum() const { return fSocketNum; }
Port port() const {
return fPort;
}
UsageEnvironment& env() const { return fEnv; }
static int DebugLevel;
protected:
Socket(UsageEnvironment& env, Port port); // virtual base class
Boolean changePort(Port newPort); // will also cause socketNum() to change
private:
int fSocketNum;
UsageEnvironment& fEnv;
Port fPort;
};
UsageEnvironment& operator<<(UsageEnvironment& s, const Socket& sock);
// A data structure for looking up a Socket by port:
class SocketLookupTable {
public:
virtual ~SocketLookupTable();
Socket* Fetch(UsageEnvironment& env, Port port, Boolean& isNew);
// Creates a new Socket if none already exists
Boolean Remove(Socket const* sock);
protected:
SocketLookupTable(); // abstract base class
virtual Socket* CreateNew(UsageEnvironment& env, Port port) = 0;
private:
HashTable* fTable;
};
// A data structure for counting traffic:
class NetInterfaceTrafficStats {
public:
NetInterfaceTrafficStats();
void countPacket(unsigned packetSize);
float totNumPackets() const {return fTotNumPackets;}
float totNumBytes() const {return fTotNumBytes;}
Boolean haveSeenTraffic() const;
private:
float fTotNumPackets;
float fTotNumBytes;
};
#endif
|