From c47a4a8b716b935c41530d96c32a1a6a7f7b5a21 Mon Sep 17 00:00:00 2001 From: amurai Date: Sun, 17 Sep 1995 16:14:49 +0000 Subject: 1. All fragments (except the first one) of a fragmented packet were dropped - devet@adv.IAEhv.nl (Arjan de Vet) 2. Will not read data from telnet connection - John Capo 3. Using LQM option could be drop the link due to LcpLayerDown() doesn't stop LQR timer. - Brian 4. Allow to describe a syntax of filters that is not only port number but also by name in /etc/service. - Rich Murphey Reviewed by: Atsushi Murai Submitted by: devet@adv.IAEhv.nl, jc@irbs.com, brian@awfulhak.demon.co.uk, rich@lamprey.utmb.edu --- usr.sbin/ppp/filter.c | 113 +++++++++++++++++++++++++------------------------- usr.sbin/ppp/ip.c | 7 +++- usr.sbin/ppp/lcp.c | 3 +- usr.sbin/ppp/main.c | 4 +- usr.sbin/ppp/ppp.8 | 10 ++++- usr.sbin/ppp/ppp.8.m4 | 10 ++++- 6 files changed, 82 insertions(+), 65 deletions(-) diff --git a/usr.sbin/ppp/filter.c b/usr.sbin/ppp/filter.c index 60a5cfb..b459ff6 100644 --- a/usr.sbin/ppp/filter.c +++ b/usr.sbin/ppp/filter.c @@ -17,15 +17,17 @@ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * $Id: filter.c,v 1.3 1995/02/26 12:17:25 amurai Exp $ + * $Id: filter.c,v 1.4 1995/05/30 03:50:31 rgrimes Exp $ * * TODO: Shoud send ICMP error message when we discard packets. */ #include #include +#include #include #include +#include #include #include #include @@ -108,6 +110,38 @@ char **argv; return(proto); } +static int +ParsePort(service, proto) +char *service; +int proto; +{ + char *protocol_name, *cp; + struct servent *servent; + int port; + + switch (proto) { + case P_UDP: + protocol_name = "udp"; + break; + case P_TCP: + protocol_name = "tcp"; + break; + default: + protocol_name = 0; + } + + servent = getservbyname (service, protocol_name); + if (servent != 0) + return(ntohs(servent->s_port)); + + port = strtol(service, &cp, 0); + if (cp == service) { + printf("%s is not a port name or number.\n", service); + return(0); + } + return(port); +} + /* * ICMP Syntax: src eq icmp_message_type */ @@ -161,9 +195,10 @@ char *cp; * UDP Syntax: [src op port] [dst op port] */ static int -ParseUdp(argc, argv) +ParseUdpOrTcp(argc, argv, proto) int argc; char **argv; +int proto; { int port; char *cp; @@ -179,78 +214,42 @@ char **argv; #endif return(0); } - if (STREQ(*argv, "src")) { + if (argc >= 3 && STREQ(*argv, "src")) { filterdata.opt.srcop = ParseOp(argv[1]); if (filterdata.opt.srcop == OP_NONE) { printf("bad operation\n"); return(0); } - port = strtol(argv[2], &cp, 0); - if (cp == argv[2]) { - printf("expect port number.\n"); + filterdata.opt.srcport = ParsePort(argv[2], proto); + if (filterdata.opt.srcport == 0) return(0); - } - filterdata.opt.srcport = port; argc -= 3; argv += 3; if (argc == 0) return(1); } - if (argc >= 3 && STREQ(argv[0], "dst")) { filterdata.opt.dstop = ParseOp(argv[1]); if (filterdata.opt.dstop == OP_NONE) { printf("bad operation\n"); return(0); } - port = strtol(argv[2], &cp, 0); - if (cp == argv[2]) { - printf("port number is expected.\n"); + filterdata.opt.dstport = ParsePort(argv[2], proto); + if (filterdata.opt.dstport == 0) return(0); - } - filterdata.opt.dstport = port; - return(1); - } - if (argc == 1 && STREQ(argv[0], "estab")) - return(1); - printf("no src/dst port.\n"); - return(0); -} - -/* - * TCP Syntax: [src op port] [dst op port] [estab] - */ -static int -ParseTcp(argc, argv) -int argc; -char **argv; -{ - int val; - - val = ParseUdp(argc, argv); - if (val) { - if (argc == 0) return(1); /* Will permit/deny all tcp traffic */ argc -= 3; argv += 3; - if (argc > 1) { - argc -= 3; argv += 3; - } - if (argc < 0 || argc > 1) { - printf("bad tcp syntax.\n"); - return(0); - } - if (argc == 1) { -checkestab: - if (STREQ(*argv, "estab")) { - filterdata.opt.estab = 1; - return(1); - } - printf("estab is expected.\n"); - return(0); + if (argc == 0) + return(1); + } + if (argc == 1) { + if (STREQ(*argv, "estab")) { + filterdata.opt.estab = 1; + return(1); } - - return(1); - } else if (argc == 1) - goto checkestab; - printf("bad port syntax (val = %d, argc = %d.\n", val, argc); + printf("estab is expected: %s\n", *argv); + return(0); + } + if (argc > 0) + printf("bad %s src/dst port syntax: %s\n", *argv); return(0); } @@ -343,10 +342,10 @@ struct filterent *ofp; switch (proto) { case P_TCP: - val = ParseTcp(argc, argv); + val = ParseUdpOrTcp(argc, argv, P_TCP); break; case P_UDP: - val = ParseUdp(argc, argv); + val = ParseUdpOrTcp(argc, argv, P_UDP); break; case P_ICMP: val = ParseIcmp(argc, argv); diff --git a/usr.sbin/ppp/ip.c b/usr.sbin/ppp/ip.c index c25b56c..16cdf1f 100644 --- a/usr.sbin/ppp/ip.c +++ b/usr.sbin/ppp/ip.c @@ -17,7 +17,7 @@ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * $Id: ip.c,v 1.3 1995/03/11 15:18:42 amurai Exp $ + * $Id: ip.c,v 1.4 1995/05/30 03:50:37 rgrimes Exp $ * * TODO: * o Return ICMP message for filterd packet @@ -131,6 +131,11 @@ int direction; sport = dport = 0; for (n = 0; n < MAXFILTERS; n++) { if (fp->action) { + /* permit fragments on in and out filter */ + if ((direction == FL_IN || direction == FL_OUT) && + (pip->ip_off & IP_OFFMASK) != 0) { + return(A_PERMIT); + } #ifdef DEBUG logprintf("rule = %d\n", n); #endif diff --git a/usr.sbin/ppp/lcp.c b/usr.sbin/ppp/lcp.c index 4cce75a..fa160af 100644 --- a/usr.sbin/ppp/lcp.c +++ b/usr.sbin/ppp/lcp.c @@ -17,7 +17,7 @@ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * $Id: lcp.c,v 1.4 1995/05/30 03:50:40 rgrimes Exp $ + * $Id: lcp.c,v 1.5 1995/07/08 05:09:57 amurai Exp $ * * TODO: * o Validate magic number received from peer. @@ -372,6 +372,7 @@ struct fsm *fp; { LogPrintf(LOG_LCP, "%s: LayerDown\n", fp->name); StopAllTimers(); + StopLqr( LQM_LQR ); OsLinkdown(); NewPhase(PHASE_TERMINATE); } diff --git a/usr.sbin/ppp/main.c b/usr.sbin/ppp/main.c index 4367750..cc0f513 100644 --- a/usr.sbin/ppp/main.c +++ b/usr.sbin/ppp/main.c @@ -17,7 +17,7 @@ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * $Id: main.c,v 1.6 1995/07/06 02:58:57 asami Exp $ + * $Id: main.c,v 1.8 1995/09/02 17:20:52 amurai Exp $ * * TODO: * o Add commands for traffic summary, version display, etc. @@ -737,7 +737,7 @@ DoLoop() } if ((mode & MODE_INTER) && FD_ISSET(netfd, &rfds) && - pgroup == tcgetpgrp(0)) { + ((mode & MODE_AUTO) || pgroup == tcgetpgrp(0))) { /* something to read from tty */ ReadTty(); } diff --git a/usr.sbin/ppp/ppp.8 b/usr.sbin/ppp/ppp.8 index 788522e..f3a1bea 100644 --- a/usr.sbin/ppp/ppp.8 +++ b/usr.sbin/ppp/ppp.8 @@ -1,5 +1,5 @@ .\" manual page [] for ppp 0.94 beta2 + alpha -.\" $Id: ppp.8,v 1.8 1995/05/26 17:35:54 jkh Exp $ +.\" $Id: ppp.8,v 1.9 1995/06/26 08:04:16 bde Exp $ .\" SH section heading .\" SS subsection heading .\" LP paragraph @@ -316,6 +316,8 @@ o A filter definition has the following syntax: d) proto must be one of icmp, udp or tcp. + e) port number can be specify by number and service name in /etc/service. + .TP o Each filter can hold up to 20 rules, starting from rule 0. The entire rule set is not effective until rule 0 is defined. @@ -587,8 +589,12 @@ Logging and debugging information file. .B /var/spool/lock/Lck..* tty port locking file. +.TP +.B /etc/service +Get port number if port number is using service name. + .SH HISTORY -This program was submitted in FreeBSD-2.0.5 by Atsushi Murai (amurai@spec.co.jp). +This program was submitted in FreeBSD-2.0.5 Atsushi Murai (amurai@spec.co.jp). .SH AUTHORS Toshiharu OHNO (tony-o@iij.ad.jp) diff --git a/usr.sbin/ppp/ppp.8.m4 b/usr.sbin/ppp/ppp.8.m4 index 788522e..f3a1bea 100644 --- a/usr.sbin/ppp/ppp.8.m4 +++ b/usr.sbin/ppp/ppp.8.m4 @@ -1,5 +1,5 @@ .\" manual page [] for ppp 0.94 beta2 + alpha -.\" $Id: ppp.8,v 1.8 1995/05/26 17:35:54 jkh Exp $ +.\" $Id: ppp.8,v 1.9 1995/06/26 08:04:16 bde Exp $ .\" SH section heading .\" SS subsection heading .\" LP paragraph @@ -316,6 +316,8 @@ o A filter definition has the following syntax: d) proto must be one of icmp, udp or tcp. + e) port number can be specify by number and service name in /etc/service. + .TP o Each filter can hold up to 20 rules, starting from rule 0. The entire rule set is not effective until rule 0 is defined. @@ -587,8 +589,12 @@ Logging and debugging information file. .B /var/spool/lock/Lck..* tty port locking file. +.TP +.B /etc/service +Get port number if port number is using service name. + .SH HISTORY -This program was submitted in FreeBSD-2.0.5 by Atsushi Murai (amurai@spec.co.jp). +This program was submitted in FreeBSD-2.0.5 Atsushi Murai (amurai@spec.co.jp). .SH AUTHORS Toshiharu OHNO (tony-o@iij.ad.jp) -- cgit v1.1