freebsd-nq/usr.sbin/ppp/ip.c

491 lines
14 KiB
C
Raw Normal View History

1995-01-31 06:29:58 +00:00
/*
* PPP IP Protocol Interface
*
* Written by Toshiharu OHNO (tony-o@iij.ad.jp)
*
* Copyright (C) 1993, Internet Initiative Japan, Inc. All rights reserverd.
*
* Redistribution and use in source and binary forms are permitted
* provided that the above copyright notice and this paragraph are
* duplicated in all such forms and that any documentation,
* advertising materials, and other materials related to such
* distribution and use acknowledge that the software was developed
* by the Internet Initiative Japan. The name of the
* IIJ may not be used to endorse or promote products derived
* from this software without specific prior written permission.
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
1995-05-30 03:57:47 +00:00
*
* $Id: ip.c,v 1.59 1999/05/08 11:06:42 brian Exp $
1995-05-30 03:57:47 +00:00
*
1995-01-31 06:29:58 +00:00
* TODO:
* o Return ICMP message for filterd packet
* and optionaly record it into log.
*/
#include <sys/param.h>
1999-04-26 08:54:34 +00:00
#if defined(__OpenBSD__) || defined(__NetBSD__)
#include <sys/socket.h>
#endif
#include <netinet/in.h>
1995-01-31 06:29:58 +00:00
#include <netinet/in_systm.h>
#include <netinet/ip.h>
#include <netinet/ip_icmp.h>
#include <netinet/udp.h>
#include <netinet/tcp.h>
#include <arpa/inet.h>
#include <sys/un.h>
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <termios.h>
#include <unistd.h>
#include "layer.h"
#include "proto.h"
#include "mbuf.h"
#include "log.h"
#include "defs.h"
#include "timer.h"
#include "fsm.h"
#include "lqr.h"
#include "hdlc.h"
#include "throughput.h"
1998-03-13 21:07:46 +00:00
#include "iplist.h"
#include "slcompress.h"
#include "ipcp.h"
1998-03-13 21:07:46 +00:00
#include "filter.h"
#include "descriptor.h"
#include "lcp.h"
o Move struct lcp and struct ccp into struct link. o Remove bundle2lcp(), bundle2ccp() and bundle2link(). They're too resource-hungry and we have `owner pointers' to do their job. o Make our FSM understand LCPs that are always ST_OPENED (with a minimum code that != 1). o Send FSM code rejects for invalid codes. o Make our bundle fsm_parent deal with multiple links. o Make timer diagnostics pretty and allow access via ~t in `term' mode (not just when logging debug) and `show timers'. Only show timers every second in debug mode, otherwise we get too many diagnostics to be useful (we probably still do). Also, don't restrict ~m in term mode to depend on debug logging. o Rationalise our bundles' phases. o Create struct mp (multilink protocol). This is both an NCP and a type of struct link. It feeds off other NCPs for output, passing fragmented packets into the queues of available datalinks. It also gets PROTO_MP input, reassembles the fragments into ppp frames, and passes them back to the HDLC layer that the fragments were passed from. ** It's not yet possible to enter multilink mode :-( ** o Add `set weight' (requires context) for deciding on a links weighting in multilink mode. Weighting is simplistic (and probably badly implemented) for now. o Remove the function pointers in struct link. They ended up only applying to physical links. o Configure our tun device with an MTU equal to the MRU from struct mp's LCP and a speed equal to the sum of our link speeds. o `show {lcp,ccp,proto}' and `set deflate' now have optional context and use ChooseLink() to decide on which `struct link' to use. This allows behaviour as before when in non-multilink mode, and allows access to the MP logical link in multilink mode. o Ignore reconnect and redial values when in -direct mode and when cleaning up. Always redial when in -ddial or -dedicated mode (unless cleaning up). o Tell our links to `staydown' when we close them due to a signal. o Remove remaining `#ifdef SIGALRM's (ppp doesn't function without alarms). o Don't bother strdup()ing our physical link name. o Various other cosmetic changes.
1998-04-03 19:21:56 +00:00
#include "ccp.h"
#include "link.h"
#include "mp.h"
#ifndef NORADIUS
#include "radius.h"
#endif
1998-03-13 21:07:46 +00:00
#include "bundle.h"
#include "vjcomp.h"
#include "tun.h"
#include "ip.h"
1995-01-31 06:29:58 +00:00
static const u_short interactive_ports[32] = {
544, 513, 514, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1999-05-01 11:31:29 +00:00
80, 81, 0, 0, 0, 21, 22, 23, 0, 0, 0, 0, 0, 0, 0, 543,
1995-01-31 06:29:58 +00:00
};
#define INTERACTIVE(p) (interactive_ports[(p) & 0x1F] == (p))
1995-01-31 06:29:58 +00:00
static const char *TcpFlags[] = { "FIN", "SYN", "RST", "PSH", "ACK", "URG" };
1995-01-31 06:29:58 +00:00
static int
PortMatch(int op, u_short pport, u_short rport)
1995-01-31 06:29:58 +00:00
{
switch (op) {
case OP_EQ:
return (pport == rport);
1995-01-31 06:29:58 +00:00
case OP_GT:
return (pport > rport);
1995-01-31 06:29:58 +00:00
case OP_LT:
return (pport < rport);
1995-01-31 06:29:58 +00:00
default:
return (0);
1995-01-31 06:29:58 +00:00
}
}
/*
* Check a packet against a defined filter
1995-01-31 06:29:58 +00:00
*/
static int
1998-03-16 22:52:54 +00:00
FilterCheck(struct ip *pip, struct filter *filter)
1995-01-31 06:29:58 +00:00
{
int gotinfo, cproto, estab, syn, finrst, n, len, didname;
1995-01-31 06:29:58 +00:00
struct tcphdr *th;
struct udphdr *uh;
struct icmp *ih;
char *ptop;
u_short sport, dport;
1998-03-16 22:52:54 +00:00
struct filterent *fp = filter->rule;
char dbuff[100];
1995-01-31 06:29:58 +00:00
if (fp->action) {
cproto = gotinfo = estab = syn = finrst = didname = 0;
1995-01-31 06:29:58 +00:00
sport = dport = 0;
for (n = 0; n < MAXFILTERS; n++) {
if (fp->action) {
/* permit fragments on in and out filter */
1998-03-16 22:52:54 +00:00
if (filter->fragok && (ntohs(pip->ip_off) & IP_OFFMASK) != 0)
return (A_PERMIT);
1998-03-16 22:52:54 +00:00
if (!didname)
log_Printf(LogDEBUG, "%s filter:\n", filter->name);
didname = 1;
if ((pip->ip_src.s_addr & fp->smask.s_addr) ==
(fp->saddr.s_addr & fp->smask.s_addr) &&
(pip->ip_dst.s_addr & fp->dmask.s_addr) ==
(fp->daddr.s_addr & fp->dmask.s_addr)) {
1995-01-31 06:29:58 +00:00
if (fp->proto) {
if (!gotinfo) {
ptop = (char *) pip + (pip->ip_hl << 2);
1995-01-31 06:29:58 +00:00
switch (pip->ip_p) {
case IPPROTO_ICMP:
cproto = P_ICMP;
ih = (struct icmp *) ptop;
sport = ih->icmp_type;
estab = syn = finrst = -1;
if (log_IsKept(LogDEBUG))
snprintf(dbuff, sizeof dbuff, "sport = %d", sport);
1995-01-31 06:29:58 +00:00
break;
case IPPROTO_UDP:
case IPPROTO_IGMP:
case IPPROTO_IPIP:
cproto = P_UDP;
uh = (struct udphdr *) ptop;
sport = ntohs(uh->uh_sport);
dport = ntohs(uh->uh_dport);
estab = syn = finrst = -1;
if (log_IsKept(LogDEBUG))
snprintf(dbuff, sizeof dbuff, "sport = %d, dport = %d",
sport, dport);
1995-01-31 06:29:58 +00:00
break;
case IPPROTO_TCP:
cproto = P_TCP;
th = (struct tcphdr *) ptop;
sport = ntohs(th->th_sport);
dport = ntohs(th->th_dport);
1995-01-31 06:29:58 +00:00
estab = (th->th_flags & TH_ACK);
syn = (th->th_flags & TH_SYN);
finrst = (th->th_flags & (TH_FIN|TH_RST));
if (log_IsKept(LogDEBUG)) {
if (!estab)
snprintf(dbuff, sizeof dbuff,
"flags = %02x, sport = %d, dport = %d",
th->th_flags, sport, dport);
else
*dbuff = '\0';
}
1995-01-31 06:29:58 +00:00
break;
default:
return (A_DENY); /* We'll block unknown type of packet */
1995-01-31 06:29:58 +00:00
}
if (log_IsKept(LogDEBUG)) {
if (estab != -1) {
len = strlen(dbuff);
snprintf(dbuff + len, sizeof dbuff - len,
", estab = %d, syn = %d, finrst = %d",
estab, syn, finrst);
}
log_Printf(LogDEBUG, " Filter: proto = %s, %s\n",
filter_Proto2Nam(cproto), dbuff);
}
1995-01-31 06:29:58 +00:00
gotinfo = 1;
}
if (log_IsKept(LogDEBUG)) {
if (fp->opt.srcop != OP_NONE) {
snprintf(dbuff, sizeof dbuff, ", src %s %d",
filter_Op2Nam(fp->opt.srcop), fp->opt.srcport);
len = strlen(dbuff);
} else
len = 0;
if (fp->opt.dstop != OP_NONE) {
snprintf(dbuff + len, sizeof dbuff - len,
", dst %s %d", filter_Op2Nam(fp->opt.dstop),
fp->opt.dstport);
} else if (!len)
*dbuff = '\0';
log_Printf(LogDEBUG, " rule = %d: Address match, "
"check against proto %s%s, action = %s\n",
n, filter_Proto2Nam(fp->proto),
dbuff, filter_Action2Nam(fp->action));
}
1995-01-31 06:29:58 +00:00
if (cproto == fp->proto) {
if ((fp->opt.srcop == OP_NONE ||
PortMatch(fp->opt.srcop, sport, fp->opt.srcport)) &&
1995-01-31 06:29:58 +00:00
(fp->opt.dstop == OP_NONE ||
PortMatch(fp->opt.dstop, dport, fp->opt.dstport)) &&
(fp->opt.estab == 0 || estab) &&
(fp->opt.syn == 0 || syn) &&
(fp->opt.finrst == 0 || finrst)) {
return (fp->action);
1995-01-31 06:29:58 +00:00
}
}
} else {
/* Address is mached. Make a decision. */
log_Printf(LogDEBUG, " rule = %d: Address match, action = %s\n", n,
filter_Action2Nam(fp->action));
return (fp->action);
1995-01-31 06:29:58 +00:00
}
} else
log_Printf(LogDEBUG, " rule = %d: Address mismatch\n", n);
1995-01-31 06:29:58 +00:00
}
fp++;
}
return (A_DENY); /* No rule is mached. Deny this packet */
1995-01-31 06:29:58 +00:00
}
return (A_PERMIT); /* No rule is given. Permit this packet */
1995-01-31 06:29:58 +00:00
}
1998-03-16 22:52:54 +00:00
#ifdef notdef
1995-01-31 06:29:58 +00:00
static void
IcmpError(struct ip *pip, int code)
1995-01-31 06:29:58 +00:00
{
struct mbuf *bp;
if (pip->ip_p != IPPROTO_ICMP) {
bp = mbuf_Alloc(cnt, MB_IPIN);
memcpy(MBUF_CTOP(bp), ptr, cnt);
vj_SendFrame(bp);
1998-03-13 21:07:46 +00:00
ipcp_AddOutOctets(cnt);
1995-01-31 06:29:58 +00:00
}
}
1998-03-16 22:52:54 +00:00
#endif
1995-01-31 06:29:58 +00:00
/*
* For debugging aid.
*/
int
1998-03-16 22:52:54 +00:00
PacketCheck(struct bundle *bundle, char *cp, int nb, struct filter *filter)
1995-01-31 06:29:58 +00:00
{
struct ip *pip;
struct tcphdr *th;
struct udphdr *uh;
struct icmp *icmph;
char *ptop;
int mask, len, n;
int pri = PRI_NORMAL;
1997-06-16 21:20:00 +00:00
int logit, loglen;
char logbuf[200];
1995-01-31 06:29:58 +00:00
logit = log_IsKept(LogTCPIP) && filter->logok;
1997-06-16 21:20:00 +00:00
loglen = 0;
1995-01-31 06:29:58 +00:00
pip = (struct ip *) cp;
1995-05-30 03:57:47 +00:00
1997-06-16 21:20:00 +00:00
if (logit && loglen < sizeof logbuf) {
1998-03-16 22:52:54 +00:00
snprintf(logbuf + loglen, sizeof logbuf - loglen, "%s ", filter->name);
loglen += strlen(logbuf + loglen);
1997-06-16 21:20:00 +00:00
}
1995-01-31 06:29:58 +00:00
ptop = (cp + (pip->ip_hl << 2));
switch (pip->ip_p) {
case IPPROTO_ICMP:
1997-06-16 21:20:00 +00:00
if (logit && loglen < sizeof logbuf) {
icmph = (struct icmp *) ptop;
snprintf(logbuf + loglen, sizeof logbuf - loglen,
"ICMP: %s:%d ---> ", inet_ntoa(pip->ip_src), icmph->icmp_type);
loglen += strlen(logbuf + loglen);
snprintf(logbuf + loglen, sizeof logbuf - loglen,
"%s:%d", inet_ntoa(pip->ip_dst), icmph->icmp_type);
loglen += strlen(logbuf + loglen);
1995-01-31 06:29:58 +00:00
}
break;
case IPPROTO_UDP:
1997-06-16 21:20:00 +00:00
if (logit && loglen < sizeof logbuf) {
uh = (struct udphdr *) ptop;
snprintf(logbuf + loglen, sizeof logbuf - loglen,
"UDP: %s:%d ---> ", inet_ntoa(pip->ip_src), ntohs(uh->uh_sport));
loglen += strlen(logbuf + loglen);
snprintf(logbuf + loglen, sizeof logbuf - loglen,
"%s:%d", inet_ntoa(pip->ip_dst), ntohs(uh->uh_dport));
loglen += strlen(logbuf + loglen);
1995-01-31 06:29:58 +00:00
}
break;
case IPPROTO_IPIP:
if (logit && loglen < sizeof logbuf) {
uh = (struct udphdr *) ptop;
snprintf(logbuf + loglen, sizeof logbuf - loglen,
"IPIP: %s:%d ---> ", inet_ntoa(pip->ip_src), ntohs(uh->uh_sport));
loglen += strlen(logbuf + loglen);
snprintf(logbuf + loglen, sizeof logbuf - loglen,
"%s:%d", inet_ntoa(pip->ip_dst), ntohs(uh->uh_dport));
loglen += strlen(logbuf + loglen);
}
break;
case IPPROTO_IGMP:
if (logit && loglen < sizeof logbuf) {
uh = (struct udphdr *) ptop;
snprintf(logbuf + loglen, sizeof logbuf - loglen,
"IGMP: %s:%d ---> ", inet_ntoa(pip->ip_src), ntohs(uh->uh_sport));
loglen += strlen(logbuf + loglen);
snprintf(logbuf + loglen, sizeof logbuf - loglen,
"%s:%d", inet_ntoa(pip->ip_dst), ntohs(uh->uh_dport));
loglen += strlen(logbuf + loglen);
}
break;
1995-01-31 06:29:58 +00:00
case IPPROTO_TCP:
th = (struct tcphdr *) ptop;
1995-01-31 06:29:58 +00:00
if (pip->ip_tos == IPTOS_LOWDELAY)
pri = PRI_FAST;
else if ((ntohs(pip->ip_off) & IP_OFFMASK) == 0) {
1995-01-31 06:29:58 +00:00
if (INTERACTIVE(ntohs(th->th_sport)) || INTERACTIVE(ntohs(th->th_dport)))
pri = PRI_FAST;
1995-01-31 06:29:58 +00:00
}
1997-06-16 21:20:00 +00:00
if (logit && loglen < sizeof logbuf) {
1995-01-31 06:29:58 +00:00
len = ntohs(pip->ip_len) - (pip->ip_hl << 2) - (th->th_off << 2);
snprintf(logbuf + loglen, sizeof logbuf - loglen,
"TCP: %s:%d ---> ", inet_ntoa(pip->ip_src), ntohs(th->th_sport));
loglen += strlen(logbuf + loglen);
snprintf(logbuf + loglen, sizeof logbuf - loglen,
"%s:%d", inet_ntoa(pip->ip_dst), ntohs(th->th_dport));
loglen += strlen(logbuf + loglen);
1995-01-31 06:29:58 +00:00
n = 0;
for (mask = TH_FIN; mask != 0x40; mask <<= 1) {
1997-06-16 21:20:00 +00:00
if (th->th_flags & mask) {
snprintf(logbuf + loglen, sizeof logbuf - loglen, " %s", TcpFlags[n]);
loglen += strlen(logbuf + loglen);
}
1995-01-31 06:29:58 +00:00
n++;
}
snprintf(logbuf + loglen, sizeof logbuf - loglen,
" seq:%lx ack:%lx (%d/%d)",
(u_long)ntohl(th->th_seq), (u_long)ntohl(th->th_ack), len, nb);
loglen += strlen(logbuf + loglen);
1995-01-31 06:29:58 +00:00
if ((th->th_flags & TH_SYN) && nb > 40) {
u_short *sp;
1995-01-31 06:29:58 +00:00
ptop += 20;
sp = (u_short *) ptop;
1997-06-16 21:20:00 +00:00
if (ntohs(sp[0]) == 0x0204) {
snprintf(logbuf + loglen, sizeof logbuf - loglen,
" MSS = %d", ntohs(sp[1]));
loglen += strlen(logbuf + loglen);
}
1995-01-31 06:29:58 +00:00
}
}
break;
}
1997-06-16 21:20:00 +00:00
1998-03-16 22:52:54 +00:00
if ((FilterCheck(pip, filter) & A_DENY)) {
if (logit)
log_Printf(LogTCPIP, "%s - BLOCKED\n", logbuf);
1998-03-16 22:52:54 +00:00
#ifdef notdef
if (direction == 0)
IcmpError(pip, pri);
1998-03-16 22:52:54 +00:00
#endif
return (-1);
1995-01-31 06:29:58 +00:00
} else {
1998-03-16 22:52:54 +00:00
/* Check Keep Alive filter */
if (logit) {
if (FilterCheck(pip, &bundle->filter.alive) & A_DENY)
log_Printf(LogTCPIP, "%s - NO KEEPALIVE\n", logbuf);
else
log_Printf(LogTCPIP, "%s\n", logbuf);
}
return (pri);
1995-01-31 06:29:58 +00:00
}
}
struct mbuf *
ip_Input(struct bundle *bundle, struct link *l, struct mbuf *bp)
{
1995-01-31 06:29:58 +00:00
int nb, nw;
struct tun_data tun;
struct ip *pip;
1995-01-31 06:29:58 +00:00
if (bundle->ncp.ipcp.fsm.state != ST_OPENED) {
log_Printf(LogWARN, "ip_Input: IPCP not open - packet dropped\n");
mbuf_Free(bp);
return NULL;
1995-01-31 06:29:58 +00:00
}
tun_fill_header(tun, AF_INET);
nb = mbuf_Length(bp);
mbuf_Read(bp, tun.data, nb);
if (PacketCheck(bundle, tun.data, nb, &bundle->filter.in) < 0)
return NULL;
pip = (struct ip *)tun.data;
if (!(FilterCheck(pip, &bundle->filter.alive) & A_DENY))
bundle_StartIdleTimer(bundle);
ipcp_AddInOctets(&bundle->ncp.ipcp, nb);
nb += sizeof tun - sizeof tun.data;
nw = write(bundle->dev.fd, &tun, nb);
if (nw != nb) {
if (nw == -1)
log_Printf(LogERROR, "ip_Input: wrote %d, got %s\n", nb, strerror(errno));
else
log_Printf(LogERROR, "ip_Input: wrote %d, got %d\n", nb, nw);
}
return NULL;
1995-01-31 06:29:58 +00:00
}
void
ip_Enqueue(struct ipcp *ipcp, int pri, char *ptr, int count)
1995-01-31 06:29:58 +00:00
{
struct mbuf *bp;
if (pri < 0 || pri > sizeof ipcp->Queue / sizeof ipcp->Queue[0])
log_Printf(LogERROR, "Can't store in ip queue %d\n", pri);
else {
/*
* We allocate an extra 6 bytes, four at the front and two at the end.
* This is an optimisation so that we need to do less work in
* mbuf_Prepend() in acf_LayerPush() and proto_LayerPush() and
* appending in hdlc_LayerPush().
*/
bp = mbuf_Alloc(count + 6, MB_IPQ);
bp->offset += 4;
bp->cnt -= 6;
memcpy(MBUF_CTOP(bp), ptr, count);
mbuf_Enqueue(&ipcp->Queue[pri], bp);
}
1995-01-31 06:29:58 +00:00
}
void
ip_DeleteQueue(struct ipcp *ipcp)
{
struct mqueue *queue;
for (queue = ipcp->Queue; queue < ipcp->Queue + PRI_MAX; queue++)
while (queue->top)
mbuf_Free(mbuf_Dequeue(queue));
}
1995-05-30 03:57:47 +00:00
int
ip_QueueLen(struct ipcp *ipcp)
{
struct mqueue *queue;
int result = 0;
for (queue = ipcp->Queue; queue < ipcp->Queue + PRI_MAX; queue++)
result += queue->qlen;
return result;
}
o Move struct lcp and struct ccp into struct link. o Remove bundle2lcp(), bundle2ccp() and bundle2link(). They're too resource-hungry and we have `owner pointers' to do their job. o Make our FSM understand LCPs that are always ST_OPENED (with a minimum code that != 1). o Send FSM code rejects for invalid codes. o Make our bundle fsm_parent deal with multiple links. o Make timer diagnostics pretty and allow access via ~t in `term' mode (not just when logging debug) and `show timers'. Only show timers every second in debug mode, otherwise we get too many diagnostics to be useful (we probably still do). Also, don't restrict ~m in term mode to depend on debug logging. o Rationalise our bundles' phases. o Create struct mp (multilink protocol). This is both an NCP and a type of struct link. It feeds off other NCPs for output, passing fragmented packets into the queues of available datalinks. It also gets PROTO_MP input, reassembles the fragments into ppp frames, and passes them back to the HDLC layer that the fragments were passed from. ** It's not yet possible to enter multilink mode :-( ** o Add `set weight' (requires context) for deciding on a links weighting in multilink mode. Weighting is simplistic (and probably badly implemented) for now. o Remove the function pointers in struct link. They ended up only applying to physical links. o Configure our tun device with an MTU equal to the MRU from struct mp's LCP and a speed equal to the sum of our link speeds. o `show {lcp,ccp,proto}' and `set deflate' now have optional context and use ChooseLink() to decide on which `struct link' to use. This allows behaviour as before when in non-multilink mode, and allows access to the MP logical link in multilink mode. o Ignore reconnect and redial values when in -direct mode and when cleaning up. Always redial when in -ddial or -dedicated mode (unless cleaning up). o Tell our links to `staydown' when we close them due to a signal. o Remove remaining `#ifdef SIGALRM's (ppp doesn't function without alarms). o Don't bother strdup()ing our physical link name. o Various other cosmetic changes.
1998-04-03 19:21:56 +00:00
int
ip_PushPacket(struct link *l, struct bundle *bundle)
1995-01-31 06:29:58 +00:00
{
struct ipcp *ipcp = &bundle->ncp.ipcp;
1995-01-31 06:29:58 +00:00
struct mqueue *queue;
struct mbuf *bp;
struct ip *pip;
int cnt;
1995-01-31 06:29:58 +00:00
if (ipcp->fsm.state != ST_OPENED)
o Move struct lcp and struct ccp into struct link. o Remove bundle2lcp(), bundle2ccp() and bundle2link(). They're too resource-hungry and we have `owner pointers' to do their job. o Make our FSM understand LCPs that are always ST_OPENED (with a minimum code that != 1). o Send FSM code rejects for invalid codes. o Make our bundle fsm_parent deal with multiple links. o Make timer diagnostics pretty and allow access via ~t in `term' mode (not just when logging debug) and `show timers'. Only show timers every second in debug mode, otherwise we get too many diagnostics to be useful (we probably still do). Also, don't restrict ~m in term mode to depend on debug logging. o Rationalise our bundles' phases. o Create struct mp (multilink protocol). This is both an NCP and a type of struct link. It feeds off other NCPs for output, passing fragmented packets into the queues of available datalinks. It also gets PROTO_MP input, reassembles the fragments into ppp frames, and passes them back to the HDLC layer that the fragments were passed from. ** It's not yet possible to enter multilink mode :-( ** o Add `set weight' (requires context) for deciding on a links weighting in multilink mode. Weighting is simplistic (and probably badly implemented) for now. o Remove the function pointers in struct link. They ended up only applying to physical links. o Configure our tun device with an MTU equal to the MRU from struct mp's LCP and a speed equal to the sum of our link speeds. o `show {lcp,ccp,proto}' and `set deflate' now have optional context and use ChooseLink() to decide on which `struct link' to use. This allows behaviour as before when in non-multilink mode, and allows access to the MP logical link in multilink mode. o Ignore reconnect and redial values when in -direct mode and when cleaning up. Always redial when in -ddial or -dedicated mode (unless cleaning up). o Tell our links to `staydown' when we close them due to a signal. o Remove remaining `#ifdef SIGALRM's (ppp doesn't function without alarms). o Don't bother strdup()ing our physical link name. o Various other cosmetic changes.
1998-04-03 19:21:56 +00:00
return 0;
for (queue = &ipcp->Queue[PRI_FAST]; queue >= ipcp->Queue; queue--)
1995-01-31 06:29:58 +00:00
if (queue->top) {
bp = mbuf_Contiguous(mbuf_Dequeue(queue));
cnt = mbuf_Length(bp);
pip = (struct ip *)MBUF_CTOP(bp);
if (!(FilterCheck(pip, &bundle->filter.alive) & A_DENY))
bundle_StartIdleTimer(bundle);
link_PushPacket(l, bp, bundle, PRI_NORMAL, PROTO_IP);
ipcp_AddOutOctets(ipcp, cnt);
return 1;
1995-01-31 06:29:58 +00:00
}
o Move struct lcp and struct ccp into struct link. o Remove bundle2lcp(), bundle2ccp() and bundle2link(). They're too resource-hungry and we have `owner pointers' to do their job. o Make our FSM understand LCPs that are always ST_OPENED (with a minimum code that != 1). o Send FSM code rejects for invalid codes. o Make our bundle fsm_parent deal with multiple links. o Make timer diagnostics pretty and allow access via ~t in `term' mode (not just when logging debug) and `show timers'. Only show timers every second in debug mode, otherwise we get too many diagnostics to be useful (we probably still do). Also, don't restrict ~m in term mode to depend on debug logging. o Rationalise our bundles' phases. o Create struct mp (multilink protocol). This is both an NCP and a type of struct link. It feeds off other NCPs for output, passing fragmented packets into the queues of available datalinks. It also gets PROTO_MP input, reassembles the fragments into ppp frames, and passes them back to the HDLC layer that the fragments were passed from. ** It's not yet possible to enter multilink mode :-( ** o Add `set weight' (requires context) for deciding on a links weighting in multilink mode. Weighting is simplistic (and probably badly implemented) for now. o Remove the function pointers in struct link. They ended up only applying to physical links. o Configure our tun device with an MTU equal to the MRU from struct mp's LCP and a speed equal to the sum of our link speeds. o `show {lcp,ccp,proto}' and `set deflate' now have optional context and use ChooseLink() to decide on which `struct link' to use. This allows behaviour as before when in non-multilink mode, and allows access to the MP logical link in multilink mode. o Ignore reconnect and redial values when in -direct mode and when cleaning up. Always redial when in -ddial or -dedicated mode (unless cleaning up). o Tell our links to `staydown' when we close them due to a signal. o Remove remaining `#ifdef SIGALRM's (ppp doesn't function without alarms). o Don't bother strdup()ing our physical link name. o Various other cosmetic changes.
1998-04-03 19:21:56 +00:00
return 0;
1995-01-31 06:29:58 +00:00
}