#include <net.h>
Inheritance diagram for Network:


Public Member Functions | |
| Network () | |
| virtual int | command (int argc, const char *const *argv) |
| virtual int | send (u_char *buf, int len)=0 |
| virtual int | recv (u_char *buf, int len, sockaddr &from, double &ts)=0 |
| virtual int | recv (netpkt_handler callback, void *clientdata) |
| virtual int | rchannel ()=0 |
| virtual int | schannel ()=0 |
| int | mode () |
Static Public Member Functions | |
| int | nonblock (int fd) |
| int | parsemode (const char *) |
| char * | modename (int) |
Protected Attributes | |
| int | mode_ |
|
|
Definition at line 58 of file net.h. References mode_.
00058 : mode_(-1) { } |
|
||||||||||||
|
Reimplemented in IPNetwork, UDPIPNetwork, PcapNetwork, PcapLiveNetwork, and PcapFileNetwork. Definition at line 88 of file net.cc. References mode_, modename(), recv(), and ts. Referenced by PcapNetwork::command(), and IPNetwork::command().
00089 {
00090 if (argc == 2) {
00091 Tcl& tcl = Tcl::instance();
00092 if (strcmp(argv[1], "flush") == 0) {
00093 if (mode_ == O_RDWR || mode_ == O_RDONLY) {
00094 unsigned char buf[1024];
00095 sockaddr from;
00096 double ts;
00097 while (recv(buf, sizeof(buf), from, ts) > 0)
00098 ;
00099 }
00100 return (TCL_OK);
00101 }
00102 if (strcmp(argv[1], "mode") == 0) {
00103 tcl.result(modename(mode_));
00104 return (TCL_OK);
00105 }
00106 }
00107 return (TclObject::command(argc, argv));
00108 }
|
Here is the call graph for this function:

|
|
Definition at line 71 of file net.h. References mode_. Referenced by PcapFileNetwork::command(), PcapLiveNetwork::command(), IPNetwork::command(), TapAgent::linknet(), TCPTapAgent::recvpkt(), TapAgent::recvpkt(), IPTapAgent::recvpkt(), TCPTapAgent::sendpkt(), TapAgent::sendpkt(), and IPTapAgent::sendpkt().
00071 { return mode_; }
|
|
|
Definition at line 154 of file net.cc. Referenced by command().
00155 {
00156 switch (mode) {
00157 case O_RDONLY:
00158 return ("readonly");
00159 case O_WRONLY:
00160 return ("writeonly");
00161 case O_RDWR:
00162 return ("readwrite");
00163 }
00164 return ("unknown");
00165 }
|
|
|
Definition at line 111 of file net.cc. Referenced by UDPIPNetwork::open().
00112 {
00113 #ifdef WIN32
00114 u_long flag = 1;
00115 if (ioctlsocket(fd, FIONBIO, &flag) == -1) {
00116 fprintf(stderr,
00117 "Network::nonblock(): ioctlsocket: FIONBIO: %lu\n",
00118 GetLastError());
00119 return -1;
00120 }
00121 #else
00122 int flags;
00123 if ((flags = fcntl(fd, F_GETFL, 0)) < 0) {
00124 perror("Network::nonblock(): fcntl");
00125 return (-1);
00126 }
00127 #if defined(hpux) || defined(__hpux)
00128 flags |= O_NONBLOCK;
00129 #else
00130 flags |= O_NONBLOCK|O_NDELAY;
00131 #endif
00132 if (fcntl(fd, F_SETFL, flags) == -1) {
00133 perror("Network::nonblock(): fcntl: F_SETFL");
00134 return -1;
00135 }
00136 #endif
00137 return 0;
00138 }
|
|
|
Definition at line 141 of file net.cc. Referenced by PcapFileNetwork::command(), PcapLiveNetwork::command(), and IPNetwork::command().
00142 {
00143 if (strcmp(mname, "readonly") == 0) {
00144 return (O_RDONLY);
00145 } else if (strcmp(mname, "readwrite") == 0) {
00146 return (O_RDWR);
00147 } else if (strcmp(mname, "writeonly") == 0) {
00148 return (O_WRONLY);
00149 }
00150 return (::atoi(mname));
00151 }
|
|
|
Implemented in IPNetwork, and PcapNetwork. Referenced by ArpAgent::command(), and TapAgent::linknet(). |
|
||||||||||||
|
Reimplemented in PcapNetwork. Definition at line 62 of file net.h.
00062 {
00063 Tcl::instance().evalf("%s info class", name());
00064 fprintf( stderr, "Callback Interface to receiving packets"
00065 " unsupported in class %s\n",
00066 Tcl::instance().result() );
00067 return 0;
00068 } // callback called for every packet
|
|
||||||||||||||||||||
|
Implemented in IPNetwork, UDPIPNetwork, and PcapNetwork. Referenced by command(), ArpAgent::dispatch(), TCPTapAgent::recvpkt(), TapAgent::recvpkt(), and IPTapAgent::recvpkt(). |
|
|
Implemented in IPNetwork, and PcapNetwork. Referenced by TapAgent::linknet(). |
|
||||||||||||
|
Implemented in IPNetwork, UDPIPNetwork, and PcapNetwork. Referenced by TCPTapAgent::sendpkt(), TapAgent::sendpkt(), IPTapAgent::sendpkt(), ArpAgent::sendreq(), and ArpAgent::sendresp(). |
|
|
Definition at line 76 of file net.h. Referenced by UDPIPNetwork::bind(), command(), UDPIPNetwork::connect(), mode(), Network(), PcapFileNetwork::open(), PcapLiveNetwork::open(), IPNetwork::open(), UDPIPNetwork::open(), IPNetwork::recv(), and IPNetwork::reset(). |
1.3.3