

Public Member Functions | |
| UDPIPNetwork () | |
| int | send (u_char *, int) |
| int | recv (u_char *, int, sockaddr &, double &) |
| int | open (int mode) |
| int | command (int argc, const char *const *argv) |
| void | reconfigure () |
| void | add_membership (Socket, in_addr &, u_int16_t) |
| int | ttl () const |
| int | noloopback_broken () |
| int | setmttl (Socket, int) |
| int | setmloop (Socket, int) |
| Socket | rchannel () |
| Socket | schannel () |
| virtual int | recv (netpkt_handler callback, void *clientdata) |
| in_addr & | laddr () |
| in_addr & | dstaddr () |
| int | add_membership (Socket, in_addr &grp) |
| int | drop_membership (Socket, in_addr &grp) |
| int | mode () |
Static Public Member Functions | |
| int | bindsock (Socket, in_addr &, u_int16_t, sockaddr_in &) |
| int | connectsock (Socket, in_addr &, u_int16_t, sockaddr_in &) |
| int | rbufsize (Socket, int) |
| int | sbufsize (Socket, int) |
| int | nonblock (int fd) |
| int | parsemode (const char *) |
| char * | modename (int) |
Protected Member Functions | |
| int | bind (in_addr &, u_int16_t port) |
| int | connect (in_addr &remoteaddr, u_int16_t port) |
| void | reset (int reconfigure) |
| int | close () |
Protected Attributes | |
| u_int16_t | lport_ |
| u_int16_t | port_ |
| in_addr | destaddr_ |
| in_addr | localaddr_ |
| int | mttl_ |
| Socket | rsock_ |
| Socket | ssock_ |
| int | noloopback_broken_ |
| int | loop_ |
| time_t | last_reset_ |
| int | mode_ |
|
|
Definition at line 190 of file net-ip.cc. References NIDEBUG.
|
|
||||||||||||
|
Definition at line 769 of file net-ip.cc. References NIDEBUG3. Referenced by add_membership(), and IPNetwork::command().
00770 {
00771
00772 #if defined(IP_ADD_MEMBERSHIP)
00773 if (IN_CLASSD(ntohl(addr.s_addr))) {
00774 #ifdef notdef
00775 /*
00776 * Try to bind the multicast address as the socket
00777 * dest address. On many systems this won't work
00778 * so fall back to a destination of INADDR_ANY if
00779 * the first bind fails.
00780 */
00781 sockaddr_in sin;
00782 memset(&sin, 0, sizeof(sin));
00783 sin.sin_family = AF_INET;
00784 sin.sin_addr = addr;
00785 if (::bind(fd, (struct sockaddr *) &sin, sizeof(sin)) < 0) {
00786 sin.sin_addr.s_addr = INADDR_ANY;
00787 if (::bind(fd, (struct sockaddr *) &sin, sizeof(sin)) < 0) {
00788 fprintf(stderr,
00789 "IPNetwork(%s): add_membership: unable to bind to addr %s: %s\n",
00790 name(), inet_ntoa(sin.sin_addr),
00791 strerror(errno));
00792 return (-1);
00793 }
00794 }
00795 #endif
00796 /*
00797 * XXX This is bogus multicast setup that really
00798 * shouldn't have to be done (group membership should be
00799 * implicit in the IP class D address, route should contain
00800 * ttl & no loopback flag, etc.). Steve Deering has promised
00801 * to fix this for the 4.4bsd release. We're all waiting
00802 * with bated breath.
00803 */
00804 struct ip_mreq mr;
00805
00806 mr.imr_multiaddr = addr;
00807 mr.imr_interface.s_addr = INADDR_ANY;
00808 if (::setsockopt(fd, IPPROTO_IP, IP_ADD_MEMBERSHIP,
00809 (char *)&mr, sizeof(mr)) < 0) {
00810 fprintf(stderr, "IPNetwork(%s): add_membership: unable to add membership for addr %s: %s\n",
00811 name(), inet_ntoa(addr), strerror(errno));
00812 return (-1);
00813 }
00814 NIDEBUG3("IPNetwork(%s): add_membership for grp %s done\n",
00815 name(), inet_ntoa(addr));
00816 return (0);
00817 }
00818 #else
00819 fprintf(stderr, "IPNetwork(%s): add_membership: host does not support IP multicast\n",
00820 name());
00821 #endif
00822 NIDEBUG3("IPNetwork(%s): add_membership for grp %s failed\n",
00823 name(), inet_ntoa(addr));
00824 return (-1);
00825 }
|
|
||||||||||||||||
|
Definition at line 384 of file net-ip.cc. References IPNetwork::add_membership(), and IPNetwork::bindsock(). Referenced by bind().
00385 {
00386 int failure = 0;
00387 sockaddr_in sin;
00388 if (bindsock(sock, addr, port, sin) < 0)
00389 failure = 1;
00390 if (failure) {
00391 in_addr addr2 = addr;
00392 addr2.s_addr = INADDR_ANY;
00393 if (bindsock(sock, addr2, port, sin) < 0)
00394 failure = 1;
00395 else
00396 failure = 0;
00397 }
00398
00399 if (IPNetwork::add_membership(sock, addr) < 0)
00400 failure = 1;
00401
00402 if (failure) {
00403 fprintf(stderr,
00404 "UDPIPNetwork(%s): add_membership: failed bind on mcast addr %s and INADDR_ANY\n",
00405 name(), inet_ntoa(addr));
00406 }
00407 }
|
Here is the call graph for this function:

|
||||||||||||
|
Definition at line 413 of file net-ip.cc. References add_membership(), IPNetwork::bindsock(), IPNetwork::connectsock(), IPNetwork::localaddr_, lport_, Network::mode_, NIDEBUG4, and IPNetwork::rsock_. Referenced by command().
00414 {
00415 NIDEBUG4("UDPIPNetwork(%s): attempt to bind to addr %s, port %d [net order]\n",
00416 name(), inet_ntoa(addr), ntohs(port));
00417 if (rsock_ < 0) {
00418 fprintf(stderr,
00419 "UDPIPNetwork(%s): bind/listen called before net is open\n",
00420 name());
00421 return (-1);
00422 }
00423 if (mode_ == O_WRONLY) {
00424 fprintf(stderr,
00425 "UDPIPNetwork(%s): attempted bind/listen but net is write-only\n",
00426 name());
00427 return (-1);
00428 }
00429 #ifdef IP_ADD_MEMBERSHIP
00430 if (IN_CLASSD(ntohl(addr.s_addr))) {
00431 // MULTICAST case, call UDPIP vers of add_membership
00432 add_membership(rsock_, addr, port);
00433 } else
00434 #endif
00435 {
00436 // UNICAST case
00437 sockaddr_in sin;
00438 if (bindsock(rsock_, addr, port, sin) < 0) {
00439 port = ntohs(port);
00440 fprintf(stderr,
00441 "UDPIPNetwork(%s): bind: unable to bind %s [port:%hu]: %s\n",
00442 name(), inet_ntoa(addr),
00443 port, strerror(errno));
00444 return (-1);
00445 }
00446 /*
00447 * MS Windows currently doesn't compy with the Internet Host
00448 * Requirements standard (RFC-1122) and won't let us include
00449 * the source address in the receive socket demux state.
00450 */
00451 #ifndef WIN32
00452 /*
00453 * (try to) connect the foreign host's address to this socket.
00454 */
00455 (void)connectsock(rsock_, addr, 0, sin);
00456 #endif
00457 }
00458 localaddr_ = addr;
00459 lport_ = port;
00460 return (0);
00461 }
|
Here is the call graph for this function:

|
||||||||||||||||||||
|
Definition at line 861 of file net-ip.cc. Referenced by add_membership(), and bind().
00862 {
00863 memset((char *)&sin, 0, sizeof(sin));
00864 sin.sin_family = AF_INET;
00865 sin.sin_port = port;
00866 sin.sin_addr = addr;
00867 return(::bind(s, (struct sockaddr *)&sin, sizeof(sin)));
00868 }
|
|
|
Definition at line 751 of file net-ip.cc. References IPNetwork::rsock_, and IPNetwork::ssock_. Referenced by IPNetwork::command().
|
|
||||||||||||
|
Reimplemented from IPNetwork. Definition at line 493 of file net-ip.cc. References bind(), IPNetwork::command(), connect(), LookupHostAddr(), lport_, port_, and u_int16_t.
00494 {
00495 Tcl& tcl = Tcl::instance();
00496 if (argc == 2) {
00497 // $udpip port
00498 if (strcmp(argv[1], "port") == 0) {
00499 tcl.resultf("%d", ntohs(port_));
00500 return (TCL_OK);
00501 }
00502 // $udpip lport
00503 if (strcmp(argv[1], "lport") == 0) {
00504 tcl.resultf("%d", ntohs(lport_));
00505 return (TCL_OK);
00506 }
00507 } else if (argc == 4) {
00508 // $udpip listen addr port
00509 // $udpip bind addr port
00510 if (strcmp(argv[1], "listen") == 0 ||
00511 strcmp(argv[1], "bind") == 0) {
00512 in_addr addr;
00513 if (strcmp(argv[2], "any") == 0)
00514 addr.s_addr = INADDR_ANY;
00515 else
00516 addr.s_addr = LookupHostAddr(argv[2]);
00517 u_int16_t port = htons(atoi(argv[3]));
00518 if (bind(addr, port) < 0) {
00519 tcl.resultf("%s %hu",
00520 inet_ntoa(addr), port);
00521 } else {
00522 tcl.result("0");
00523 }
00524 return (TCL_OK);
00525 }
00526 // $udpip connect addr port
00527 if (strcmp(argv[1], "connect") == 0) {
00528 in_addr addr;
00529 addr.s_addr = LookupHostAddr(argv[2]);
00530 u_int16_t port = htons(atoi(argv[3]));
00531 if (connect(addr, port) < 0) {
00532 tcl.resultf("%s %hu",
00533 inet_ntoa(addr), port);
00534 } else {
00535 tcl.result("0");
00536 }
00537 return (TCL_OK);
00538 }
00539 }
00540 return (IPNetwork::command(argc, argv));
00541 }
|
Here is the call graph for this function:

|
||||||||||||
|
Definition at line 467 of file net-ip.cc. References IPNetwork::connectsock(), IPNetwork::destaddr_, IPNetwork::last_reset_, Network::mode_, port_, and IPNetwork::ssock_. Referenced by command().
00468 {
00469 sockaddr_in sin;
00470 if (ssock_ < 0) {
00471 fprintf(stderr,
00472 "UDPIPNetwork(%s): connect called before net is open\n",
00473 name());
00474 return (-1);
00475 }
00476 if (mode_ == O_RDONLY) {
00477 fprintf(stderr,
00478 "UDPIPNetwork(%s): attempted connect but net is read-only\n",
00479 name());
00480 return (-1);
00481 }
00482
00483 int rval = connectsock(ssock_, addr, port, sin);
00484 if (rval < 0)
00485 return (rval);
00486 destaddr_ = addr;
00487 port_ = port;
00488 last_reset_ = 0;
00489 return(rval);
00490 }
|
Here is the call graph for this function:

|
||||||||||||||||||||
|
Definition at line 871 of file net-ip.cc. Referenced by bind(), connect(), and IPNetwork::open().
00872 {
00873 memset((char *)&sin, 0, sizeof(sin));
00874 sin.sin_family = AF_INET;
00875 sin.sin_port = port;
00876 sin.sin_addr = addr;
00877 return(::connect(s, (struct sockaddr *)&sin, sizeof(sin)));
00878 }
|
|
||||||||||||
|
Definition at line 832 of file net-ip.cc. References NIDEBUG3. Referenced by IPNetwork::command().
00833 {
00834
00835 #if defined(IP_DROP_MEMBERSHIP)
00836 if (IN_CLASSD(ntohl(addr.s_addr))) {
00837 struct ip_mreq mr;
00838
00839 mr.imr_multiaddr = addr;
00840 mr.imr_interface.s_addr = INADDR_ANY;
00841 if (::setsockopt(fd, IPPROTO_IP, IP_DROP_MEMBERSHIP,
00842 (char *)&mr, sizeof(mr)) < 0) {
00843 fprintf(stderr, "IPNetwork(%s): drop_membership: unable to drop membership for addr %s: %s\n",
00844 name(), inet_ntoa(addr), strerror(errno));
00845 return (-1);
00846 }
00847 NIDEBUG3("IPNetwork(%s): drop_membership for grp %s done\n",
00848 name(), inet_ntoa(addr));
00849 return (0);
00850 }
00851 #else
00852 fprintf(stderr, "IPNetwork(%s): drop_membership: host does not support IP multicast\n",
00853 name());
00854 #endif
00855 NIDEBUG3("IPNetwork(%s): drop_membership for grp %s failed\n",
00856 name(), inet_ntoa(addr));
00857 return (-1);
00858 }
|
|
|
Definition at line 114 of file net-ip.cc. References IPNetwork::destaddr_.
00114 { return (destaddr_); }
|
|
|
Definition at line 113 of file net-ip.cc. References IPNetwork::localaddr_.
00113 { return (localaddr_); }
|
|
|
Definition at line 71 of file net.h. References Network::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 Network::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 101 of file net-ip.cc. References IPNetwork::noloopback_broken_.
00101 { // no loopback filter?
00102 return (noloopback_broken_);
00103 }
|
|
|
Definition at line 111 of file net.cc. Referenced by 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 }
|
|
|
Reimplemented from IPNetwork. Definition at line 316 of file net-ip.cc. References Network::mode_, NIDEBUG5, Network::nonblock(), IPNetwork::rbufsize(), IPNetwork::rsock_, IPNetwork::sbufsize(), and IPNetwork::ssock_.
00317 {
00318 if (mode == O_RDONLY || mode == O_RDWR) {
00319 rsock_ = socket(AF_INET, SOCK_DGRAM, 0);
00320 if (rsock_ < 0) {
00321 fprintf(stderr,
00322 "UDPIPNetwork(%s): open: couldn't open rcv sock\n",
00323 name());
00324 }
00325 nonblock(rsock_);
00326 int on = 1;
00327 if (::setsockopt(rsock_, SOL_SOCKET, SO_REUSEADDR, (char *)&on,
00328 sizeof(on)) < 0) {
00329 fprintf(stderr,
00330 "UDPIPNetwork(%s): open: warning: unable set REUSEADDR: %s\n",
00331 name(), strerror(errno));
00332 }
00333 #ifdef SO_REUSEPORT
00334 on = 1;
00335 if (::setsockopt(rsock_, SOL_SOCKET, SO_REUSEPORT, (char *)&on,
00336 sizeof(on)) < 0) {
00337 fprintf(stderr,
00338 "UDPIPNetwork(%s): open: warning: unable set REUSEPORT: %s\n",
00339 name(), strerror(errno));
00340 }
00341 #endif
00342 /*
00343 * XXX don't need this for the session socket.
00344 */
00345 if (rbufsize(rsock_, 80*1024) < 0) {
00346 if (rbufsize(rsock_, 32*1024) < 0) {
00347 fprintf(stderr,
00348 "UDPIPNetwork(%s): open: unable to set r bufsize to %d: %s\n",
00349 name(), 32*1024, strerror(errno));
00350 }
00351 }
00352 }
00353 if (mode == O_WRONLY || mode == O_RDWR) {
00354 ssock_ = socket(AF_INET, SOCK_DGRAM, 0);
00355 if (ssock_ < 0) {
00356 fprintf(stderr,
00357 "UDPIPNetwork(%s): open: couldn't open snd sock\n",
00358 name());
00359 }
00360 nonblock(ssock_);
00361 int firsttry = 80 * 1024;
00362 int secondtry = 48 * 1024;
00363
00364 if (sbufsize(ssock_, firsttry) < 0) {
00365 if (sbufsize(ssock_, secondtry) < 0) {
00366 fprintf(stderr,
00367 "UDPIPNetwork(%s): open: cannot set send sockbuf size to %d bytes, using default\n",
00368 name(), secondtry);
00369 }
00370 }
00371
00372 }
00373 mode_ = mode;
00374 NIDEBUG5("UDPIPNetwork(%s): opened network w/mode %d, ssock:%d, rsock:%d\n",
00375 name(), mode_, rsock_, ssock_);
00376 return (0);
00377 }
|
Here is the call graph for this function:

|
|
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 }
|
|
||||||||||||
|
Definition at line 886 of file net-ip.cc. Referenced by open().
00887 {
00888 return(::setsockopt(s, SOL_SOCKET, SO_RCVBUF, (char *)&cnt, sizeof(cnt)));
00889 }
|
|
|
Implements Network. Definition at line 107 of file net-ip.cc. References IPNetwork::rsock_, and Socket. Referenced by IPNetwork::command().
00107 { return(rsock_); } // virtual in Network
|
|
|
Reimplemented from IPNetwork. Definition at line 955 of file net-ip.cc.
00956 {
00957 }
|
|
||||||||||||
|
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
|
|
||||||||||||||||||||
|
Reimplemented from IPNetwork. Definition at line 279 of file net-ip.cc. References Scheduler::clock(), Scheduler::instance(), len, IPNetwork::localaddr_, IPNetwork::loop_, lport_, NIDEBUG2, NIDEBUG5, IPNetwork::noloopback_broken_, IPNetwork::rsock_, socklen_t, and ts.
00280 {
00281 sockaddr_in sfrom;
00282 int fromlen = sizeof(sfrom);
00283 int cc = ::recvfrom(rsock_, (char*)buf, len, 0,
00284 (sockaddr*)&sfrom, (socklen_t*)&fromlen);
00285 NIDEBUG5("UDPIPNetwork(%s): ::recvfrom(%d, buf, %d) returned %d\n",
00286 name(), rsock_, len, cc);
00287 if (cc < 0) {
00288 if (errno != EWOULDBLOCK) {
00289 fprintf(stderr,
00290 "UDPIPNetwork(%s): recvfrom failed: %s\n",
00291 name(), strerror(errno));
00292 }
00293 return (-1);
00294 }
00295 from = *((sockaddr*)&sfrom);
00296
00297 /*
00298 * if we received multicast data and we don't want the look,
00299 * there is a chance it is
00300 * what we sent if "noloopback_broken_" is set.
00301 * If so, filter out the stuff we don't want right here.
00302 */
00303
00304 if (!loop_ && noloopback_broken_ &&
00305 sfrom.sin_addr.s_addr == localaddr_.s_addr &&
00306 sfrom.sin_port == lport_) {
00307 NIDEBUG2("UDPIPNetwork(%s): filtered out our own pkt\n", name());
00308 return (0); // empty
00309 }
00310
00311 ts = Scheduler::instance().clock();
00312 return (cc); // number of bytes received
00313 }
|
Here is the call graph for this function:

|
|
Definition at line 921 of file net-ip.cc. References IPNetwork::last_reset_, Network::mode_, NIDEBUG2, IPNetwork::open(), IPNetwork::reconfigure(), IPNetwork::rsock_, and IPNetwork::ssock_. Referenced by send().
00922 {
00923 time_t t = time(0);
00924 int d = int(t - last_reset_);
00925 NIDEBUG2("IPNetwork(%s): reset\n", name());
00926 if (d > 3) { // Steve: why?
00927 last_reset_ = t;
00928 if (ssock_ >= 0)
00929 (void)::close(ssock_);
00930 if (rsock_ >= 0)
00931 (void)::close(rsock_);
00932 if (open(mode_) < 0) {
00933 fprintf(stderr,
00934 "IPNetwork(%s): couldn't reset\n",
00935 name());
00936 mode_ = -1;
00937 return;
00938 }
00939 if (restart)
00940 (void) reconfigure();
00941 }
00942 }
|
Here is the call graph for this function:

|
||||||||||||
|
Definition at line 880 of file net-ip.cc. Referenced by open().
00881 {
00882 return(::setsockopt(s, SOL_SOCKET, SO_SNDBUF, (char *)&cnt, sizeof(cnt)));
00883 }
|
|
|
Implements Network. Definition at line 108 of file net-ip.cc. References Socket, and IPNetwork::ssock_. Referenced by IPNetwork::command(), and send().
00108 { return(ssock_); } // virtual in Network
|
|
||||||||||||
|
Reimplemented from IPNetwork. Definition at line 204 of file net-ip.cc. References len, NIDEBUG5, IPNetwork::reset(), and IPNetwork::schannel().
00205 {
00206 int cc = ::send(schannel(), (char*)buf, len, 0);
00207 NIDEBUG5("UDPIPNetwork(%s): ::send(%d, buf, %d) returned %d\n",
00208 name(), schannel(), len, cc);
00209
00210 if (cc < 0) {
00211 switch (errno) {
00212 case ECONNREFUSED:
00213 /* no one listening at some site - ignore */
00214 #if defined(__osf__) || defined(_AIX) || defined(__FreeBSD__)
00215 /*
00216 * Here's an old comment...
00217 *
00218 * Due to a bug in kern/uipc_socket.c, on several
00219 * systems, datagram sockets incorrectly persist
00220 * in an error state on receipt of an ICMP
00221 * port-unreachable. This causes unicast connection
00222 * rendezvous problems, and worse, multicast
00223 * transmission problems because several systems
00224 * incorrectly send port unreachables for
00225 * multicast destinations. Our work around
00226 * is to simply close and reopen the socket
00227 * (by calling reset() below).
00228 *
00229 * This bug originated at CSRG in Berkeley
00230 * and was present in the BSD Reno networking
00231 * code release. It has since been fixed
00232 * in 4.4BSD and OSF-3.x. It is known to remain
00233 * in AIX-4.1.3.
00234 *
00235 * A fix is to change the following lines from
00236 * kern/uipc_socket.c:
00237 *
00238 * if (so_serror)
00239 * snderr(so->so_error);
00240 *
00241 * to:
00242 *
00243 * if (so->so_error) {
00244 * error = so->so_error;
00245 * so->so_error = 0;
00246 * splx(s);
00247 * goto release;
00248 * }
00249 *
00250 */
00251 reset(1);
00252 #endif
00253 break;
00254
00255 case ENETUNREACH:
00256 case EHOSTUNREACH:
00257 /*
00258 * These "errors" are totally meaningless.
00259 * There is some broken host sending
00260 * icmp unreachables for multicast destinations.
00261 * UDP probably aborted the send because of them --
00262 * try exactly once more. E.g., the send we
00263 * just did cleared the errno for the previous
00264 * icmp unreachable, so we should be able to
00265 * send now.
00266 */
00267 cc = ::send(schannel(), (char*)buf, len, 0);
00268 break;
00269
00270 default:
00271 fprintf(stderr, "UDPIPNetwork(%s): send failed: %s\n",
00272 name(), strerror(errno));
00273 return (-1);
00274 }
00275 }
00276 return cc; // bytes sent
00277 }
|
Here is the call graph for this function:

|
||||||||||||
|
Definition at line 892 of file net-ip.cc. References IPNetwork::loop_, and IPNetwork::noloopback_broken_. Referenced by IPNetwork::command().
00893 {
00894
00895 #ifdef IP_MULTICAST_LOOP
00896 u_char c = loop;
00897
00898 if (::setsockopt(s, IPPROTO_IP, IP_MULTICAST_LOOP, &c, sizeof(c)) < 0) {
00899 /*
00900 * If we cannot turn off loopback (Like on the
00901 * Microsoft TCP/IP stack), then declare this
00902 * option broken so that our packets can be
00903 * filtered on the recv path.
00904 */
00905 if (c != loop) {
00906 noloopback_broken_ = 1;
00907 loop_ = c;
00908 }
00909 return (-1);
00910 }
00911 noloopback_broken_ = 0;
00912 #else
00913 fprintf(stderr, "IPNetwork(%s): msetloop: host does not support IP multicast\n",
00914 name());
00915 #endif
00916 loop_ = c;
00917 return (0);
00918 }
|
|
||||||||||||
|
Definition at line 675 of file net-ip.cc.
00676 {
00677 /* set the multicast TTL */
00678
00679 #ifdef WIN32
00680 u_int t = ttl;
00681 #else
00682 u_char t = ttl;
00683 #endif
00684
00685 t = (ttl > 255) ? 255 : (ttl < 0) ? 0 : ttl;
00686 if (::setsockopt(s, IPPROTO_IP, IP_MULTICAST_TTL,
00687 (char*)&t, sizeof(t)) < 0) {
00688 fprintf(stderr,
00689 "IPNetwork(%s): couldn't set multicast ttl to %d\n",
00690 name(), t);
00691 return (-1);
00692 }
00693 return (0);
00694 }
|
|
|
Definition at line 100 of file net-ip.cc. References IPNetwork::mttl_.
00100 { return (mttl_); } // current mcast ttl
|
|
|
Definition at line 127 of file net-ip.cc. Referenced by IPNetwork::command(), connect(), IPNetwork::dstaddr(), and IPNetwork::IPNetwork(). |
|
|
Definition at line 141 of file net-ip.cc. Referenced by connect(), and IPNetwork::reset(). |
|
|
Definition at line 128 of file net-ip.cc. Referenced by bind(), IPNetwork::command(), IPNetwork::IPNetwork(), IPNetwork::laddr(), and recv(). |
|
|
Definition at line 133 of file net-ip.cc. Referenced by recv(), and IPNetwork::setmloop(). |
|
|
|
|
|
Definition at line 76 of file net.h. Referenced by bind(), Network::command(), connect(), Network::mode(), Network::Network(), PcapFileNetwork::open(), PcapLiveNetwork::open(), IPNetwork::open(), open(), IPNetwork::recv(), and IPNetwork::reset(). |
|
|
Definition at line 129 of file net-ip.cc. Referenced by IPNetwork::command(), and IPNetwork::ttl(). |
|
|
Definition at line 132 of file net-ip.cc. Referenced by IPNetwork::noloopback_broken(), recv(), and IPNetwork::setmloop(). |
|
|
|
|
|
Definition at line 130 of file net-ip.cc. Referenced by bind(), IPNetwork::close(), IPNetwork::open(), open(), IPNetwork::rchannel(), IPNetwork::recv(), recv(), and IPNetwork::reset(). |
|
|
Definition at line 131 of file net-ip.cc. Referenced by IPNetwork::close(), connect(), IPNetwork::open(), open(), IPNetwork::reset(), IPNetwork::schannel(), and IPNetwork::send(). |
1.3.3