mirror of
https://github.com/freebsd/freebsd-src
synced 2024-09-26 19:54:57 +00:00
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:
parent
1b04bf06cf
commit
f18846503d
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=10858
|
@ -17,15 +17,17 @@
|
||||||
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
||||||
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
* 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.
|
* TODO: Shoud send ICMP error message when we discard packets.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
|
#include <sys/param.h>
|
||||||
#include <netinet/in.h>
|
#include <netinet/in.h>
|
||||||
#include <arpa/inet.h>
|
#include <arpa/inet.h>
|
||||||
|
#include <netdb.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <strings.h>
|
#include <strings.h>
|
||||||
|
@ -108,6 +110,38 @@ char **argv;
|
||||||
return(proto);
|
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
|
* ICMP Syntax: src eq icmp_message_type
|
||||||
*/
|
*/
|
||||||
|
@ -161,9 +195,10 @@ char *cp;
|
||||||
* UDP Syntax: [src op port] [dst op port]
|
* UDP Syntax: [src op port] [dst op port]
|
||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
ParseUdp(argc, argv)
|
ParseUdpOrTcp(argc, argv, proto)
|
||||||
int argc;
|
int argc;
|
||||||
char **argv;
|
char **argv;
|
||||||
|
int proto;
|
||||||
{
|
{
|
||||||
int port;
|
int port;
|
||||||
char *cp;
|
char *cp;
|
||||||
|
@ -179,78 +214,42 @@ char **argv;
|
||||||
#endif
|
#endif
|
||||||
return(0);
|
return(0);
|
||||||
}
|
}
|
||||||
if (STREQ(*argv, "src")) {
|
if (argc >= 3 && STREQ(*argv, "src")) {
|
||||||
filterdata.opt.srcop = ParseOp(argv[1]);
|
filterdata.opt.srcop = ParseOp(argv[1]);
|
||||||
if (filterdata.opt.srcop == OP_NONE) {
|
if (filterdata.opt.srcop == OP_NONE) {
|
||||||
printf("bad operation\n");
|
printf("bad operation\n");
|
||||||
return(0);
|
return(0);
|
||||||
}
|
}
|
||||||
port = strtol(argv[2], &cp, 0);
|
filterdata.opt.srcport = ParsePort(argv[2], proto);
|
||||||
if (cp == argv[2]) {
|
if (filterdata.opt.srcport == 0)
|
||||||
printf("expect port number.\n");
|
|
||||||
return(0);
|
return(0);
|
||||||
}
|
|
||||||
filterdata.opt.srcport = port;
|
|
||||||
argc -= 3; argv += 3;
|
argc -= 3; argv += 3;
|
||||||
if (argc == 0)
|
if (argc == 0)
|
||||||
return(1);
|
return(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (argc >= 3 && STREQ(argv[0], "dst")) {
|
if (argc >= 3 && STREQ(argv[0], "dst")) {
|
||||||
filterdata.opt.dstop = ParseOp(argv[1]);
|
filterdata.opt.dstop = ParseOp(argv[1]);
|
||||||
if (filterdata.opt.dstop == OP_NONE) {
|
if (filterdata.opt.dstop == OP_NONE) {
|
||||||
printf("bad operation\n");
|
printf("bad operation\n");
|
||||||
return(0);
|
return(0);
|
||||||
}
|
}
|
||||||
port = strtol(argv[2], &cp, 0);
|
filterdata.opt.dstport = ParsePort(argv[2], proto);
|
||||||
if (cp == argv[2]) {
|
if (filterdata.opt.dstport == 0)
|
||||||
printf("port number is expected.\n");
|
|
||||||
return(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;
|
argc -= 3; argv += 3;
|
||||||
if (argc > 1) {
|
if (argc == 0)
|
||||||
argc -= 3; argv += 3;
|
return(1);
|
||||||
|
}
|
||||||
|
if (argc == 1) {
|
||||||
|
if (STREQ(*argv, "estab")) {
|
||||||
|
filterdata.opt.estab = 1;
|
||||||
|
return(1);
|
||||||
}
|
}
|
||||||
if (argc < 0 || argc > 1) {
|
printf("estab is expected: %s\n", *argv);
|
||||||
printf("bad tcp syntax.\n");
|
return(0);
|
||||||
return(0);
|
}
|
||||||
}
|
if (argc > 0)
|
||||||
if (argc == 1) {
|
printf("bad %s src/dst port syntax: %s\n", *argv);
|
||||||
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);
|
|
||||||
return(0);
|
return(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -343,10 +342,10 @@ struct filterent *ofp;
|
||||||
|
|
||||||
switch (proto) {
|
switch (proto) {
|
||||||
case P_TCP:
|
case P_TCP:
|
||||||
val = ParseTcp(argc, argv);
|
val = ParseUdpOrTcp(argc, argv, P_TCP);
|
||||||
break;
|
break;
|
||||||
case P_UDP:
|
case P_UDP:
|
||||||
val = ParseUdp(argc, argv);
|
val = ParseUdpOrTcp(argc, argv, P_UDP);
|
||||||
break;
|
break;
|
||||||
case P_ICMP:
|
case P_ICMP:
|
||||||
val = ParseIcmp(argc, argv);
|
val = ParseIcmp(argc, argv);
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
||||||
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
* 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:
|
* TODO:
|
||||||
* o Return ICMP message for filterd packet
|
* o Return ICMP message for filterd packet
|
||||||
|
@ -131,6 +131,11 @@ int direction;
|
||||||
sport = dport = 0;
|
sport = dport = 0;
|
||||||
for (n = 0; n < MAXFILTERS; n++) {
|
for (n = 0; n < MAXFILTERS; n++) {
|
||||||
if (fp->action) {
|
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
|
#ifdef DEBUG
|
||||||
logprintf("rule = %d\n", n);
|
logprintf("rule = %d\n", n);
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
||||||
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
* 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:
|
* TODO:
|
||||||
* o Validate magic number received from peer.
|
* o Validate magic number received from peer.
|
||||||
|
@ -372,6 +372,7 @@ struct fsm *fp;
|
||||||
{
|
{
|
||||||
LogPrintf(LOG_LCP, "%s: LayerDown\n", fp->name);
|
LogPrintf(LOG_LCP, "%s: LayerDown\n", fp->name);
|
||||||
StopAllTimers();
|
StopAllTimers();
|
||||||
|
StopLqr( LQM_LQR );
|
||||||
OsLinkdown();
|
OsLinkdown();
|
||||||
NewPhase(PHASE_TERMINATE);
|
NewPhase(PHASE_TERMINATE);
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
||||||
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
* 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:
|
* TODO:
|
||||||
* o Add commands for traffic summary, version display, etc.
|
* o Add commands for traffic summary, version display, etc.
|
||||||
|
@ -737,7 +737,7 @@ DoLoop()
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((mode & MODE_INTER) && FD_ISSET(netfd, &rfds) &&
|
if ((mode & MODE_INTER) && FD_ISSET(netfd, &rfds) &&
|
||||||
pgroup == tcgetpgrp(0)) {
|
((mode & MODE_AUTO) || pgroup == tcgetpgrp(0))) {
|
||||||
/* something to read from tty */
|
/* something to read from tty */
|
||||||
ReadTty();
|
ReadTty();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
.\" manual page [] for ppp 0.94 beta2 + alpha
|
.\" 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
|
.\" SH section heading
|
||||||
.\" SS subsection heading
|
.\" SS subsection heading
|
||||||
.\" LP paragraph
|
.\" LP paragraph
|
||||||
|
@ -316,6 +316,8 @@ o A filter definition has the following syntax:
|
||||||
|
|
||||||
d) proto must be one of icmp, udp or tcp.
|
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
|
.TP
|
||||||
o Each filter can hold up to 20 rules, starting from rule 0.
|
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.
|
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..*
|
.B /var/spool/lock/Lck..*
|
||||||
tty port locking file.
|
tty port locking file.
|
||||||
|
|
||||||
|
.TP
|
||||||
|
.B /etc/service
|
||||||
|
Get port number if port number is using service name.
|
||||||
|
|
||||||
.SH HISTORY
|
.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
|
.SH AUTHORS
|
||||||
Toshiharu OHNO (tony-o@iij.ad.jp)
|
Toshiharu OHNO (tony-o@iij.ad.jp)
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
.\" manual page [] for ppp 0.94 beta2 + alpha
|
.\" 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
|
.\" SH section heading
|
||||||
.\" SS subsection heading
|
.\" SS subsection heading
|
||||||
.\" LP paragraph
|
.\" LP paragraph
|
||||||
|
@ -316,6 +316,8 @@ o A filter definition has the following syntax:
|
||||||
|
|
||||||
d) proto must be one of icmp, udp or tcp.
|
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
|
.TP
|
||||||
o Each filter can hold up to 20 rules, starting from rule 0.
|
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.
|
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..*
|
.B /var/spool/lock/Lck..*
|
||||||
tty port locking file.
|
tty port locking file.
|
||||||
|
|
||||||
|
.TP
|
||||||
|
.B /etc/service
|
||||||
|
Get port number if port number is using service name.
|
||||||
|
|
||||||
.SH HISTORY
|
.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
|
.SH AUTHORS
|
||||||
Toshiharu OHNO (tony-o@iij.ad.jp)
|
Toshiharu OHNO (tony-o@iij.ad.jp)
|
||||||
|
|
Loading…
Reference in a new issue