[BACK]Return to netcat.c CVS log [TXT][DIR] Up to [local] / src / usr.bin / nc

Diff for /src/usr.bin/nc/netcat.c between version 1.80 and 1.81

version 1.80, 2005/05/27 04:55:28 version 1.81, 2005/05/28 16:57:48
Line 93 
Line 93 
 int     udptest(int);  int     udptest(int);
 int     unix_connect(char *);  int     unix_connect(char *);
 int     unix_listen(char *);  int     unix_listen(char *);
   int     set_common_sockopts(int);
 void    usage(int);  void    usage(int);
   
 int  int
Line 462 
Line 463 
 remote_connect(const char *host, const char *port, struct addrinfo hints)  remote_connect(const char *host, const char *port, struct addrinfo hints)
 {  {
         struct addrinfo *res, *res0;          struct addrinfo *res, *res0;
         int s, error, x = 1;          int s, error;
   
         if ((error = getaddrinfo(host, port, &hints, &res)))          if ((error = getaddrinfo(host, port, &hints, &res)))
                 errx(1, "getaddrinfo: %s", gai_strerror(error));                  errx(1, "getaddrinfo: %s", gai_strerror(error));
Line 497 
Line 498 
                                 errx(1, "bind failed: %s", strerror(errno));                                  errx(1, "bind failed: %s", strerror(errno));
                         freeaddrinfo(ares);                          freeaddrinfo(ares);
                 }                  }
                 if (Sflag) {  
                         if (setsockopt(s, IPPROTO_TCP, TCP_MD5SIG,  
                             &x, sizeof(x)) == -1)  
                                 err(1, NULL);  
                 }  
                 if (Dflag) {  
                         if (setsockopt(s, SOL_SOCKET, SO_DEBUG,  
                             &x, sizeof(x)) == -1)  
                                 err(1, NULL);  
                 }  
                 if (jflag) {  
                         if (setsockopt(s, SOL_SOCKET, SO_JUMBO,  
                             &x, sizeof(x)) == -1)  
                                 err(1, NULL);  
                 }  
   
                   set_common_sockopts(s);
   
                 if (connect(s, res0->ai_addr, res0->ai_addrlen) == 0)                  if (connect(s, res0->ai_addr, res0->ai_addrlen) == 0)
                         break;                          break;
                 else if (vflag)                  else if (vflag)
Line 562 
Line 550 
                 ret = setsockopt(s, SOL_SOCKET, SO_REUSEPORT, &x, sizeof(x));                  ret = setsockopt(s, SOL_SOCKET, SO_REUSEPORT, &x, sizeof(x));
                 if (ret == -1)                  if (ret == -1)
                         err(1, NULL);                          err(1, NULL);
                 if (Sflag) {  
                         ret = setsockopt(s, IPPROTO_TCP, TCP_MD5SIG,  
                             &x, sizeof(x));  
                         if (ret == -1)  
                                 err(1, NULL);  
                 }  
                 if (Dflag) {  
                         if (setsockopt(s, SOL_SOCKET, SO_DEBUG,  
                             &x, sizeof(x)) == -1)  
                                 err(1, NULL);  
                 }  
   
                   set_common_sockopts(s);
   
                 if (bind(s, (struct sockaddr *)res0->ai_addr,                  if (bind(s, (struct sockaddr *)res0->ai_addr,
                     res0->ai_addrlen) == 0)                      res0->ai_addrlen) == 0)
                         break;                          break;
Line 771 
Line 750 
                         ret = -1;                          ret = -1;
         }          }
         return (ret);          return (ret);
   }
   
   int
   set_common_sockopts(int s)
   {
           int x = 1;
   
           if (Sflag) {
                   if (setsockopt(s, IPPROTO_TCP, TCP_MD5SIG,
                           &x, sizeof(x)) == -1)
                           err(1, NULL);
           }
           if (Dflag) {
                   if (setsockopt(s, SOL_SOCKET, SO_DEBUG,
                           &x, sizeof(x)) == -1)
                           err(1, NULL);
           }
           if (jflag) {
                   if (setsockopt(s, SOL_SOCKET, SO_JUMBO,
                           &x, sizeof(x)) == -1)
                           err(1, NULL);
           }
 }  }
   
 void  void

Legend:
Removed from v.1.80  
changed lines
  Added in v.1.81