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 <jc@irbs.com>
3. Using LQM option could be drop the link due to LcpLayerDown() doesn't
   stop LQR timer. -  Brian <brian@awfulhak.demon.co.uk>
4. Allow to describe a syntax of filters that is not only port number
   but also by name in /etc/service. -  Rich Murphey <rich@lamprey.utmb.edu>

Reviewed by:	Atsushi Murai <amurai@spec.co.jp>
Submitted by:	devet@adv.IAEhv.nl, jc@irbs.com, brian@awfulhak.demon.co.uk,
		rich@lamprey.utmb.edu
This commit is contained in:
Atsushi Murai 1995-09-17 16:14:49 +00:00
parent 1b04bf06cf
commit f18846503d
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=10858
6 changed files with 82 additions and 65 deletions

View file

@ -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 <sys/types.h>
#include <sys/socket.h>
#include <sys/param.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <netdb.h>
#include <stdio.h>
#include <stdlib.h>
#include <strings.h>
@ -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)
return(1);
}
if (argc == 1) {
if (STREQ(*argv, "estab")) {
filterdata.opt.estab = 1;
return(1);
}
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);
}
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);

View file

@ -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

View file

@ -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);
}

View file

@ -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();
}

View file

@ -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)

View file

@ -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)