Allow `host:port/udp'' devices and support
`host:port/tcp'' as
being the same as the previous (still supported) ``host:port'' syntax for tcp socket devices. A udp device uses synchronous ppp rather than async, and avoids the double-retransmit overhead that comes with ppp over tcp (it's usually a bad idea to transport IP over a reliable transport that itself is using an unreliable transport). PPP over UDP provides througput of ** 1.5Mb per second ** with all compression disabled, maxing out a PPro/200 when running ppp twice, back-to-back. This proves that PPPoE is plausable in userland.... This change adds a few more handler functions to struct device and allows derivations of struct device (which may contain their own data etc) to pass themselves through the unix domain socket for MP. ** At last **, struct physical has lost all the tty crud ! iov2physical() is now smart enough to restore the correct stack of layers so that MP servers will work again. The version number has bumped as our MP link transfer contents have changed (they now may contain a `struct device'). Don't extract the protocol twice in MP mode (resulting in protocol rejects for every MP packet). This was broken with my original layering changes. Add ``Physical'' and ``Sync'' log levels for logging the relevent raw packets and add protocol-tracking LogDEBUG stuff in various LayerPush & LayerPull functions. Assign our physical device name for incoming tcp connections by calling getpeername(). Assign our physical device name for incoming udp connections from the address retrieved by the first recvfrom().
This commit is contained in:
parent
3c9bb8b7ff
commit
6815097bf7
@ -1,4 +1,4 @@
|
||||
# $Id: Makefile,v 1.52 1999/01/28 15:16:38 brian Exp $
|
||||
# $Id: Makefile,v 1.53 1999/05/08 11:05:54 brian Exp $
|
||||
|
||||
MAINTAINER=brian@FreeBSD.org
|
||||
|
||||
@ -8,7 +8,7 @@ SRCS= acf.c arp.c async.c auth.c bundle.c cbcp.c ccp.c chap.c chat.c \
|
||||
id.c iface.c ip.c ipcp.c iplist.c lcp.c link.c log.c lqr.c main.c \
|
||||
mbuf.c mp.c pap.c physical.c pred.c probe.c prompt.c proto.c route.c \
|
||||
server.c sig.c slcompress.c sync.c systems.c tcp.c throughput.c \
|
||||
timer.c tty.c tun.c vjcomp.c
|
||||
timer.c tty.c tun.c udp.c vjcomp.c
|
||||
CFLAGS+=-Wall
|
||||
LDADD+= -lcrypt -lmd -lutil -lz
|
||||
DPADD+= ${LIBCRYPT} ${LIBMD} ${LIBUTIL} ${LIBZ}
|
||||
|
@ -2,7 +2,7 @@
|
||||
* The code in this file was written by Eivind Eklund <perhaps@yes.no>,
|
||||
* who places it in the public domain without restriction.
|
||||
*
|
||||
* $Id: alias_cmd.c,v 1.23 1999/04/26 08:54:32 brian Exp $
|
||||
* $Id: alias_cmd.c,v 1.24 1999/05/08 11:05:59 brian Exp $
|
||||
*/
|
||||
|
||||
#include <sys/param.h>
|
||||
@ -328,7 +328,8 @@ alias_LayerPush(struct bundle *bundle, struct link *l, struct mbuf *bp,
|
||||
{
|
||||
if (!bundle->AliasEnabled || *proto != PROTO_IP)
|
||||
return bp;
|
||||
|
||||
|
||||
log_Printf(LogDEBUG, "alias_LayerPush: PROTO_IP -> PROTO_IP\n");
|
||||
bp = mbuf_Contiguous(alias_PadMbuf(bp, MB_IPQ));
|
||||
PacketAliasOut(MBUF_CTOP(bp), bp->cnt);
|
||||
bp->cnt = ntohs(((struct ip *)MBUF_CTOP(bp))->ip_len);
|
||||
@ -348,6 +349,7 @@ alias_LayerPull(struct bundle *bundle, struct link *l, struct mbuf *bp,
|
||||
if (!bundle->AliasEnabled || *proto != PROTO_IP)
|
||||
return bp;
|
||||
|
||||
log_Printf(LogDEBUG, "alias_LayerPull: PROTO_IP -> PROTO_IP\n");
|
||||
bp = mbuf_Contiguous(alias_PadMbuf(bp, MB_IPIN));
|
||||
pip = (struct ip *)MBUF_CTOP(bp);
|
||||
piip = (struct ip *)((char *)pip + (pip->ip_hl << 2));
|
||||
|
@ -17,7 +17,7 @@
|
||||
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* $Id: async.c,v 1.18 1999/04/11 08:51:04 brian Exp $
|
||||
* $Id: async.c,v 1.19 1999/05/08 11:06:03 brian Exp $
|
||||
*
|
||||
*/
|
||||
#include <sys/types.h>
|
||||
@ -118,8 +118,8 @@ async_LayerPush(struct bundle *bundle, struct link *l, struct mbuf *bp,
|
||||
mbuf_Free(bp);
|
||||
bp = mbuf_Alloc(cnt, MB_ASYNC);
|
||||
memcpy(MBUF_CTOP(bp), p->async.xbuff, cnt);
|
||||
log_DumpBp(LogASYNC, "Write", bp);
|
||||
|
||||
log_DumpBp(LogASYNC, "WriteModem", bp);
|
||||
return bp;
|
||||
}
|
||||
|
||||
@ -182,6 +182,7 @@ async_LayerPull(struct bundle *b, struct link *l, struct mbuf *bp,
|
||||
|
||||
last = &nbp;
|
||||
|
||||
log_DumpBp(LogASYNC, "Read", bp);
|
||||
while (bp) {
|
||||
ch = MBUF_CTOP(bp);
|
||||
for (cnt = bp->cnt; cnt; cnt--) {
|
||||
|
@ -23,7 +23,7 @@
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $Id: bundle.c,v 1.51 1999/04/26 08:54:33 brian Exp $
|
||||
* $Id: bundle.c,v 1.52 1999/05/08 11:06:08 brian Exp $
|
||||
*/
|
||||
|
||||
#include <sys/param.h>
|
||||
@ -87,7 +87,7 @@
|
||||
#include "ip.h"
|
||||
#include "iface.h"
|
||||
|
||||
#define SCATTER_SEGMENTS 4 /* version, datalink, name, physical */
|
||||
#define SCATTER_SEGMENTS 5 /* version, datalink, name, physical, device */
|
||||
#define SOCKET_OVERHEAD 100 /* additional buffer space for large */
|
||||
/* {recv,send}msg() calls */
|
||||
|
||||
|
@ -17,7 +17,7 @@
|
||||
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* $Id: ccp.c,v 1.47 1999/05/08 11:06:12 brian Exp $
|
||||
* $Id: ccp.c,v 1.48 1999/05/09 20:02:17 brian Exp $
|
||||
*
|
||||
* TODO:
|
||||
* o Support other compression protocols
|
||||
@ -594,6 +594,8 @@ ccp_LayerPull(struct bundle *b, struct link *l, struct mbuf *bp, u_short *proto)
|
||||
*/
|
||||
if (l->ccp.fsm.state == ST_OPENED) {
|
||||
if (*proto == PROTO_COMPD || *proto == PROTO_ICOMPD) {
|
||||
log_Printf(LogDEBUG, "ccp_LayerPull: PROTO_%sCOMPDP -> PROTO_IP\n",
|
||||
*proto == PROTO_ICOMPD ? "I" : "");
|
||||
/* Decompress incoming data */
|
||||
if (l->ccp.reset_sent != -1)
|
||||
/* Send another REQ and put the packet in the bit bucket */
|
||||
@ -603,10 +605,13 @@ ccp_LayerPull(struct bundle *b, struct link *l, struct mbuf *bp, u_short *proto)
|
||||
(l->ccp.in.state, &l->ccp, proto, bp);
|
||||
mbuf_Free(bp);
|
||||
bp = NULL;
|
||||
} else if (PROTO_COMPRESSIBLE(*proto) && l->ccp.in.state != NULL)
|
||||
} else if (PROTO_COMPRESSIBLE(*proto) && l->ccp.in.state != NULL) {
|
||||
log_Printf(LogDEBUG, "ccp_LayerPull: Ignore packet (dict only)\n");
|
||||
/* Add incoming Network Layer traffic to our dictionary */
|
||||
(*algorithm[l->ccp.in.algorithm]->i.DictSetup)
|
||||
(l->ccp.in.state, &l->ccp, *proto, bp);
|
||||
} else
|
||||
log_Printf(LogDEBUG, "ccp_LayerPull: Ignore packet\n");
|
||||
}
|
||||
|
||||
return bp;
|
||||
|
@ -17,7 +17,7 @@
|
||||
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* $Id: command.c,v 1.191 1999/04/26 08:54:33 brian Exp $
|
||||
* $Id: command.c,v 1.192 1999/05/08 11:06:21 brian Exp $
|
||||
*
|
||||
*/
|
||||
#include <sys/param.h>
|
||||
@ -142,8 +142,8 @@
|
||||
#define NEG_VJCOMP 51
|
||||
#define NEG_DNS 52
|
||||
|
||||
const char Version[] = "2.2";
|
||||
const char VersionDate[] = "$Date: 1999/04/26 08:54:33 $";
|
||||
const char Version[] = "2.21";
|
||||
const char VersionDate[] = "$Date: 1999/05/08 11:06:21 $";
|
||||
|
||||
static int ShowCommand(struct cmdargs const *);
|
||||
static int TerminalCommand(struct cmdargs const *);
|
||||
|
@ -23,7 +23,7 @@
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $Id: datalink.c,v 1.37 1999/04/06 14:48:10 brian Exp $
|
||||
* $Id: datalink.c,v 1.38 1999/05/08 11:06:24 brian Exp $
|
||||
*/
|
||||
|
||||
#include <sys/param.h>
|
||||
@ -210,7 +210,7 @@ datalink_LoginDone(struct datalink *dl)
|
||||
physical_Offline(dl->physical);
|
||||
chat_Init(&dl->chat, dl->physical, dl->cfg.script.hangup, 1, NULL);
|
||||
} else {
|
||||
timer_Stop(&dl->physical->Timer);
|
||||
physical_StopDeviceTimer(dl->physical);
|
||||
if (dl->physical->type == PHYS_DEDICATED)
|
||||
/* force a redial timeout */
|
||||
physical_Close(dl->physical);
|
||||
@ -463,7 +463,7 @@ datalink_ComeDown(struct datalink *dl, int how)
|
||||
|
||||
if (dl->state >= DATALINK_READY && dl->stayonline) {
|
||||
dl->stayonline = 0;
|
||||
timer_Stop(&dl->physical->Timer);
|
||||
physical_StopDeviceTimer(dl->physical);
|
||||
datalink_NewState(dl, DATALINK_READY);
|
||||
} else if (dl->state != DATALINK_CLOSED && dl->state != DATALINK_HANGUP) {
|
||||
physical_Offline(dl->physical);
|
||||
|
@ -23,7 +23,7 @@
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $Id:$
|
||||
* $Id: exec.c,v 1.1 1999/05/08 11:06:30 brian Exp $
|
||||
*/
|
||||
|
||||
#include <sys/param.h>
|
||||
@ -78,10 +78,35 @@
|
||||
#include "datalink.h"
|
||||
#include "exec.h"
|
||||
|
||||
static int
|
||||
exec_Open(struct physical *p)
|
||||
static struct device execdevice = {
|
||||
EXEC_DEVICE,
|
||||
"exec",
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL
|
||||
};
|
||||
|
||||
struct device *
|
||||
exec_iov2device(int type, struct physical *p, struct iovec *iov,
|
||||
int *niov, int maxiov)
|
||||
{
|
||||
if (*p->name.full == '!') {
|
||||
if (type == EXEC_DEVICE)
|
||||
return &execdevice;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
struct device *
|
||||
exec_Create(struct physical *p)
|
||||
{
|
||||
if (p->fd < 0 && *p->name.full == '!') {
|
||||
int fids[2];
|
||||
|
||||
if (socketpair(AF_UNIX, SOCK_STREAM, PF_UNSPEC, fids) < 0)
|
||||
@ -137,24 +162,11 @@ exec_Open(struct physical *p)
|
||||
p->fd = fids[0];
|
||||
waitpid(pid, &stat, 0);
|
||||
log_Printf(LogDEBUG, "Using descriptor %d for child\n", p->fd);
|
||||
physical_SetupStack(p, 1);
|
||||
return 1;
|
||||
physical_SetupStack(p, PHYSICAL_FORCE_ASYNC);
|
||||
return &execdevice;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
const struct device execdevice = {
|
||||
EXEC_DEVICE,
|
||||
"exec",
|
||||
exec_Open,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL
|
||||
};
|
||||
|
@ -23,7 +23,12 @@
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $Id:$
|
||||
* $Id: exec.h,v 1.1 1999/05/08 11:06:31 brian Exp $
|
||||
*/
|
||||
|
||||
extern const struct device execdevice;
|
||||
struct physical;
|
||||
struct device;
|
||||
|
||||
extern struct device *exec_Create(struct physical *);
|
||||
extern struct device *exec_iov2device(int, struct physical *,
|
||||
struct iovec *, int *, int);
|
||||
|
@ -23,7 +23,7 @@
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $Id: link.c,v 1.8 1999/03/31 14:21:45 brian Exp $
|
||||
* $Id: link.c,v 1.9 1999/05/08 11:06:58 brian Exp $
|
||||
*
|
||||
*/
|
||||
|
||||
@ -216,8 +216,8 @@ link_PushPacket(struct link *l, struct mbuf *bp, struct bundle *b, int pri,
|
||||
bp = (*l->layer[layer - 1]->push)(b, l, bp, pri, &proto);
|
||||
|
||||
if (bp) {
|
||||
log_Printf(LogDEBUG, "link_PushPacket: proto = 0x%04x\n", proto);
|
||||
link_AddOutOctets(l, mbuf_Length(bp));
|
||||
log_Printf(LogDEBUG, "link_PushPacket: Transmit proto 0x%04x\n", proto);
|
||||
mbuf_Enqueue(l->Queue + pri, mbuf_Contiguous(bp));
|
||||
}
|
||||
}
|
||||
@ -267,6 +267,7 @@ link_PullPacket(struct link *l, char *buf, size_t len, struct bundle *b)
|
||||
while (bp) {
|
||||
next = bp->pnext;
|
||||
bp->pnext = NULL;
|
||||
log_Printf(LogDEBUG, "link_PullPacket: Despatch proto 0x%04x\n", proto);
|
||||
Despatch(b, l, bp, proto);
|
||||
bp = next;
|
||||
}
|
||||
|
@ -23,7 +23,7 @@
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $Id: log.c,v 1.36 1999/03/07 11:54:41 brian Exp $
|
||||
* $Id: log.c,v 1.37 1999/05/09 20:02:22 brian Exp $
|
||||
*/
|
||||
|
||||
#include <sys/types.h>
|
||||
@ -55,6 +55,8 @@ static const char *LogNames[] = {
|
||||
"LCP",
|
||||
"LQM",
|
||||
"Phase",
|
||||
"Physical",
|
||||
"Sync",
|
||||
"TCP/IP",
|
||||
"Timer",
|
||||
"Tun",
|
||||
|
@ -23,7 +23,7 @@
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $Id: log.h,v 1.22 1998/08/07 18:42:49 brian Exp $
|
||||
* $Id: log.h,v 1.23 1998/08/09 15:34:11 brian Exp $
|
||||
*/
|
||||
|
||||
#define LogMIN (1)
|
||||
@ -40,14 +40,16 @@
|
||||
#define LogLCP (11)
|
||||
#define LogLQM (12)
|
||||
#define LogPHASE (13)
|
||||
#define LogTCPIP (14)
|
||||
#define LogTIMER (15) /* syslog(LOG_DEBUG, ....) */
|
||||
#define LogTUN (16) /* If set, tun%d is output with each message */
|
||||
#define LogMAXCONF (16)
|
||||
#define LogWARN (17) /* Sent to VarTerm else syslog(LOG_WARNING, ) */
|
||||
#define LogERROR (18) /* syslog(LOG_ERR, ....), + sent to VarTerm */
|
||||
#define LogALERT (19) /* syslog(LOG_ALERT, ....) */
|
||||
#define LogMAX (19)
|
||||
#define LogPHYSICAL (14) /* syslog(LOG_INFO, ....) */
|
||||
#define LogSYNC (15) /* syslog(LOG_INFO, ....) */
|
||||
#define LogTCPIP (16)
|
||||
#define LogTIMER (17) /* syslog(LOG_DEBUG, ....) */
|
||||
#define LogTUN (18) /* If set, tun%d is output with each message */
|
||||
#define LogMAXCONF (18)
|
||||
#define LogWARN (19) /* Sent to VarTerm else syslog(LOG_WARNING, ) */
|
||||
#define LogERROR (20) /* syslog(LOG_ERR, ....), + sent to VarTerm */
|
||||
#define LogALERT (21) /* syslog(LOG_ALERT, ....) */
|
||||
#define LogMAX (21)
|
||||
|
||||
struct mbuf;
|
||||
struct cmdargs;
|
||||
|
@ -23,7 +23,7 @@
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $Id: mp.c,v 1.18 1999/01/28 01:56:33 brian Exp $
|
||||
* $Id: mp.c,v 1.19 1999/05/08 11:07:17 brian Exp $
|
||||
*/
|
||||
|
||||
#include <sys/param.h>
|
||||
@ -490,20 +490,9 @@ mp_Assemble(struct mp *mp, struct mbuf *m, struct physical *p)
|
||||
} while (!h.end);
|
||||
|
||||
if (q) {
|
||||
u_short proto;
|
||||
u_char ch;
|
||||
|
||||
q = mbuf_Read(q, &ch, 1);
|
||||
proto = ch;
|
||||
if (!(proto & 1)) {
|
||||
q = mbuf_Read(q, &ch, 1);
|
||||
proto <<= 8;
|
||||
proto += ch;
|
||||
}
|
||||
if (log_IsKept(LogDEBUG))
|
||||
log_Printf(LogDEBUG, "MP: Reassembled frags %ld-%lu, length %d\n",
|
||||
first, (u_long)h.seq, mbuf_Length(q));
|
||||
q = mbuf_Contiguous(q);
|
||||
log_Printf(LogDEBUG, "MP: Reassembled frags %ld-%lu, length %d\n",
|
||||
first, (u_long)h.seq, mbuf_Length(q));
|
||||
link_PullPacket(&mp->link, MBUF_CTOP(q), q->cnt, mp->bundle);
|
||||
}
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
* The code in this file was written by Eivind Eklund <perhaps@yes.no>,
|
||||
* who places it in the public domain without restriction.
|
||||
*
|
||||
* $Id: alias_cmd.c,v 1.23 1999/04/26 08:54:32 brian Exp $
|
||||
* $Id: alias_cmd.c,v 1.24 1999/05/08 11:05:59 brian Exp $
|
||||
*/
|
||||
|
||||
#include <sys/param.h>
|
||||
@ -328,7 +328,8 @@ alias_LayerPush(struct bundle *bundle, struct link *l, struct mbuf *bp,
|
||||
{
|
||||
if (!bundle->AliasEnabled || *proto != PROTO_IP)
|
||||
return bp;
|
||||
|
||||
|
||||
log_Printf(LogDEBUG, "alias_LayerPush: PROTO_IP -> PROTO_IP\n");
|
||||
bp = mbuf_Contiguous(alias_PadMbuf(bp, MB_IPQ));
|
||||
PacketAliasOut(MBUF_CTOP(bp), bp->cnt);
|
||||
bp->cnt = ntohs(((struct ip *)MBUF_CTOP(bp))->ip_len);
|
||||
@ -348,6 +349,7 @@ alias_LayerPull(struct bundle *bundle, struct link *l, struct mbuf *bp,
|
||||
if (!bundle->AliasEnabled || *proto != PROTO_IP)
|
||||
return bp;
|
||||
|
||||
log_Printf(LogDEBUG, "alias_LayerPull: PROTO_IP -> PROTO_IP\n");
|
||||
bp = mbuf_Contiguous(alias_PadMbuf(bp, MB_IPIN));
|
||||
pip = (struct ip *)MBUF_CTOP(bp);
|
||||
piip = (struct ip *)((char *)pip + (pip->ip_hl << 2));
|
||||
|
@ -16,7 +16,7 @@
|
||||
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* $Id: physical.c,v 1.9 1999/05/08 11:07:22 brian Exp $
|
||||
* $Id: physical.c,v 1.10 1999/05/09 20:13:51 brian Exp $
|
||||
*
|
||||
*/
|
||||
|
||||
@ -88,6 +88,7 @@
|
||||
#include "cbcp.h"
|
||||
#include "datalink.h"
|
||||
#include "tcp.h"
|
||||
#include "udp.h"
|
||||
#include "exec.h"
|
||||
#include "tty.h"
|
||||
|
||||
@ -97,11 +98,18 @@ static int physical_DescriptorWrite(struct descriptor *, struct bundle *,
|
||||
static void physical_DescriptorRead(struct descriptor *, struct bundle *,
|
||||
const fd_set *);
|
||||
|
||||
static const struct device *handlers[] = {
|
||||
&ttydevice, &tcpdevice, &execdevice
|
||||
struct {
|
||||
struct device *(*create)(struct physical *);
|
||||
struct device *(*iov2device)(int, struct physical *, struct iovec *iov,
|
||||
int *niov, int maxiov);
|
||||
} devices[] = {
|
||||
{ tty_Create, tty_iov2device },
|
||||
{ tcp_Create, tcp_iov2device },
|
||||
{ udp_Create, udp_iov2device },
|
||||
{ exec_Create, exec_iov2device }
|
||||
};
|
||||
|
||||
#define NHANDLERS (sizeof handlers / sizeof handlers[0])
|
||||
#define NDEVICES (sizeof devices / sizeof devices[0])
|
||||
|
||||
static int
|
||||
physical_UpdateSet(struct descriptor *d, fd_set *r, fd_set *w, fd_set *e,
|
||||
@ -129,7 +137,6 @@ physical_Create(struct datalink *dl, int type)
|
||||
memset(p->link.proto_out, '\0', sizeof p->link.proto_out);
|
||||
link_EmptyStack(&p->link);
|
||||
|
||||
memset(&p->Timer, '\0', sizeof p->Timer);
|
||||
p->handler = NULL;
|
||||
p->desc.type = PHYSICAL_DESCRIPTOR;
|
||||
p->desc.UpdateSet = physical_UpdateSet;
|
||||
@ -256,7 +263,7 @@ physical_ReallyClose(struct physical *p)
|
||||
|
||||
log_Printf(LogDEBUG, "%s: Really close %d\n", p->link.name, p->fd);
|
||||
if (p->fd >= 0) {
|
||||
timer_Stop(&p->Timer);
|
||||
physical_StopDeviceTimer(p);
|
||||
if (p->Utmp) {
|
||||
ID0logout(p->name.base);
|
||||
p->Utmp = 0;
|
||||
@ -273,8 +280,8 @@ physical_ReallyClose(struct physical *p)
|
||||
}
|
||||
if (newsid)
|
||||
bundle_setsid(p->dl->bundle, 0);
|
||||
if (p->handler && p->handler->postclose)
|
||||
(*p->handler->postclose)(p);
|
||||
if (p->handler && p->handler->destroy)
|
||||
(*p->handler->destroy)(p);
|
||||
p->handler = NULL;
|
||||
}
|
||||
*p->name.full = '\0';
|
||||
@ -441,7 +448,6 @@ physical_DescriptorRead(struct descriptor *d, struct bundle *bundle,
|
||||
return;
|
||||
}
|
||||
|
||||
log_DumpBuff(LogASYNC, "ReadFromModem", rbuff, n);
|
||||
rbuff -= p->input.sz;
|
||||
n += p->input.sz;
|
||||
|
||||
@ -475,12 +481,11 @@ iov2physical(struct datalink *dl, struct iovec *iov, int *niov, int maxiov,
|
||||
int fd)
|
||||
{
|
||||
struct physical *p;
|
||||
int len, h;
|
||||
int len, h, type;
|
||||
|
||||
p = (struct physical *)iov[(*niov)++].iov_base;
|
||||
p->link.name = dl->name;
|
||||
throughput_init(&p->link.throughput);
|
||||
memset(&p->Timer, '\0', sizeof p->Timer);
|
||||
memset(p->link.Queue, '\0', sizeof p->link.Queue);
|
||||
|
||||
p->desc.UpdateSet = physical_UpdateSet;
|
||||
@ -495,18 +500,6 @@ iov2physical(struct datalink *dl, struct iovec *iov, int *niov, int maxiov,
|
||||
p->out = NULL;
|
||||
p->connect_count = 1;
|
||||
|
||||
if (p->handler) {
|
||||
for (h = 0; h < NHANDLERS; h++)
|
||||
if (p->handler == (const struct device *)(long)handlers[h]->type) {
|
||||
p->handler = handlers[h];
|
||||
break;
|
||||
}
|
||||
if (h == NHANDLERS) {
|
||||
log_Printf(LogERROR, "iov2physical: Can't find device hander !\n");
|
||||
p->handler = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
p->link.lcp.fsm.bundle = dl->bundle;
|
||||
p->link.lcp.fsm.link = &p->link;
|
||||
memset(&p->link.lcp.fsm.FsmTimer, '\0', sizeof p->link.lcp.fsm.FsmTimer);
|
||||
@ -538,8 +531,13 @@ iov2physical(struct datalink *dl, struct iovec *iov, int *niov, int maxiov,
|
||||
|
||||
throughput_start(&p->link.throughput, "physical throughput",
|
||||
Enabled(dl->bundle, OPT_THROUGHPUT));
|
||||
if (p->handler && p->handler->restored)
|
||||
(*p->handler->restored)(p);
|
||||
|
||||
type = (long)p->handler;
|
||||
for (h = 0; h < NDEVICES && p->handler == NULL; h++)
|
||||
p->handler = (*devices[h].iov2device)(type, p, iov, niov, maxiov);
|
||||
|
||||
if (p->handler == NULL)
|
||||
physical_SetupStack(p, PHYSICAL_NOFORCE);
|
||||
|
||||
return p;
|
||||
}
|
||||
@ -557,12 +555,12 @@ physical2iov(struct physical *p, struct iovec *iov, int *niov, int maxiov,
|
||||
timer_Stop(&p->link.ccp.fsm.OpenTimer);
|
||||
timer_Stop(&p->link.lcp.fsm.StoppedTimer);
|
||||
timer_Stop(&p->link.ccp.fsm.StoppedTimer);
|
||||
if (p->handler)
|
||||
p->handler = (const struct device *)(long)p->handler->type;
|
||||
if (p->Timer.state != TIMER_STOPPED) {
|
||||
timer_Stop(&p->Timer);
|
||||
p->Timer.state = TIMER_RUNNING; /* Special - see iov2physical() */
|
||||
if (p->handler) {
|
||||
if (p->handler->device2iov)
|
||||
(*p->handler->device2iov)(p, iov, niov, maxiov, newpid);
|
||||
p->handler = (struct device *)(long)p->handler->type;
|
||||
}
|
||||
|
||||
if (tcgetpgrp(p->fd) == getpgrp())
|
||||
p->session_owner = getpid(); /* So I'll eventually get HUP'd */
|
||||
timer_Stop(&p->link.throughput.Timer);
|
||||
@ -633,18 +631,30 @@ physical_SetRtsCts(struct physical *p, int enable)
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Encapsulation for a read on the FD. Avoids some exposure, and
|
||||
concentrates control. */
|
||||
ssize_t
|
||||
physical_Read(struct physical *p, void *buf, size_t nbytes)
|
||||
{
|
||||
return read(p->fd, buf, nbytes);
|
||||
ssize_t ret;
|
||||
|
||||
if (p->handler && p->handler->read)
|
||||
ret = (*p->handler->read)(p, buf, nbytes);
|
||||
else
|
||||
ret = read(p->fd, buf, nbytes);
|
||||
|
||||
log_DumpBuff(LogPHYSICAL, "read", buf, ret);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
ssize_t
|
||||
physical_Write(struct physical *p, const void *buf, size_t nbytes)
|
||||
{
|
||||
return write(p->fd, buf, nbytes);
|
||||
log_DumpBuff(LogPHYSICAL, "write", buf, nbytes);
|
||||
|
||||
if (p->handler && p->handler->write)
|
||||
return (*p->handler->write)(p, buf, nbytes);
|
||||
|
||||
return write(p->fd, buf, nbytes);
|
||||
}
|
||||
|
||||
int
|
||||
@ -788,16 +798,17 @@ physical_Open(struct physical *p, struct bundle *bundle)
|
||||
log_Printf(LogDEBUG, "%s: Open: Modem is already open!\n", p->link.name);
|
||||
/* We're going back into "term" mode */
|
||||
else if (p->type == PHYS_DIRECT) {
|
||||
if (tty_OpenStdin(p)) {
|
||||
physical_SetDevice(p, "");
|
||||
p->fd = STDIN_FILENO;
|
||||
for (h = 0; h < NDEVICES && p->handler == NULL && p->fd >= 0; h++)
|
||||
p->handler = (*devices[h].create)(p);
|
||||
if (p->fd >= 0) {
|
||||
if (p->handler == NULL)
|
||||
physical_SetupStack(p, PHYSICAL_NOFORCE);
|
||||
physical_Found(p);
|
||||
p->handler = &ttydevice;
|
||||
} else {
|
||||
log_Printf(LogDEBUG, "%s: physical_Open: stdin is not a tty\n",
|
||||
p->link.name);
|
||||
physical_SetDevice(p, "");
|
||||
physical_SetupStack(p, 0);
|
||||
physical_Found(p);
|
||||
return p->fd = STDIN_FILENO;
|
||||
if (p->handler == NULL)
|
||||
log_Printf(LogDEBUG, "%s: stdin is unidentified\n",
|
||||
p->link.name);
|
||||
}
|
||||
} else {
|
||||
dev = p->cfg.devlist;
|
||||
@ -805,16 +816,18 @@ physical_Open(struct physical *p, struct bundle *bundle)
|
||||
while (devno < p->cfg.ndev && p->fd < 0) {
|
||||
physical_SetDevice(p, dev);
|
||||
|
||||
for (h = 0; h < NHANDLERS; h++)
|
||||
if (handlers[h]->open && (*handlers[h]->open)(p)) {
|
||||
p->handler = handlers[h];
|
||||
physical_Found(p);
|
||||
}
|
||||
if (*p->name.full == '/')
|
||||
p->fd = ID0open(p->name.full, O_RDWR | O_NONBLOCK);
|
||||
|
||||
for (h = 0; h < NDEVICES && p->handler == NULL; h++)
|
||||
p->handler = (*devices[h].create)(p);
|
||||
|
||||
if (p->fd < 0)
|
||||
log_Printf(LogWARN, "%s: Device (%s) must begin with a '/',"
|
||||
" a '!' or be a host:port pair\n", p->link.name,
|
||||
p->name.full);
|
||||
else
|
||||
physical_Found(p);
|
||||
dev += strlen(dev) + 1;
|
||||
devno++;
|
||||
}
|
||||
@ -824,10 +837,11 @@ physical_Open(struct physical *p, struct bundle *bundle)
|
||||
}
|
||||
|
||||
void
|
||||
physical_SetupStack(struct physical *p, int forceasync)
|
||||
physical_SetupStack(struct physical *p, int how)
|
||||
{
|
||||
link_EmptyStack(&p->link);
|
||||
if (!forceasync && physical_IsSync(p))
|
||||
if (how == PHYSICAL_FORCE_SYNC ||
|
||||
(how == PHYSICAL_NOFORCE && physical_IsSync(p)))
|
||||
link_Stack(&p->link, &synclayer);
|
||||
else {
|
||||
link_Stack(&p->link, &asynclayer);
|
||||
@ -841,7 +855,20 @@ physical_SetupStack(struct physical *p, int forceasync)
|
||||
#ifndef NOALIAS
|
||||
link_Stack(&p->link, &aliaslayer);
|
||||
#endif
|
||||
if (forceasync && physical_IsSync(p))
|
||||
if (how == PHYSICAL_FORCE_ASYNC && physical_IsSync(p)) {
|
||||
log_Printf(LogWARN, "Sync device setting ignored for ``%s'' device\n",
|
||||
p->handler ? p->handler->name : "unknown");
|
||||
p->cfg.speed = MODEM_SPEED;
|
||||
} else if (how == PHYSICAL_FORCE_SYNC && !physical_IsSync(p)) {
|
||||
log_Printf(LogWARN, "Async device setting ignored for ``%s'' device\n",
|
||||
p->handler ? p->handler->name : "unknown");
|
||||
physical_SetSync(p);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
physical_StopDeviceTimer(struct physical *p)
|
||||
{
|
||||
if (p->handler && p->handler->stoptimer)
|
||||
(*p->handler->stoptimer)(p);
|
||||
}
|
||||
|
@ -16,7 +16,7 @@
|
||||
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* $Id: physical.h,v 1.8 1999/04/27 00:23:57 brian Exp $
|
||||
* $Id: physical.h,v 1.9 1999/05/08 11:07:24 brian Exp $
|
||||
*
|
||||
*/
|
||||
|
||||
@ -30,17 +30,21 @@ struct cmdargs;
|
||||
|
||||
#define TTY_DEVICE 1
|
||||
#define TCP_DEVICE 2
|
||||
#define EXEC_DEVICE 3
|
||||
#define UDP_DEVICE 3
|
||||
#define EXEC_DEVICE 4
|
||||
|
||||
struct device {
|
||||
int type;
|
||||
const char *name;
|
||||
int (*open)(struct physical *);
|
||||
|
||||
int (*raw)(struct physical *);
|
||||
void (*offline)(struct physical *);
|
||||
void (*cooked)(struct physical *);
|
||||
void (*postclose)(struct physical *);
|
||||
void (*restored)(struct physical *);
|
||||
void (*stoptimer)(struct physical *);
|
||||
void (*destroy)(struct physical *);
|
||||
ssize_t (*read)(struct physical *, void *, size_t);
|
||||
ssize_t (*write)(struct physical *, const void *, size_t);
|
||||
void (*device2iov)(struct physical *, struct iovec *, int *, int, pid_t);
|
||||
int (*speed)(struct physical *);
|
||||
const char *(*openinfo)(struct physical *);
|
||||
};
|
||||
@ -52,7 +56,6 @@ struct physical {
|
||||
struct async async; /* Our async state */
|
||||
struct hdlc hdlc; /* Our hdlc state */
|
||||
int fd; /* File descriptor for this device */
|
||||
int mbits; /* Current DCD status */
|
||||
struct mbuf *out; /* mbuf that suffered a short write */
|
||||
int connect_count;
|
||||
struct datalink *dl; /* my owner */
|
||||
@ -67,9 +70,11 @@ struct physical {
|
||||
char *base;
|
||||
} name;
|
||||
|
||||
unsigned Utmp : 1; /* Are we in utmp ? */
|
||||
unsigned Utmp : 1; /* Are we in utmp ? (move to ttydevice ?) */
|
||||
pid_t session_owner; /* HUP this when closing the link */
|
||||
|
||||
struct device *handler; /* device specific handler */
|
||||
|
||||
struct {
|
||||
unsigned rts_cts : 1; /* Is rts/cts enabled ? */
|
||||
unsigned parity; /* What parity is enabled? (tty flags) */
|
||||
@ -82,12 +87,6 @@ struct physical {
|
||||
int delay; /* Wait this many seconds after login script */
|
||||
} cd;
|
||||
} cfg;
|
||||
|
||||
struct termios ios; /* To be able to reset from raw mode */
|
||||
|
||||
struct pppTimer Timer; /* CD checks */
|
||||
|
||||
const struct device *handler; /* device specific handlers */
|
||||
};
|
||||
|
||||
#define field2phys(fp, name) \
|
||||
@ -99,6 +98,10 @@ struct physical {
|
||||
#define descriptor2physical(d) \
|
||||
((d)->type == PHYSICAL_DESCRIPTOR ? field2phys(d, desc) : NULL)
|
||||
|
||||
#define PHYSICAL_NOFORCE 1
|
||||
#define PHYSICAL_FORCE_ASYNC 2
|
||||
#define PHYSICAL_FORCE_SYNC 3
|
||||
|
||||
extern struct physical *physical_Create(struct datalink *, int);
|
||||
extern int physical_Open(struct physical *, struct bundle *);
|
||||
extern int physical_Raw(struct physical *);
|
||||
@ -132,3 +135,4 @@ extern int physical_RemoveFromSet(struct physical *, fd_set *, fd_set *,
|
||||
extern int physical_SetMode(struct physical *, int);
|
||||
extern void physical_DeleteQueue(struct physical *);
|
||||
extern void physical_SetupStack(struct physical *, int);
|
||||
extern void physical_StopDeviceTimer(struct physical *);
|
||||
|
@ -1,4 +1,4 @@
|
||||
.\" $Id: ppp.8,v 1.166 1999/05/02 08:52:50 brian Exp $
|
||||
.\" $Id: ppp.8,v 1.167 1999/05/08 11:07:25 brian Exp $
|
||||
.Dd 20 September 1995
|
||||
.nr XX \w'\fC00'
|
||||
.Os FreeBSD
|
||||
@ -148,12 +148,15 @@ The user can use
|
||||
to check the packet flow over the
|
||||
.Em PPP
|
||||
link.
|
||||
.It Supports PPP over TCP capability.
|
||||
.It Supports PPP over TCP and PPP over UDP.
|
||||
If a device name is specified as
|
||||
.Em host Ns No : Ns Em port ,
|
||||
.Em host Ns No : Ns Em port Ns
|
||||
.Op / Ns Em tcp Ns No | Ns Em udp ,
|
||||
.Nm
|
||||
will open a TCP connection for transporting data rather than using a
|
||||
conventional serial device.
|
||||
will open a TCP or UDP connection for transporting data rather than using a
|
||||
conventional serial device. UDP connections force
|
||||
.Nm
|
||||
into synchronous mode.
|
||||
.It "Supports IETF draft Predictor-1 (rfc 1978) and DEFLATE (rfc 1979) compression."
|
||||
.Nm
|
||||
supports not only VJ-compression but also Predictor-1 and DEFLATE compression.
|
||||
@ -1202,14 +1205,14 @@ as if passed to the
|
||||
command. The value will be used in
|
||||
.Nm ppp Ns No s
|
||||
subsequent CBCP phase.
|
||||
.Sh PPP OVER TCP (a.k.a Tunnelling)
|
||||
.Sh PPP OVER TCP and UDP (a.k.a Tunnelling)
|
||||
Instead of running
|
||||
.Nm
|
||||
over a serial link, it is possible to
|
||||
use a TCP connection instead by specifying a host and port as the
|
||||
use a TCP connection instead by specifying the host, port and protocol as the
|
||||
device:
|
||||
.Pp
|
||||
.Dl set device ui-gate:6669
|
||||
.Dl set device ui-gate:6669/tcp
|
||||
.Pp
|
||||
Instead of opening a serial device,
|
||||
.Nm
|
||||
@ -1278,7 +1281,7 @@ on awfulhak (the initiator) should contain the following:
|
||||
.Bd -literal -offset indent
|
||||
ui-gate:
|
||||
set escape 0xff
|
||||
set device ui-gate:ppp-in
|
||||
set device ui-gate:ppp-in/tcp
|
||||
set dial
|
||||
set timeout 30
|
||||
set log Phase Chat Connect hdlc LCP IPCP CCP tun
|
||||
@ -1308,6 +1311,7 @@ Internet), and the
|
||||
traffic is conceptually encapsulated
|
||||
(although not packet by packet) inside the TCP stream between
|
||||
the two gateways.
|
||||
.Pp
|
||||
The major disadvantage of this mechanism is that there are two
|
||||
"guaranteed delivery" mechanisms in place - the underlying TCP
|
||||
stream and whatever protocol is used over the
|
||||
@ -1315,6 +1319,14 @@ stream and whatever protocol is used over the
|
||||
link - probably TCP again. If packets are lost, both levels will
|
||||
get in each others way trying to negotiate sending of the missing
|
||||
packet.
|
||||
.Pp
|
||||
To avoid this overhead, it is also possible to do all this using
|
||||
UDP instead of TCP as the transport by simply changing the protocol
|
||||
from "tcp" to "udp". When using UDP as a transport,
|
||||
.Nm
|
||||
will operate in synchronous mode. This is another gain as the incoming
|
||||
data does not have to be rearranged into packets.
|
||||
.Pp
|
||||
.Sh PACKET ALIASING
|
||||
The
|
||||
.Fl alias
|
||||
@ -1922,6 +1934,10 @@ Generate an LCP packet trace.
|
||||
Generate LQR reports.
|
||||
.It Li Phase
|
||||
Phase transition log output.
|
||||
.It Li Physical
|
||||
Dump physical level packet in hex.
|
||||
.It Li Sync
|
||||
Dump sync level packet in hex.
|
||||
.It Li TCP/IP
|
||||
Dump all TCP/IP packets.
|
||||
.It Li Timer
|
||||
@ -3508,15 +3524,16 @@ is opened. Standard input, output and error are fed back to
|
||||
and are read and written as if they were a regular device.
|
||||
.Pp
|
||||
If a
|
||||
.Dq host:port
|
||||
pair is given,
|
||||
.Dq host:port Ns Op /tcp|/udp
|
||||
specification is given,
|
||||
.Nm
|
||||
will attempt to connect to the given
|
||||
.Dq host
|
||||
on the given
|
||||
.Dq port .
|
||||
Refer to the section on
|
||||
.Em PPP OVER TCP
|
||||
If a tcp or udp specification is not given, the default is tcp. Refer to
|
||||
the section on
|
||||
.Em PPP OVER TCP and UDP
|
||||
above for further details.
|
||||
.Pp
|
||||
If multiple
|
||||
@ -3802,7 +3819,7 @@ and that number is not already in use,
|
||||
.Nm
|
||||
will grant the peers request. This is useful if the peer wants
|
||||
to re-establish a link using the same IP number as was previously
|
||||
allocated (thus maintaining any existing tcp connections).
|
||||
allocated (thus maintaining any existing tcp or udp connections).
|
||||
.Pp
|
||||
If the peer requests an IP number that's either outside
|
||||
of this range or is already in use,
|
||||
@ -4247,7 +4264,14 @@ can also be used, but link encryption may be implemented in the future, so
|
||||
.Xr telnet 1
|
||||
should not be relied upon.
|
||||
.It set speed Ar value
|
||||
This sets the speed of the serial device.
|
||||
This sets the speed of the serial device. If speed is specified as
|
||||
.Dq sync ,
|
||||
.Nm
|
||||
treats the device as a synchronous device.
|
||||
.Pp
|
||||
Certain device types will know whether they should be specified as
|
||||
synchronous or asynchronous. These devices will override incorrect
|
||||
settings and log a warning to this effect.
|
||||
.It set stopped Op Ar LCPseconds Op Ar CCPseconds
|
||||
If this option is set,
|
||||
.Nm
|
||||
|
@ -1,4 +1,4 @@
|
||||
.\" $Id: ppp.8,v 1.166 1999/05/02 08:52:50 brian Exp $
|
||||
.\" $Id: ppp.8,v 1.167 1999/05/08 11:07:25 brian Exp $
|
||||
.Dd 20 September 1995
|
||||
.nr XX \w'\fC00'
|
||||
.Os FreeBSD
|
||||
@ -148,12 +148,15 @@ The user can use
|
||||
to check the packet flow over the
|
||||
.Em PPP
|
||||
link.
|
||||
.It Supports PPP over TCP capability.
|
||||
.It Supports PPP over TCP and PPP over UDP.
|
||||
If a device name is specified as
|
||||
.Em host Ns No : Ns Em port ,
|
||||
.Em host Ns No : Ns Em port Ns
|
||||
.Op / Ns Em tcp Ns No | Ns Em udp ,
|
||||
.Nm
|
||||
will open a TCP connection for transporting data rather than using a
|
||||
conventional serial device.
|
||||
will open a TCP or UDP connection for transporting data rather than using a
|
||||
conventional serial device. UDP connections force
|
||||
.Nm
|
||||
into synchronous mode.
|
||||
.It "Supports IETF draft Predictor-1 (rfc 1978) and DEFLATE (rfc 1979) compression."
|
||||
.Nm
|
||||
supports not only VJ-compression but also Predictor-1 and DEFLATE compression.
|
||||
@ -1202,14 +1205,14 @@ as if passed to the
|
||||
command. The value will be used in
|
||||
.Nm ppp Ns No s
|
||||
subsequent CBCP phase.
|
||||
.Sh PPP OVER TCP (a.k.a Tunnelling)
|
||||
.Sh PPP OVER TCP and UDP (a.k.a Tunnelling)
|
||||
Instead of running
|
||||
.Nm
|
||||
over a serial link, it is possible to
|
||||
use a TCP connection instead by specifying a host and port as the
|
||||
use a TCP connection instead by specifying the host, port and protocol as the
|
||||
device:
|
||||
.Pp
|
||||
.Dl set device ui-gate:6669
|
||||
.Dl set device ui-gate:6669/tcp
|
||||
.Pp
|
||||
Instead of opening a serial device,
|
||||
.Nm
|
||||
@ -1278,7 +1281,7 @@ on awfulhak (the initiator) should contain the following:
|
||||
.Bd -literal -offset indent
|
||||
ui-gate:
|
||||
set escape 0xff
|
||||
set device ui-gate:ppp-in
|
||||
set device ui-gate:ppp-in/tcp
|
||||
set dial
|
||||
set timeout 30
|
||||
set log Phase Chat Connect hdlc LCP IPCP CCP tun
|
||||
@ -1308,6 +1311,7 @@ Internet), and the
|
||||
traffic is conceptually encapsulated
|
||||
(although not packet by packet) inside the TCP stream between
|
||||
the two gateways.
|
||||
.Pp
|
||||
The major disadvantage of this mechanism is that there are two
|
||||
"guaranteed delivery" mechanisms in place - the underlying TCP
|
||||
stream and whatever protocol is used over the
|
||||
@ -1315,6 +1319,14 @@ stream and whatever protocol is used over the
|
||||
link - probably TCP again. If packets are lost, both levels will
|
||||
get in each others way trying to negotiate sending of the missing
|
||||
packet.
|
||||
.Pp
|
||||
To avoid this overhead, it is also possible to do all this using
|
||||
UDP instead of TCP as the transport by simply changing the protocol
|
||||
from "tcp" to "udp". When using UDP as a transport,
|
||||
.Nm
|
||||
will operate in synchronous mode. This is another gain as the incoming
|
||||
data does not have to be rearranged into packets.
|
||||
.Pp
|
||||
.Sh PACKET ALIASING
|
||||
The
|
||||
.Fl alias
|
||||
@ -1922,6 +1934,10 @@ Generate an LCP packet trace.
|
||||
Generate LQR reports.
|
||||
.It Li Phase
|
||||
Phase transition log output.
|
||||
.It Li Physical
|
||||
Dump physical level packet in hex.
|
||||
.It Li Sync
|
||||
Dump sync level packet in hex.
|
||||
.It Li TCP/IP
|
||||
Dump all TCP/IP packets.
|
||||
.It Li Timer
|
||||
@ -3508,15 +3524,16 @@ is opened. Standard input, output and error are fed back to
|
||||
and are read and written as if they were a regular device.
|
||||
.Pp
|
||||
If a
|
||||
.Dq host:port
|
||||
pair is given,
|
||||
.Dq host:port Ns Op /tcp|/udp
|
||||
specification is given,
|
||||
.Nm
|
||||
will attempt to connect to the given
|
||||
.Dq host
|
||||
on the given
|
||||
.Dq port .
|
||||
Refer to the section on
|
||||
.Em PPP OVER TCP
|
||||
If a tcp or udp specification is not given, the default is tcp. Refer to
|
||||
the section on
|
||||
.Em PPP OVER TCP and UDP
|
||||
above for further details.
|
||||
.Pp
|
||||
If multiple
|
||||
@ -3802,7 +3819,7 @@ and that number is not already in use,
|
||||
.Nm
|
||||
will grant the peers request. This is useful if the peer wants
|
||||
to re-establish a link using the same IP number as was previously
|
||||
allocated (thus maintaining any existing tcp connections).
|
||||
allocated (thus maintaining any existing tcp or udp connections).
|
||||
.Pp
|
||||
If the peer requests an IP number that's either outside
|
||||
of this range or is already in use,
|
||||
@ -4247,7 +4264,14 @@ can also be used, but link encryption may be implemented in the future, so
|
||||
.Xr telnet 1
|
||||
should not be relied upon.
|
||||
.It set speed Ar value
|
||||
This sets the speed of the serial device.
|
||||
This sets the speed of the serial device. If speed is specified as
|
||||
.Dq sync ,
|
||||
.Nm
|
||||
treats the device as a synchronous device.
|
||||
.Pp
|
||||
Certain device types will know whether they should be specified as
|
||||
synchronous or asynchronous. These devices will override incorrect
|
||||
settings and log a warning to this effect.
|
||||
.It set stopped Op Ar LCPseconds Op Ar CCPseconds
|
||||
If this option is set,
|
||||
.Nm
|
||||
|
@ -23,7 +23,7 @@
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $Id:$
|
||||
* $Id: proto.c,v 1.1 1999/05/08 11:07:32 brian Exp $
|
||||
*/
|
||||
|
||||
#include <sys/types.h>
|
||||
@ -34,6 +34,7 @@
|
||||
#include "layer.h"
|
||||
#include "acf.h"
|
||||
#include "defs.h"
|
||||
#include "log.h"
|
||||
#include "timer.h"
|
||||
#include "fsm.h"
|
||||
#include "mbuf.h"
|
||||
@ -71,6 +72,7 @@ static struct mbuf *
|
||||
proto_LayerPush(struct bundle *b, struct link *l, struct mbuf *bp,
|
||||
int pri, u_short *proto)
|
||||
{
|
||||
log_Printf(LogDEBUG, "proto_LayerPush: Using 0x%04x\n", *proto);
|
||||
bp = proto_Prepend(bp, *proto, l->lcp.his_protocomp,
|
||||
acf_WrapperOctets(&l->lcp, *proto));
|
||||
link_ProtocolRecord(l, *proto, PROTO_OUT);
|
||||
@ -101,6 +103,8 @@ proto_LayerPull(struct bundle *b, struct link *l, struct mbuf *bp,
|
||||
} else
|
||||
bp = mbuf_Read(bp, cp, 1);
|
||||
|
||||
log_Printf(LogDEBUG, "proto_LayerPull: unknown -> 0x%04x\n", *proto);
|
||||
|
||||
link_ProtocolRecord(l, *proto, PROTO_IN);
|
||||
|
||||
return bp;
|
||||
|
@ -23,7 +23,7 @@
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $Id:$
|
||||
* $Id: sync.c,v 1.1 1999/05/08 11:07:40 brian Exp $
|
||||
*/
|
||||
|
||||
#include <sys/types.h>
|
||||
@ -48,6 +48,14 @@
|
||||
#include "descriptor.h"
|
||||
#include "physical.h"
|
||||
|
||||
static struct mbuf *
|
||||
async_LayerPush(struct bundle *bundle, struct link *l, struct mbuf *bp,
|
||||
int pri, u_short *proto)
|
||||
{
|
||||
log_DumpBp(LogSYNC, "Write", bp);
|
||||
return bp;
|
||||
}
|
||||
|
||||
static struct mbuf *
|
||||
sync_LayerPull(struct bundle *b, struct link *l, struct mbuf *bp,
|
||||
u_short *proto)
|
||||
@ -57,7 +65,9 @@ sync_LayerPull(struct bundle *b, struct link *l, struct mbuf *bp,
|
||||
if (!p)
|
||||
log_Printf(LogERROR, "Can't Pull a sync packet from a logical link\n");
|
||||
else {
|
||||
/* Normally done by the HDLC layer */
|
||||
log_DumpBp(LogSYNC, "Read", bp);
|
||||
|
||||
/* Either done here or by the HDLC layer */
|
||||
p->hdlc.lqm.SaveInOctets += mbuf_Length(bp) + 1;
|
||||
p->hdlc.lqm.SaveInPackets++;
|
||||
}
|
||||
|
@ -23,7 +23,7 @@
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $Id:$
|
||||
* $Id: tcp.c,v 1.1 1999/05/08 11:07:45 brian Exp $
|
||||
*/
|
||||
|
||||
#include <sys/types.h>
|
||||
@ -58,7 +58,7 @@
|
||||
#include "tcp.h"
|
||||
|
||||
static int
|
||||
OpenConnection(const char *name, char *host, char *port)
|
||||
tcp_OpenConnection(const char *name, char *host, char *port)
|
||||
{
|
||||
struct sockaddr_in dest;
|
||||
int sock;
|
||||
@ -69,61 +69,39 @@ OpenConnection(const char *name, char *host, char *port)
|
||||
dest.sin_addr = GetIpAddr(host);
|
||||
if (dest.sin_addr.s_addr == INADDR_NONE) {
|
||||
log_Printf(LogWARN, "%s: %s: unknown host\n", name, host);
|
||||
return (-1);
|
||||
return -1;
|
||||
}
|
||||
dest.sin_port = htons(atoi(port));
|
||||
if (dest.sin_port == 0) {
|
||||
sp = getservbyname(port, "tcp");
|
||||
if (sp) {
|
||||
if (sp)
|
||||
dest.sin_port = sp->s_port;
|
||||
} else {
|
||||
else {
|
||||
log_Printf(LogWARN, "%s: %s: unknown service\n", name, port);
|
||||
return (-1);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
log_Printf(LogPHASE, "%s: Connecting to %s:%s\n", name, host, port);
|
||||
log_Printf(LogPHASE, "%s: Connecting to %s:%s/tcp\n", name, host, port);
|
||||
|
||||
sock = socket(PF_INET, SOCK_STREAM, 0);
|
||||
if (sock < 0) {
|
||||
return (sock);
|
||||
}
|
||||
if (sock < 0)
|
||||
return sock;
|
||||
|
||||
if (connect(sock, (struct sockaddr *)&dest, sizeof dest) < 0) {
|
||||
log_Printf(LogWARN, "%s: connect: %s\n", name, strerror(errno));
|
||||
close(sock);
|
||||
return (-1);
|
||||
}
|
||||
return (sock);
|
||||
}
|
||||
|
||||
static int
|
||||
tcp_Open(struct physical *p)
|
||||
{
|
||||
char *cp, *host, *port;
|
||||
|
||||
if ((cp = strchr(p->name.full, ':')) != NULL) {
|
||||
*cp = '\0';
|
||||
host = p->name.full;
|
||||
port = cp + 1;
|
||||
if (*host && *port) {
|
||||
p->fd = OpenConnection(p->link.name, host, port);
|
||||
*cp = ':'; /* Don't destroy name.full */
|
||||
if (p->fd >= 0) {
|
||||
log_Printf(LogDEBUG, "%s: Opened socket %s\n", p->link.name,
|
||||
p->name.full);
|
||||
physical_SetupStack(p, 1);
|
||||
return 1;
|
||||
}
|
||||
} else
|
||||
*cp = ':'; /* Don't destroy name.full */
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return sock;
|
||||
}
|
||||
|
||||
const struct device tcpdevice = {
|
||||
TTY_DEVICE,
|
||||
static struct device tcpdevice = {
|
||||
TCP_DEVICE,
|
||||
"tcp",
|
||||
tcp_Open,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
@ -132,3 +110,79 @@ const struct device tcpdevice = {
|
||||
NULL,
|
||||
NULL
|
||||
};
|
||||
|
||||
struct device *
|
||||
tcp_iov2device(int type, struct physical *p, struct iovec *iov,
|
||||
int *niov, int maxiov)
|
||||
{
|
||||
if (type == TCP_DEVICE)
|
||||
return &tcpdevice;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
struct device *
|
||||
tcp_Create(struct physical *p)
|
||||
{
|
||||
char *cp, *host, *port, *svc;
|
||||
|
||||
if (p->fd < 0) {
|
||||
if ((cp = strchr(p->name.full, ':')) != NULL) {
|
||||
*cp = '\0';
|
||||
host = p->name.full;
|
||||
port = cp + 1;
|
||||
svc = strchr(port, '/');
|
||||
if (svc && strcasecmp(svc, "/tcp")) {
|
||||
*cp = ':';
|
||||
return 0;
|
||||
}
|
||||
if (svc)
|
||||
*svc = '\0';
|
||||
if (*host && *port) {
|
||||
p->fd = tcp_OpenConnection(p->link.name, host, port);
|
||||
*cp = ':';
|
||||
if (svc)
|
||||
*svc = '/';
|
||||
if (p->fd >= 0)
|
||||
log_Printf(LogDEBUG, "%s: Opened tcp socket %s\n", p->link.name,
|
||||
p->name.full);
|
||||
} else {
|
||||
if (svc)
|
||||
*svc = '/';
|
||||
*cp = ':';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (p->fd >= 0) {
|
||||
/* See if we're a tcp socket */
|
||||
int type, sz, err;
|
||||
|
||||
sz = sizeof type;
|
||||
if ((err = getsockopt(p->fd, SOL_SOCKET, SO_TYPE, &type, &sz)) == 0 &&
|
||||
sz == sizeof type && type == SOCK_STREAM) {
|
||||
struct sockaddr_in sock;
|
||||
struct sockaddr *sockp = (struct sockaddr *)&sock;
|
||||
|
||||
if (*p->name.full == '\0') {
|
||||
sz = sizeof sock;
|
||||
if (getpeername(p->fd, sockp, &sz) != 0 ||
|
||||
sz != sizeof(struct sockaddr_in) || sock.sin_family != AF_INET) {
|
||||
log_Printf(LogDEBUG, "%s: Link is SOCK_STREAM, but not inet\n",
|
||||
p->link.name);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
log_Printf(LogPHASE, "%s: Link is a tcp socket\n", p->link.name);
|
||||
|
||||
snprintf(p->name.full, sizeof p->name.full, "%s:%d/tcp",
|
||||
inet_ntoa(sock.sin_addr), ntohs(sock.sin_port));
|
||||
p->name.base = p->name.full;
|
||||
}
|
||||
physical_SetupStack(p, PHYSICAL_FORCE_ASYNC);
|
||||
return &tcpdevice;
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
@ -23,7 +23,11 @@
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $Id:$
|
||||
* $Id: tcp.h,v 1.1 1999/05/08 11:07:45 brian Exp $
|
||||
*/
|
||||
|
||||
extern const struct device tcpdevice;
|
||||
struct physical;
|
||||
|
||||
extern struct device *tcp_Create(struct physical *);
|
||||
extern struct device *tcp_iov2device(int, struct physical *,
|
||||
struct iovec *, int *, int);
|
||||
|
@ -23,7 +23,7 @@
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $Id:$
|
||||
* $Id: tty.c,v 1.1 1999/05/08 11:07:50 brian Exp $
|
||||
*/
|
||||
|
||||
#include <sys/param.h>
|
||||
@ -48,6 +48,7 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <sys/wait.h>
|
||||
#include <sys/uio.h>
|
||||
#include <termios.h>
|
||||
#include <unistd.h>
|
||||
|
||||
@ -86,7 +87,16 @@
|
||||
#include "datalink.h"
|
||||
#include "tty.h"
|
||||
|
||||
#define Online(p) ((p)->mbits & TIOCM_CD)
|
||||
#define Online(dev) ((dev)->mbits & TIOCM_CD)
|
||||
|
||||
struct ttydevice {
|
||||
struct device dev; /* What struct physical knows about */
|
||||
struct pppTimer Timer; /* CD checks */
|
||||
int mbits; /* Current DCD status */
|
||||
struct termios ios; /* To be able to reset from raw mode */
|
||||
};
|
||||
|
||||
#define device2tty(d) ((d)->type == TTY_DEVICE ? (struct ttydevice *)d : NULL)
|
||||
|
||||
static int
|
||||
tty_Lock(struct physical *p, int tunno)
|
||||
@ -147,11 +157,12 @@ tty_Unlock(struct physical *p)
|
||||
static void
|
||||
tty_SetupDevice(struct physical *p)
|
||||
{
|
||||
struct ttydevice *dev = device2tty(p->handler);
|
||||
struct termios rstio;
|
||||
int oldflag;
|
||||
|
||||
tcgetattr(p->fd, &rstio);
|
||||
p->ios = rstio;
|
||||
dev->ios = rstio;
|
||||
|
||||
log_Printf(LogDEBUG, "%s: tty_SetupDevice: physical (get): fd = %d,"
|
||||
" iflag = %lx, oflag = %lx, cflag = %lx\n", p->link.name, p->fd,
|
||||
@ -182,17 +193,17 @@ tty_SetupDevice(struct physical *p)
|
||||
"cflag = %lx\n", p->link.name, (u_long)rstio.c_iflag,
|
||||
(u_long)rstio.c_oflag, (u_long)rstio.c_cflag);
|
||||
|
||||
if (ioctl(p->fd, TIOCMGET, &p->mbits) == -1) {
|
||||
if (ioctl(p->fd, TIOCMGET, &dev->mbits) == -1) {
|
||||
if (p->type != PHYS_DIRECT) {
|
||||
log_Printf(LogWARN, "%s: Open: Cannot get physical status: %s\n",
|
||||
p->link.name, strerror(errno));
|
||||
physical_Close(p);
|
||||
return;
|
||||
} else
|
||||
p->mbits = TIOCM_CD;
|
||||
dev->mbits = TIOCM_CD;
|
||||
}
|
||||
log_Printf(LogDEBUG, "%s: Open: physical control = %o\n",
|
||||
p->link.name, p->mbits);
|
||||
p->link.name, dev->mbits);
|
||||
|
||||
oldflag = fcntl(p->fd, F_GETFL, 0);
|
||||
if (oldflag < 0) {
|
||||
@ -203,52 +214,7 @@ tty_SetupDevice(struct physical *p)
|
||||
} else
|
||||
fcntl(p->fd, F_SETFL, oldflag & ~O_NONBLOCK);
|
||||
|
||||
physical_SetupStack(p, 0);
|
||||
}
|
||||
|
||||
static int
|
||||
tty_Open(struct physical *p)
|
||||
{
|
||||
if (*p->name.full == '/') {
|
||||
p->mbits = 0;
|
||||
if (tty_Lock(p, p->dl->bundle->unit) != -1) {
|
||||
p->fd = ID0open(p->name.full, O_RDWR | O_NONBLOCK);
|
||||
if (p->fd < 0) {
|
||||
log_Printf(LogPHASE, "%s: Open(\"%s\"): %s\n",
|
||||
p->link.name, p->name.full, strerror(errno));
|
||||
tty_Unlock(p);
|
||||
} else if (!isatty(p->fd)) {
|
||||
log_Printf(LogPHASE, "%s: Open(\"%s\"): Not a tty\n",
|
||||
p->link.name, p->name.full);
|
||||
close(p->fd);
|
||||
p->fd = -1;
|
||||
tty_Unlock(p);
|
||||
} else {
|
||||
log_Printf(LogDEBUG, "%s: Opened %s\n", p->link.name, p->name.full);
|
||||
tty_SetupDevice(p);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return p->fd >= 0;
|
||||
}
|
||||
|
||||
int
|
||||
tty_OpenStdin(struct physical *p)
|
||||
{
|
||||
if (isatty(STDIN_FILENO)) {
|
||||
p->mbits = 0;
|
||||
log_Printf(LogDEBUG, "%s: tty_Open: stdin is a tty\n", p->link.name);
|
||||
physical_SetDevice(p, ttyname(STDIN_FILENO));
|
||||
if (tty_Lock(p, p->dl->bundle->unit) == -1)
|
||||
close(STDIN_FILENO);
|
||||
else {
|
||||
p->fd = STDIN_FILENO;
|
||||
tty_SetupDevice(p);
|
||||
}
|
||||
}
|
||||
|
||||
return p->fd >= 0;
|
||||
physical_SetupStack(p, PHYSICAL_NOFORCE);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -259,27 +225,28 @@ static void
|
||||
tty_Timeout(void *data)
|
||||
{
|
||||
struct physical *p = data;
|
||||
struct ttydevice *dev = device2tty(p->handler);
|
||||
int ombits, change;
|
||||
|
||||
timer_Stop(&p->Timer);
|
||||
p->Timer.load = SECTICKS; /* Once a second please */
|
||||
timer_Start(&p->Timer);
|
||||
ombits = p->mbits;
|
||||
timer_Stop(&dev->Timer);
|
||||
dev->Timer.load = SECTICKS; /* Once a second please */
|
||||
timer_Start(&dev->Timer);
|
||||
ombits = dev->mbits;
|
||||
|
||||
if (p->fd >= 0) {
|
||||
if (ioctl(p->fd, TIOCMGET, &p->mbits) < 0) {
|
||||
if (ioctl(p->fd, TIOCMGET, &dev->mbits) < 0) {
|
||||
log_Printf(LogPHASE, "%s: ioctl error (%s)!\n", p->link.name,
|
||||
strerror(errno));
|
||||
datalink_Down(p->dl, CLOSE_NORMAL);
|
||||
timer_Stop(&p->Timer);
|
||||
timer_Stop(&dev->Timer);
|
||||
return;
|
||||
}
|
||||
} else
|
||||
p->mbits = 0;
|
||||
dev->mbits = 0;
|
||||
|
||||
if (ombits == -1) {
|
||||
/* First time looking for carrier */
|
||||
if (Online(p))
|
||||
if (Online(dev))
|
||||
log_Printf(LogDEBUG, "%s: %s: CD detected\n", p->link.name, p->name.full);
|
||||
else if (p->cfg.cd.required) {
|
||||
log_Printf(LogPHASE, "%s: %s: Required CD not detected\n",
|
||||
@ -288,43 +255,46 @@ tty_Timeout(void *data)
|
||||
} else {
|
||||
log_Printf(LogPHASE, "%s: %s doesn't support CD\n",
|
||||
p->link.name, p->name.full);
|
||||
timer_Stop(&p->Timer);
|
||||
p->mbits = TIOCM_CD;
|
||||
timer_Stop(&dev->Timer);
|
||||
dev->mbits = TIOCM_CD;
|
||||
}
|
||||
} else {
|
||||
change = ombits ^ p->mbits;
|
||||
change = ombits ^ dev->mbits;
|
||||
if (change & TIOCM_CD) {
|
||||
if (p->mbits & TIOCM_CD)
|
||||
if (dev->mbits & TIOCM_CD)
|
||||
log_Printf(LogDEBUG, "%s: offline -> online\n", p->link.name);
|
||||
else {
|
||||
log_Printf(LogDEBUG, "%s: online -> offline\n", p->link.name);
|
||||
log_Printf(LogPHASE, "%s: Carrier lost\n", p->link.name);
|
||||
datalink_Down(p->dl, CLOSE_NORMAL);
|
||||
timer_Stop(&p->Timer);
|
||||
timer_Stop(&dev->Timer);
|
||||
}
|
||||
} else
|
||||
log_Printf(LogDEBUG, "%s: Still %sline\n", p->link.name,
|
||||
Online(p) ? "on" : "off");
|
||||
Online(dev) ? "on" : "off");
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
tty_StartTimer(struct physical *p)
|
||||
{
|
||||
timer_Stop(&p->Timer);
|
||||
p->Timer.load = SECTICKS * p->cfg.cd.delay;
|
||||
p->Timer.func = tty_Timeout;
|
||||
p->Timer.name = "tty CD";
|
||||
p->Timer.arg = p;
|
||||
struct ttydevice *dev = device2tty(p->handler);
|
||||
|
||||
timer_Stop(&dev->Timer);
|
||||
dev->Timer.load = SECTICKS * p->cfg.cd.delay;
|
||||
dev->Timer.func = tty_Timeout;
|
||||
dev->Timer.name = "tty CD";
|
||||
dev->Timer.arg = p;
|
||||
log_Printf(LogDEBUG, "%s: Using tty_Timeout [%p]\n",
|
||||
p->link.name, tty_Timeout);
|
||||
p->mbits = -1; /* So we know it's the first time */
|
||||
timer_Start(&p->Timer);
|
||||
dev->mbits = -1; /* So we know it's the first time */
|
||||
timer_Start(&dev->Timer);
|
||||
}
|
||||
|
||||
static int
|
||||
tty_Raw(struct physical *p)
|
||||
{
|
||||
struct ttydevice *dev = device2tty(p->handler);
|
||||
struct termios rstio;
|
||||
int oldflag;
|
||||
|
||||
@ -333,9 +303,9 @@ tty_Raw(struct physical *p)
|
||||
|
||||
log_Printf(LogDEBUG, "%s: Entering physical_Raw\n", p->link.name);
|
||||
|
||||
if (p->type != PHYS_DIRECT && p->fd >= 0 && !Online(p))
|
||||
if (p->type != PHYS_DIRECT && p->fd >= 0 && !Online(dev))
|
||||
log_Printf(LogDEBUG, "%s: Raw: descriptor = %d, mbits = %x\n",
|
||||
p->link.name, p->fd, p->mbits);
|
||||
p->link.name, p->fd, dev->mbits);
|
||||
|
||||
tcgetattr(p->fd, &rstio);
|
||||
cfmakeraw(&rstio);
|
||||
@ -354,7 +324,7 @@ tty_Raw(struct physical *p)
|
||||
return 0;
|
||||
fcntl(p->fd, F_SETFL, oldflag | O_NONBLOCK);
|
||||
|
||||
if (ioctl(p->fd, TIOCMGET, &p->mbits) == 0)
|
||||
if (ioctl(p->fd, TIOCMGET, &dev->mbits) == 0)
|
||||
tty_StartTimer(p);
|
||||
|
||||
return 1;
|
||||
@ -363,10 +333,12 @@ tty_Raw(struct physical *p)
|
||||
static void
|
||||
tty_Offline(struct physical *p)
|
||||
{
|
||||
struct ttydevice *dev = device2tty(p->handler);
|
||||
|
||||
if (p->fd >= 0) {
|
||||
timer_Stop(&p->Timer);
|
||||
p->mbits &= ~TIOCM_DTR;
|
||||
if (Online(p)) {
|
||||
timer_Stop(&dev->Timer);
|
||||
dev->mbits &= ~TIOCM_DTR;
|
||||
if (Online(dev)) {
|
||||
struct termios tio;
|
||||
|
||||
tcgetattr(p->fd, &tio);
|
||||
@ -382,11 +354,12 @@ tty_Offline(struct physical *p)
|
||||
static void
|
||||
tty_Cooked(struct physical *p)
|
||||
{
|
||||
struct ttydevice *dev = device2tty(p->handler);
|
||||
int oldflag;
|
||||
|
||||
tcflush(p->fd, TCIOFLUSH);
|
||||
if (!physical_IsSync(p)) {
|
||||
tcsetattr(p->fd, TCSAFLUSH, &p->ios);
|
||||
tcsetattr(p->fd, TCSAFLUSH, &dev->ios);
|
||||
oldflag = fcntl(p->fd, F_GETFL, 0);
|
||||
if (oldflag == 0)
|
||||
fcntl(p->fd, F_SETFL, oldflag & ~O_NONBLOCK);
|
||||
@ -394,18 +367,20 @@ tty_Cooked(struct physical *p)
|
||||
}
|
||||
|
||||
static void
|
||||
tty_Close(struct physical *p)
|
||||
tty_StopTimer(struct physical *p)
|
||||
{
|
||||
tty_Unlock(p);
|
||||
struct ttydevice *dev = device2tty(p->handler);
|
||||
|
||||
timer_Stop(&dev->Timer);
|
||||
}
|
||||
|
||||
static void
|
||||
tty_Restored(struct physical *p)
|
||||
tty_Free(struct physical *p)
|
||||
{
|
||||
if (p->Timer.state != TIMER_STOPPED) {
|
||||
p->Timer.state = TIMER_STOPPED; /* Special - see physical2iov() */
|
||||
tty_StartTimer(p);
|
||||
}
|
||||
struct ttydevice *dev = device2tty(p->handler);
|
||||
|
||||
tty_Unlock(p);
|
||||
free(dev);
|
||||
}
|
||||
|
||||
static int
|
||||
@ -422,9 +397,10 @@ tty_Speed(struct physical *p)
|
||||
static const char *
|
||||
tty_OpenInfo(struct physical *p)
|
||||
{
|
||||
struct ttydevice *dev = device2tty(p->handler);
|
||||
static char buf[13];
|
||||
|
||||
if (Online(p))
|
||||
if (Online(dev))
|
||||
strcpy(buf, "with");
|
||||
else
|
||||
strcpy(buf, "no");
|
||||
@ -432,15 +408,89 @@ tty_OpenInfo(struct physical *p)
|
||||
return buf;
|
||||
}
|
||||
|
||||
const struct device ttydevice = {
|
||||
static void
|
||||
tty_device2iov(struct physical *p, struct iovec *iov, int *niov,
|
||||
int maxiov, pid_t newpid)
|
||||
{
|
||||
struct ttydevice *dev = p ? device2tty(p->handler) : NULL;
|
||||
|
||||
iov[*niov].iov_base = p ? p->handler : malloc(sizeof(struct ttydevice));
|
||||
iov[*niov].iov_len = sizeof(struct ttydevice);
|
||||
(*niov)++;
|
||||
|
||||
if (dev->Timer.state != TIMER_STOPPED) {
|
||||
timer_Stop(&dev->Timer);
|
||||
dev->Timer.state = TIMER_RUNNING;
|
||||
}
|
||||
}
|
||||
|
||||
static struct device basettydevice = {
|
||||
TTY_DEVICE,
|
||||
"tty",
|
||||
tty_Open,
|
||||
tty_Raw,
|
||||
tty_Offline,
|
||||
tty_Cooked,
|
||||
tty_Close,
|
||||
tty_Restored,
|
||||
tty_StopTimer,
|
||||
tty_Free,
|
||||
NULL,
|
||||
NULL,
|
||||
tty_device2iov,
|
||||
tty_Speed,
|
||||
tty_OpenInfo
|
||||
};
|
||||
|
||||
struct device *
|
||||
tty_iov2device(int type, struct physical *p, struct iovec *iov, int *niov,
|
||||
int maxiov)
|
||||
{
|
||||
if (type == TTY_DEVICE) {
|
||||
struct ttydevice *dev;
|
||||
|
||||
/* It's one of ours ! Let's create the device */
|
||||
|
||||
dev = (struct ttydevice *)iov[(*niov)++].iov_base;
|
||||
/* Refresh function pointers etc */
|
||||
memcpy(&dev->dev, &basettydevice, sizeof dev->dev);
|
||||
|
||||
physical_SetupStack(p, PHYSICAL_NOFORCE);
|
||||
if (dev->Timer.state != TIMER_STOPPED) {
|
||||
dev->Timer.state = TIMER_STOPPED;
|
||||
tty_StartTimer(p);
|
||||
}
|
||||
return &dev->dev;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
struct device *
|
||||
tty_Create(struct physical *p)
|
||||
{
|
||||
if (p->fd >= 0 && isatty(p->fd)) {
|
||||
if (*p->name.full == '\0') {
|
||||
log_Printf(LogDEBUG, "%s: Input is a tty\n", p->link.name);
|
||||
physical_SetDevice(p, ttyname(p->fd));
|
||||
if (tty_Lock(p, p->dl->bundle->unit) == -1) {
|
||||
close(p->fd);
|
||||
p->fd = -1;
|
||||
} else {
|
||||
struct ttydevice *dev = malloc(sizeof *dev);
|
||||
|
||||
if (dev != NULL)
|
||||
tty_SetupDevice(p);
|
||||
|
||||
return &dev->dev;
|
||||
}
|
||||
} else if (tty_Lock(p, p->dl->bundle->unit) != -1) {
|
||||
struct ttydevice *dev = malloc(sizeof *dev);
|
||||
log_Printf(LogDEBUG, "%s: Opened %s\n", p->link.name, p->name.full);
|
||||
|
||||
if (dev != NULL)
|
||||
tty_SetupDevice(p);
|
||||
|
||||
return &dev->dev;
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
@ -23,11 +23,12 @@
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $Id:$
|
||||
* $Id: tty.h,v 1.1 1999/05/08 11:07:52 brian Exp $
|
||||
*/
|
||||
|
||||
struct physical;
|
||||
struct device;
|
||||
|
||||
extern int tty_OpenStdin(struct physical *);
|
||||
|
||||
extern const struct device ttydevice;
|
||||
extern struct device *tty_Create(struct physical *);
|
||||
extern struct device *tty_iov2device(int, struct physical *,
|
||||
struct iovec *, int *, int);
|
||||
|
269
usr.sbin/ppp/udp.c
Normal file
269
usr.sbin/ppp/udp.c
Normal file
@ -0,0 +1,269 @@
|
||||
/*-
|
||||
* Copyright (c) 1999 Brian Somers <brian@Awfulhak.org>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $Id: tcp.c,v 1.1 1999/05/08 11:07:45 brian Exp $
|
||||
*/
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <netdb.h>
|
||||
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <sys/uio.h>
|
||||
#include <termios.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "layer.h"
|
||||
#include "defs.h"
|
||||
#include "mbuf.h"
|
||||
#include "log.h"
|
||||
#include "sync.h"
|
||||
#include "timer.h"
|
||||
#include "lqr.h"
|
||||
#include "hdlc.h"
|
||||
#include "throughput.h"
|
||||
#include "fsm.h"
|
||||
#include "lcp.h"
|
||||
#include "ccp.h"
|
||||
#include "link.h"
|
||||
#include "async.h"
|
||||
#include "descriptor.h"
|
||||
#include "physical.h"
|
||||
#include "udp.h"
|
||||
|
||||
struct udpdevice {
|
||||
struct device dev; /* What struct physical knows about */
|
||||
struct sockaddr_in sock; /* peer address */
|
||||
unsigned connected : 1; /* Have we connect()d ? */
|
||||
};
|
||||
|
||||
#define device2udp(d) ((d)->type == UDP_DEVICE ? (struct udpdevice *)d : NULL)
|
||||
|
||||
static ssize_t
|
||||
udp_Sendto(struct physical *p, const void *v, size_t n)
|
||||
{
|
||||
struct udpdevice *dev = device2udp(p->handler);
|
||||
|
||||
if (dev->connected)
|
||||
return write(p->fd, v, n);
|
||||
|
||||
return sendto(p->fd, v, n, 0, (struct sockaddr *)&dev->sock,
|
||||
sizeof dev->sock);
|
||||
}
|
||||
|
||||
static ssize_t
|
||||
udp_Recvfrom(struct physical *p, void *v, size_t n)
|
||||
{
|
||||
struct udpdevice *dev = device2udp(p->handler);
|
||||
int sz, ret;
|
||||
|
||||
if (dev->connected)
|
||||
return read(p->fd, v, n);
|
||||
|
||||
sz = sizeof dev->sock;
|
||||
ret = recvfrom(p->fd, v, n, 0, (struct sockaddr *)&dev->sock, &sz);
|
||||
|
||||
if (*p->name.full == '\0') {
|
||||
snprintf(p->name.full, sizeof p->name.full, "%s:%d/udp",
|
||||
inet_ntoa(dev->sock.sin_addr), ntohs(dev->sock.sin_port));
|
||||
p->name.base = p->name.full;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void
|
||||
udp_Free(struct physical *p)
|
||||
{
|
||||
struct udpdevice *dev = device2udp(p->handler);
|
||||
|
||||
free(dev);
|
||||
}
|
||||
|
||||
static void
|
||||
udp_device2iov(struct physical *p, struct iovec *iov, int *niov,
|
||||
int maxiov, pid_t newpid)
|
||||
{
|
||||
iov[*niov].iov_base = p ? p->handler : malloc(sizeof(struct udpdevice));
|
||||
iov[*niov].iov_len = sizeof(struct udpdevice);
|
||||
(*niov)++;
|
||||
}
|
||||
|
||||
static const struct device baseudpdevice = {
|
||||
UDP_DEVICE,
|
||||
"udp",
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
udp_Free,
|
||||
udp_Recvfrom,
|
||||
udp_Sendto,
|
||||
udp_device2iov,
|
||||
NULL,
|
||||
NULL
|
||||
};
|
||||
|
||||
struct device *
|
||||
udp_iov2device(int type, struct physical *p, struct iovec *iov, int *niov,
|
||||
int maxiov)
|
||||
{
|
||||
struct device *dev;
|
||||
|
||||
if (type == UDP_DEVICE) {
|
||||
/* It's one of ours ! Let's create the device */
|
||||
|
||||
dev = (struct device *)iov[(*niov)++].iov_base;
|
||||
/* Refresh function pointers etc */
|
||||
memcpy(dev, &baseudpdevice, sizeof *dev);
|
||||
/* Remember, there's really more than (sizeof *dev) there */
|
||||
|
||||
physical_SetupStack(p, PHYSICAL_FORCE_SYNC);
|
||||
} else
|
||||
dev = NULL;
|
||||
|
||||
return dev;
|
||||
}
|
||||
|
||||
static struct udpdevice *
|
||||
udp_CreateDevice(struct physical *p, char *host, char *port)
|
||||
{
|
||||
struct udpdevice *dev;
|
||||
struct servent *sp;
|
||||
|
||||
if ((dev = malloc(sizeof *dev)) == NULL) {
|
||||
log_Printf(LogWARN, "%s: Cannot allocate a udp device: %s\n",
|
||||
p->link.name, strerror(errno));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
dev->sock.sin_family = AF_INET;
|
||||
dev->sock.sin_addr.s_addr = inet_addr(host);
|
||||
dev->sock.sin_addr = GetIpAddr(host);
|
||||
if (dev->sock.sin_addr.s_addr == INADDR_NONE) {
|
||||
log_Printf(LogWARN, "%s: %s: unknown host\n", p->link.name, host);
|
||||
free(dev);
|
||||
return NULL;
|
||||
}
|
||||
dev->sock.sin_port = htons(atoi(port));
|
||||
if (dev->sock.sin_port == 0) {
|
||||
sp = getservbyname(port, "udp");
|
||||
if (sp)
|
||||
dev->sock.sin_port = sp->s_port;
|
||||
else {
|
||||
log_Printf(LogWARN, "%s: %s: unknown service\n", p->link.name, port);
|
||||
free(dev);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
log_Printf(LogPHASE, "%s: Connecting to %s:%s/udp\n", p->link.name,
|
||||
host, port);
|
||||
|
||||
p->fd = socket(PF_INET, SOCK_DGRAM, 0);
|
||||
if (p->fd >= 0) {
|
||||
log_Printf(LogDEBUG, "%s: Opened udp socket %s\n", p->link.name,
|
||||
p->name.full);
|
||||
if (connect(p->fd, (struct sockaddr *)&dev->sock, sizeof dev->sock) == 0) {
|
||||
dev->connected = 1;
|
||||
return dev;
|
||||
} else
|
||||
log_Printf(LogWARN, "%s: connect: %s\n", p->name.full, strerror(errno));
|
||||
} else
|
||||
log_Printf(LogWARN, "%s: socket: %s\n", p->name.full, strerror(errno));
|
||||
|
||||
close(p->fd);
|
||||
p->fd = -1;
|
||||
free(dev);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
struct device *
|
||||
udp_Create(struct physical *p)
|
||||
{
|
||||
char *cp, *host, *port, *svc;
|
||||
struct udpdevice *dev;
|
||||
|
||||
dev = NULL;
|
||||
if (p->fd < 0) {
|
||||
if ((cp = strchr(p->name.full, ':')) != NULL) {
|
||||
*cp = '\0';
|
||||
host = p->name.full;
|
||||
port = cp + 1;
|
||||
svc = strchr(port, '/');
|
||||
if (svc && strcasecmp(svc, "/udp")) {
|
||||
*cp = ':';
|
||||
return NULL;
|
||||
}
|
||||
if (svc)
|
||||
*svc = '\0';
|
||||
|
||||
if (*host && *port)
|
||||
dev = udp_CreateDevice(p, host, port);
|
||||
|
||||
*cp = ':';
|
||||
if (svc)
|
||||
*svc = '/';
|
||||
}
|
||||
} else {
|
||||
/* See if we're a connected udp socket */
|
||||
int type, sz, err;
|
||||
|
||||
sz = sizeof type;
|
||||
if ((err = getsockopt(p->fd, SOL_SOCKET, SO_TYPE, &type, &sz)) == 0 &&
|
||||
sz == sizeof type && type == SOCK_DGRAM) {
|
||||
if ((dev = malloc(sizeof *dev)) == NULL) {
|
||||
log_Printf(LogWARN, "%s: Cannot allocate a udp device: %s\n",
|
||||
p->link.name, strerror(errno));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* We can't getpeername().... hence we stay un-connect()ed */
|
||||
dev->connected = 0;
|
||||
|
||||
log_Printf(LogPHASE, "%s: Link is a udp socket\n", p->link.name);
|
||||
|
||||
if (p->link.lcp.cfg.openmode != OPEN_PASSIVE) {
|
||||
log_Printf(LogPHASE, "%s: Changing openmode to PASSIVE\n",
|
||||
p->link.name);
|
||||
p->link.lcp.cfg.openmode = OPEN_PASSIVE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (dev) {
|
||||
memcpy(&dev->dev, &baseudpdevice, sizeof dev->dev);
|
||||
physical_SetupStack(p, PHYSICAL_FORCE_SYNC);
|
||||
return &dev->dev;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
34
usr.sbin/ppp/udp.h
Normal file
34
usr.sbin/ppp/udp.h
Normal file
@ -0,0 +1,34 @@
|
||||
/*-
|
||||
* Copyright (c) 1999 Brian Somers <brian@Awfulhak.org>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $Id: tcp.h,v 1.1 1999/05/08 11:07:45 brian Exp $
|
||||
*/
|
||||
|
||||
struct physical;
|
||||
struct device;
|
||||
|
||||
extern struct device *udp_Create(struct physical *);
|
||||
extern struct device *udp_iov2device(int, struct physical *,
|
||||
struct iovec *, int *, int);
|
@ -17,7 +17,7 @@
|
||||
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* $Id: vjcomp.c,v 1.28 1999/05/08 11:07:55 brian Exp $
|
||||
* $Id: vjcomp.c,v 1.29 1999/05/09 20:02:29 brian Exp $
|
||||
*
|
||||
* TODO:
|
||||
*/
|
||||
@ -66,8 +66,6 @@ vj_LayerPush(struct bundle *bundle, struct link *l, struct mbuf *bp, int pri,
|
||||
struct ip *pip;
|
||||
u_short cproto = bundle->ncp.ipcp.peer_compproto >> 16;
|
||||
|
||||
log_Printf(LogDEBUG, "vj_LayerWrite: COMPPROTO = %x\n",
|
||||
bundle->ncp.ipcp.peer_compproto);
|
||||
bp = mbuf_Contiguous(bp);
|
||||
pip = (struct ip *)MBUF_CTOP(bp);
|
||||
if (*proto == PROTO_IP && pip->ip_p == IPPROTO_TCP &&
|
||||
@ -82,14 +80,16 @@ vj_LayerPush(struct bundle *bundle, struct link *l, struct mbuf *bp, int pri,
|
||||
|
||||
case TYPE_UNCOMPRESSED_TCP:
|
||||
*proto = PROTO_VJUNCOMP;
|
||||
log_Printf(LogDEBUG, "vj_LayerPush: PROTO_IP -> PROTO_VJUNCOMP\n");
|
||||
break;
|
||||
|
||||
case TYPE_COMPRESSED_TCP:
|
||||
*proto = PROTO_VJCOMP;
|
||||
log_Printf(LogDEBUG, "vj_LayerPush: PROTO_IP -> PROTO_VJUNCOMP\n");
|
||||
break;
|
||||
|
||||
default:
|
||||
log_Printf(LogERROR, "Unknown frame type %x\n", type);
|
||||
log_Printf(LogERROR, "vj_LayerPush: Unknown frame type %x\n", type);
|
||||
mbuf_Free(bp);
|
||||
return NULL;
|
||||
}
|
||||
@ -153,15 +153,14 @@ vj_LayerPull(struct bundle *bundle, struct link *l, struct mbuf *bp,
|
||||
{
|
||||
u_char type;
|
||||
|
||||
log_Printf(LogDEBUG, "vj_LayerPull: proto %02x\n", *proto);
|
||||
log_DumpBp(LogDEBUG, "Raw packet info:", bp);
|
||||
|
||||
switch (*proto) {
|
||||
case PROTO_VJCOMP:
|
||||
type = TYPE_COMPRESSED_TCP;
|
||||
log_Printf(LogDEBUG, "vj_LayerPull: PROTO_VJCOMP -> PROTO_IP\n");
|
||||
break;
|
||||
case PROTO_VJUNCOMP:
|
||||
type = TYPE_UNCOMPRESSED_TCP;
|
||||
log_Printf(LogDEBUG, "vj_LayerPull: PROTO_VJUNCOMP -> PROTO_IP\n");
|
||||
break;
|
||||
default:
|
||||
return bp;
|
||||
|
Loading…
Reference in New Issue
Block a user