=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/nc/netcat.c,v retrieving revision 1.36 retrieving revision 1.37 diff -c -r1.36 -r1.37 *** src/usr.bin/nc/netcat.c 2001/09/02 19:07:17 1.36 --- src/usr.bin/nc/netcat.c 2001/09/02 19:11:46 1.37 *************** *** 1,4 **** ! /* $OpenBSD: netcat.c,v 1.36 2001/09/02 19:07:17 jakob Exp $ */ /* * Copyright (c) 2001 Eric Jackson * --- 1,4 ---- ! /* $OpenBSD: netcat.c,v 1.37 2001/09/02 19:11:46 jakob Exp $ */ /* * Copyright (c) 2001 Eric Jackson * *************** *** 79,87 **** void usage __P((int)); int ! main(argc, argv) ! int argc; ! char *argv[]; { int ch, s, ret; char *host, *uport, *endp; --- 79,85 ---- void usage __P((int)); int ! main(int argc, char *argv[]) { int ch, s, ret; char *host, *uport, *endp; *************** *** 236,254 **** len = sizeof(z); rv = recvfrom(s, buf, sizeof(buf), MSG_PEEK, ! (struct sockaddr *)&z, &len); if (rv < 0) errx(1, "%s", strerror(errno)); ! rv = connect(s, (struct sockaddr *)&z, ! len); if (rv < 0) errx(1, "%s", strerror(errno)); connfd = s; } else { connfd = accept(s, (struct sockaddr *)&cliaddr, ! &len); } readwrite(connfd); --- 234,251 ---- len = sizeof(z); rv = recvfrom(s, buf, sizeof(buf), MSG_PEEK, ! (struct sockaddr *)&z, &len); if (rv < 0) errx(1, "%s", strerror(errno)); ! rv = connect(s, (struct sockaddr *)&z, len); if (rv < 0) errx(1, "%s", strerror(errno)); connfd = s; } else { connfd = accept(s, (struct sockaddr *)&cliaddr, ! &len); } readwrite(connfd); *************** *** 294,306 **** sv = NULL; else { sv = getservbyport( ! ntohs(atoi(portlist[i])), ! uflag ? "udp" : "tcp"); } printf("Connection to %s %s port [%s/%s] succeeded!\n", ! host, portlist[i], uflag ? "udp" : "tcp", ! sv ? sv->s_name : "*"); } if (!zflag) readwrite(s); --- 291,303 ---- sv = NULL; else { sv = getservbyport( ! ntohs(atoi(portlist[i])), ! uflag ? "udp" : "tcp"); } printf("Connection to %s %s port [%s/%s] succeeded!\n", ! host, portlist[i], uflag ? "udp" : "tcp", ! sv ? sv->s_name : "*"); } if (!zflag) readwrite(s); *************** *** 319,327 **** * port or source address if needed. Return's -1 on failure. */ int ! remote_connect(host, port, hints) ! char *host, *port; ! struct addrinfo hints; { struct addrinfo *res, *res0; int s, error; --- 316,322 ---- * port or source address if needed. Return's -1 on failure. */ int ! remote_connect(char *host, char *port, struct addrinfo hints) { struct addrinfo *res, *res0; int s, error; *************** *** 332,338 **** res0 = res; do { if ((s = socket(res0->ai_family, res0->ai_socktype, ! res0->ai_protocol)) < 0) continue; /* Bind to a local port or source address if specified */ --- 327,333 ---- res0 = res; do { if ((s = socket(res0->ai_family, res0->ai_socktype, ! res0->ai_protocol)) < 0) continue; /* Bind to a local port or source address if specified */ *************** *** 355,361 **** errx(1, "%s", gai_strerror(error)); if (bind(s, (struct sockaddr *)ares->ai_addr, ! ares->ai_addrlen) < 0) { errx(1, "bind failed: %s", strerror(errno)); freeaddrinfo(ares); continue; --- 350,356 ---- errx(1, "%s", gai_strerror(error)); if (bind(s, (struct sockaddr *)ares->ai_addr, ! ares->ai_addrlen) < 0) { errx(1, "bind failed: %s", strerror(errno)); freeaddrinfo(ares); continue; *************** *** 384,392 **** * address. Return's -1 on failure. */ int ! local_listen(host, port, hints) ! char *host, *port; ! struct addrinfo hints; { struct addrinfo *res, *res0; int s, ret, x = 1; --- 379,385 ---- * address. Return's -1 on failure. */ int ! local_listen(char *host, char *port, struct addrinfo hints) { struct addrinfo *res, *res0; int s, ret, x = 1; *************** *** 408,414 **** res0 = res; do { if ((s = socket(res0->ai_family, res0->ai_socktype, ! res0->ai_protocol)) == 0) continue; ret = setsockopt(s, SOL_SOCKET, SO_REUSEPORT, &x, sizeof(x)); --- 401,407 ---- res0 = res; do { if ((s = socket(res0->ai_family, res0->ai_socktype, ! res0->ai_protocol)) == 0) continue; ret = setsockopt(s, SOL_SOCKET, SO_REUSEPORT, &x, sizeof(x)); *************** *** 416,422 **** err(1, NULL); if (bind(s, (struct sockaddr *)res0->ai_addr, ! res0->ai_addrlen) == 0) break; close(s); --- 409,415 ---- err(1, NULL); if (bind(s, (struct sockaddr *)res0->ai_addr, ! res0->ai_addrlen) == 0) break; close(s); *************** *** 438,445 **** * Loop that polls on the network file descriptor and stdin. */ void ! readwrite(nfd) ! int nfd; { struct pollfd *pfd; char buf[BUFSIZ]; --- 431,437 ---- * Loop that polls on the network file descriptor and stdin. */ void ! readwrite(int nfd) { struct pollfd *pfd; char buf[BUFSIZ]; *************** *** 489,498 **** } /* Deal with RFC854 WILL/WONT DO/DONT negotiation */ void ! atelnet(nfd, buf, size) ! int nfd; ! unsigned char *buf; ! unsigned int size; { int ret; unsigned char *p, *end; --- 481,487 ---- } /* Deal with RFC854 WILL/WONT DO/DONT negotiation */ void ! atelnet(int nfd, unsigned char *buf, unsigned int size) { int ret; unsigned char *p, *end; *************** *** 530,537 **** * that we should try to connect too. */ void ! build_ports(p) ! char *p; { char *n, *endp; int hi, lo, cp; --- 519,525 ---- * that we should try to connect too. */ void ! build_ports(char *p) { char *n, *endp; int hi, lo, cp; *************** *** 593,600 **** * Also fails after around 100 ports checked. */ int ! udptest(s) ! int s; { int i, rv, ret; --- 581,587 ---- * Also fails after around 100 ports checked. */ int ! udptest(int s) { int i, rv, ret; *************** *** 633,640 **** } void ! usage(ret) ! int ret; { fprintf(stderr, "usage: nc [-46hklnrtuvz] [-i interval] [-p source port]\n"); fprintf(stderr, "\t [-s ip address] [-w timeout] [-x proxy address [:port]]\n"); --- 620,626 ---- } void ! usage(int ret) { fprintf(stderr, "usage: nc [-46hklnrtuvz] [-i interval] [-p source port]\n"); fprintf(stderr, "\t [-s ip address] [-w timeout] [-x proxy address [:port]]\n");