NetworkInterface.h++
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef __ccxx_NetworkInterface_hxx
00024 #define __ccxx_NetworkInterface_hxx
00025
00026 #include <commonc++/Common.h++>
00027 #include <commonc++/InetAddress.h++>
00028 #include <commonc++/MACAddress.h++>
00029 #include <commonc++/String.h++>
00030
00031 namespace ccxx {
00032
00037 class COMMONCPP_API NetworkInterface
00038 {
00039 friend class Network;
00040
00041 public:
00042
00044 static const uint32_t FLAG_UP;
00045
00047 static const uint32_t FLAG_BROADCAST;
00048
00050 static const uint32_t FLAG_DEBUG;
00051
00053 static const uint32_t FLAG_LOOPBACK;
00054
00056 static const uint32_t FLAG_PPP;
00057
00059 static const uint32_t FLAG_NOTRAILERS;
00060
00062 static const uint32_t FLAG_RUNNING;
00063
00067 static const uint32_t FLAG_NOARP;
00068
00070 static const uint32_t FLAG_PROMISCUOUS;
00071
00073 static const uint32_t FLAG_MULTICAST;
00074
00076 static const uint32_t FLAG_MASK;
00077
00079 ~NetworkInterface() throw();
00080
00082 inline String getName() const
00083 { return(_name); }
00084
00086 inline InetAddress getAddress() const
00087 { return(_addr); }
00088
00090 inline MACAddress getHardwareAddress() const
00091 { return(_hwAddr); }
00092
00094 inline InetAddress getBroadcastAddress() const throw()
00095 { return(_broadcastAddr); }
00096
00098 inline InetAddress getDestAddress() const throw()
00099 { return(_destAddr); }
00100
00102 inline InetAddress getNetMask() const throw()
00103 { return(_netmask); }
00104
00106 inline uint_t getPrefixLength() const throw()
00107 { return(_prefixLength); }
00108
00110 inline uint32_t getFlags() const throw()
00111 { return(_flags); }
00112
00114 inline bool isUp() const throw()
00115 { return((_flags & FLAG_UP) != 0); }
00116
00118 inline bool isBroadcastSupported() const throw()
00119 { return((_flags & FLAG_BROADCAST) != 0); }
00120
00122 inline bool isMulticastSupported() const throw()
00123 { return((_flags & FLAG_MULTICAST) != 0); }
00124
00126 inline bool isDebuggingEnabled() const throw()
00127 { return((_flags & FLAG_DEBUG) != 0); }
00128
00130 inline bool isLoopback() const throw()
00131 { return((_flags & FLAG_LOOPBACK) != 0); }
00132
00134 inline bool isPPP() const throw()
00135 { return((_flags & FLAG_PPP) != 0); }
00136
00138 inline bool isNoTrailers() const throw()
00139 { return((_flags & FLAG_NOTRAILERS) != 0); }
00140
00142 inline bool isRunning() const throw()
00143 { return((_flags & FLAG_RUNNING) != 0); }
00144
00148 inline bool isNoARP() const throw()
00149 { return((_flags & FLAG_NOARP) != 0); }
00150
00152 inline bool isPromiscuous() const throw()
00153 { return((_flags & FLAG_PROMISCUOUS) != 0); }
00154
00156 inline int getMTU() const throw()
00157 { return(_mtu); }
00158
00160 inline int getMetric() const throw()
00161 { return(_metric); }
00162
00163 private:
00164
00165 NetworkInterface() throw();
00166
00167 inline void setName(String name)
00168 { _name = name; }
00169
00170 inline void setAddress(const InetAddress &addr)
00171 { _addr = addr; }
00172
00173 inline void setHardwareAddress(const MACAddress &addr)
00174 { _hwAddr = addr; }
00175
00176 inline void setBroadcastAddress(const InetAddress &addr)
00177 { _broadcastAddr = addr; }
00178
00179 inline void setDestAddress(const InetAddress &addr)
00180 { _destAddr = addr; }
00181
00182 void setNetmask(const InetAddress &addr);
00183
00184 inline void setUp(bool flag) throw()
00185 { flag ? _flags |= FLAG_UP : _flags &= ~FLAG_UP; }
00186
00187 inline void setBroadcastSupported(bool flag) throw()
00188 { flag ? _flags |= FLAG_BROADCAST : _flags &= ~FLAG_BROADCAST; }
00189
00190 inline void setDebuggingEnabled(bool flag) throw()
00191 { flag ? _flags |= FLAG_DEBUG : _flags &= ~FLAG_DEBUG; }
00192
00193 inline void setLoopback(bool flag) throw()
00194 { flag ? _flags |= FLAG_LOOPBACK : _flags &= ~FLAG_LOOPBACK; }
00195
00196 inline void setPPP(bool flag) throw()
00197 { flag ? _flags |= FLAG_PPP : _flags &= ~FLAG_PPP; }
00198
00199 inline void setNoTrailers(bool flag) throw()
00200 { flag ? _flags |= FLAG_NOTRAILERS : _flags &= ~FLAG_NOTRAILERS; }
00201
00202 inline void setRunning(bool flag) throw()
00203 { flag ? _flags |= FLAG_RUNNING : _flags &= ~FLAG_RUNNING; }
00204
00205 inline void setNoARP(bool flag) throw()
00206 { flag ? _flags |= FLAG_NOARP : _flags &= ~FLAG_NOARP; }
00207
00208 inline void setPromiscuous(bool flag) throw()
00209 { flag ? _flags |= FLAG_PROMISCUOUS : _flags &= ~FLAG_PROMISCUOUS; }
00210
00211 inline void setMulticastSupported(bool flag) throw()
00212 { flag ? _flags |= FLAG_MULTICAST : _flags &= ~FLAG_MULTICAST; }
00213
00214 inline void setFlags(int flags) throw()
00215 { _flags = flags & FLAG_MASK; }
00216
00217 inline void setMTU(int mtu) throw()
00218 { _mtu = mtu; }
00219
00220 inline void setMetric(int metric) throw()
00221 { _metric = metric; }
00222
00223 String _name;
00224 MACAddress _hwAddr;
00225 InetAddress _addr;
00226 InetAddress _broadcastAddr;
00227 InetAddress _destAddr;
00228 InetAddress _netmask;
00229 int _mtu;
00230 int _metric;
00231 uint_t _prefixLength;
00232 uint32_t _flags;
00233 };
00234
00235 };
00236
00237 #endif // __ccxx_NetworkInterface_hxx
00238
00239