[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.64 and 1.65

version 1.64, 2003/10/19 22:50:35 version 1.65, 2004/01/22 13:28:46
Line 37 
Line 37 
 #include <sys/un.h>  #include <sys/un.h>
   
 #include <netinet/in.h>  #include <netinet/in.h>
   #include <netinet/tcp.h>
 #include <arpa/telnet.h>  #include <arpa/telnet.h>
   
 #include <err.h>  #include <err.h>
Line 71 
Line 72 
 int     vflag;                                  /* Verbosity */  int     vflag;                                  /* Verbosity */
 int     xflag;                                  /* Socks proxy */  int     xflag;                                  /* Socks proxy */
 int     zflag;                                  /* Port Scan Flag */  int     zflag;                                  /* Port Scan Flag */
   int     Sflag;                                  /* TCP MD5 signature option */
   
 int timeout = -1;  int timeout = -1;
 int family = AF_UNSPEC;  int family = AF_UNSPEC;
Line 111 
Line 113 
         endp = NULL;          endp = NULL;
         sv = NULL;          sv = NULL;
   
         while ((ch = getopt(argc, argv, "46UX:hi:klnp:rs:tuvw:x:z")) != -1) {          while ((ch = getopt(argc, argv, "46UX:hi:klnp:rs:tuvw:x:zS")) != -1) {
                 switch (ch) {                  switch (ch) {
                 case '4':                  case '4':
                         family = AF_INET;                          family = AF_INET;
Line 178 
Line 180 
                 case 'z':                  case 'z':
                         zflag = 1;                          zflag = 1;
                         break;                          break;
                   case 'S':
                           Sflag = 1;
                           break;
                 default:                  default:
                         usage(1);                          usage(1);
                 }                  }
Line 437 
Line 442 
 remote_connect(char *host, char *port, struct addrinfo hints)  remote_connect(char *host, char *port, struct addrinfo hints)
 {  {
         struct addrinfo *res, *res0;          struct addrinfo *res, *res0;
         int s, error;          int s, error, x = 1;
   
         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 472 
Line 477 
                                 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_SIGNATURE_ENABLE,
                               &x, sizeof(x)) == -1)
                                   err(1, NULL);
                   }
   
                 if (connect(s, res0->ai_addr, res0->ai_addrlen) == 0)                  if (connect(s, res0->ai_addr, res0->ai_addrlen) == 0)
                         break;                          break;
Line 519 
Line 529 
                 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_SIGNATURE_ENABLE,
                               &x, sizeof(x));
                           if (ret == -1)
                                   err(1, NULL);
                   }
   
                 if (bind(s, (struct sockaddr *)res0->ai_addr,                  if (bind(s, (struct sockaddr *)res0->ai_addr,
                     res0->ai_addrlen) == 0)                      res0->ai_addrlen) == 0)
Line 730 
Line 746 
         fprintf(stderr, "\tCommand Summary:\n\          fprintf(stderr, "\tCommand Summary:\n\
         \t-4            Use IPv4\n\          \t-4            Use IPv4\n\
         \t-6            Use IPv6\n\          \t-6            Use IPv6\n\
           \t-S            Enable the TCP MD5 signature option\n\
         \t-U            Use UNIX domain socket\n\          \t-U            Use UNIX domain socket\n\
         \t-X vers\t     SOCKS version (4 or 5)\n\          \t-X vers\t     SOCKS version (4 or 5)\n\
         \t-h            This help text\n\          \t-h            This help text\n\
Line 753 
Line 770 
 void  void
 usage(int ret)  usage(int ret)
 {  {
         fprintf(stderr, "usage: nc [-46Uhklnrtuvz] [-i interval] [-p source port]\n");          fprintf(stderr, "usage: nc [-46SUhklnrtuvz] [-i interval] [-p source port]\n");
         fprintf(stderr, "\t  [-s ip address] [-w timeout] [-X vers] [-x proxy address [:port]]\n");          fprintf(stderr, "\t  [-s ip address] [-w timeout] [-X vers] [-x proxy address [:port]]\n");
         fprintf(stderr, "\t  [hostname] [port[s...]]\n");          fprintf(stderr, "\t  [hostname] [port[s...]]\n");
         if (ret)          if (ret)

Legend:
Removed from v.1.64  
changed lines
  Added in v.1.65