mirror of
https://git.FreeBSD.org/src.git
synced 2025-01-30 16:51:41 +00:00
Cosmetic: Make our external function names consistent.
This commit is contained in:
parent
40f1c018aa
commit
dd7e261079
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/cvs2svn/branches/MP/; revision=35605
@ -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.12.2.6 1998/04/07 23:45:39 brian Exp $
|
||||
* $Id: alias_cmd.c,v 1.12.2.7 1998/04/14 23:17:00 brian Exp $
|
||||
*/
|
||||
|
||||
#include <sys/types.h>
|
||||
@ -29,9 +29,9 @@ static int StrToAddrAndPort(const char *, struct in_addr *, u_short *, const cha
|
||||
|
||||
|
||||
int
|
||||
AliasRedirectPort(struct cmdargs const *arg)
|
||||
alias_RedirectPort(struct cmdargs const *arg)
|
||||
{
|
||||
if (!AliasEnabled()) {
|
||||
if (!alias_IsEnabled()) {
|
||||
prompt_Printf(arg->prompt, "Alias not enabled\n");
|
||||
return 1;
|
||||
} else if (arg->argc == arg->argn+3) {
|
||||
@ -91,9 +91,9 @@ AliasRedirectPort(struct cmdargs const *arg)
|
||||
|
||||
|
||||
int
|
||||
AliasRedirectAddr(struct cmdargs const *arg)
|
||||
alias_RedirectAddr(struct cmdargs const *arg)
|
||||
{
|
||||
if (!AliasEnabled()) {
|
||||
if (!alias_IsEnabled()) {
|
||||
prompt_Printf(arg->prompt, "alias not enabled\n");
|
||||
return 1;
|
||||
} else if (arg->argc == arg->argn+2) {
|
||||
@ -138,7 +138,7 @@ StrToAddr(const char *str, struct in_addr *addr)
|
||||
|
||||
hp = gethostbyname(str);
|
||||
if (!hp) {
|
||||
LogPrintf(LogWARN, "StrToAddr: Unknown host %s.\n", str);
|
||||
log_Printf(LogWARN, "StrToAddr: Unknown host %s.\n", str);
|
||||
return -1;
|
||||
}
|
||||
*addr = *((struct in_addr *) hp->h_addr);
|
||||
@ -160,7 +160,7 @@ StrToPort(const char *str, u_short *port, const char *proto)
|
||||
}
|
||||
sp = getservbyname(str, proto);
|
||||
if (!sp) {
|
||||
LogPrintf(LogWARN, "StrToAddr: Unknown port or service %s/%s.\n",
|
||||
log_Printf(LogWARN, "StrToAddr: Unknown port or service %s/%s.\n",
|
||||
str, proto);
|
||||
return -1;
|
||||
}
|
||||
@ -177,7 +177,7 @@ StrToAddrAndPort(const char *str, struct in_addr *addr, u_short *port, const cha
|
||||
|
||||
colon = strchr(str, ':');
|
||||
if (!colon) {
|
||||
LogPrintf(LogWARN, "StrToAddrAndPort: %s is missing port number.\n", str);
|
||||
log_Printf(LogWARN, "StrToAddrAndPort: %s is missing port number.\n", str);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -2,10 +2,10 @@
|
||||
* 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.h,v 1.7 1997/12/24 10:28:38 brian Exp $
|
||||
* $Id: alias_cmd.h,v 1.7.2.1 1998/04/07 00:53:13 brian Exp $
|
||||
*/
|
||||
|
||||
struct cmdargs;
|
||||
|
||||
extern int AliasRedirectPort(struct cmdargs const *);
|
||||
extern int AliasRedirectAddr(struct cmdargs const *);
|
||||
extern int alias_RedirectPort(struct cmdargs const *);
|
||||
extern int alias_RedirectAddr(struct cmdargs const *);
|
||||
|
@ -17,7 +17,7 @@
|
||||
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* $Id: arp.c,v 1.27.2.13 1998/04/23 23:50:36 brian Exp $
|
||||
* $Id: arp.c,v 1.27.2.14 1998/04/28 01:25:01 brian Exp $
|
||||
*
|
||||
*/
|
||||
|
||||
@ -78,7 +78,7 @@
|
||||
#if RTM_VERSION >= 3
|
||||
|
||||
/*
|
||||
* sifproxyarp - Make a proxy ARP entry for the peer.
|
||||
* arp_SetProxy - Make a proxy ARP entry for the peer.
|
||||
*/
|
||||
static struct {
|
||||
struct rt_msghdr hdr;
|
||||
@ -90,7 +90,7 @@ static struct {
|
||||
static int arpmsg_valid;
|
||||
|
||||
int
|
||||
sifproxyarp(struct bundle *bundle, struct in_addr addr, int s)
|
||||
arp_SetProxy(struct bundle *bundle, struct in_addr addr, int s)
|
||||
{
|
||||
int routes;
|
||||
|
||||
@ -100,12 +100,12 @@ sifproxyarp(struct bundle *bundle, struct in_addr addr, int s)
|
||||
*/
|
||||
memset(&arpmsg, 0, sizeof arpmsg);
|
||||
if (!get_ether_addr(s, addr, &arpmsg.hwa)) {
|
||||
LogPrintf(LogERROR, "Cannot determine ethernet address for proxy ARP\n");
|
||||
log_Printf(LogERROR, "Cannot determine ethernet address for proxy ARP\n");
|
||||
return 0;
|
||||
}
|
||||
routes = ID0socket(PF_ROUTE, SOCK_RAW, AF_INET);
|
||||
if (routes < 0) {
|
||||
LogPrintf(LogERROR, "sifproxyarp: opening routing socket: %s\n",
|
||||
log_Printf(LogERROR, "arp_SetProxy: opening routing socket: %s\n",
|
||||
strerror(errno));
|
||||
return 0;
|
||||
}
|
||||
@ -123,7 +123,7 @@ sifproxyarp(struct bundle *bundle, struct in_addr addr, int s)
|
||||
arpmsg.hdr.rtm_msglen = (char *) &arpmsg.hwa - (char *) &arpmsg
|
||||
+ arpmsg.hwa.sdl_len;
|
||||
if (write(routes, &arpmsg, arpmsg.hdr.rtm_msglen) < 0) {
|
||||
LogPrintf(LogERROR, "Add proxy arp entry: %s\n", strerror(errno));
|
||||
log_Printf(LogERROR, "Add proxy arp entry: %s\n", strerror(errno));
|
||||
close(routes);
|
||||
return 0;
|
||||
}
|
||||
@ -133,10 +133,10 @@ sifproxyarp(struct bundle *bundle, struct in_addr addr, int s)
|
||||
}
|
||||
|
||||
/*
|
||||
* cifproxyarp - Delete the proxy ARP entry for the peer.
|
||||
* arp_ClearProxy - Delete the proxy ARP entry for the peer.
|
||||
*/
|
||||
int
|
||||
cifproxyarp(struct bundle *bundle, struct in_addr addr, int s)
|
||||
arp_ClearProxy(struct bundle *bundle, struct in_addr addr, int s)
|
||||
{
|
||||
int routes;
|
||||
|
||||
@ -149,12 +149,12 @@ cifproxyarp(struct bundle *bundle, struct in_addr addr, int s)
|
||||
|
||||
routes = ID0socket(PF_ROUTE, SOCK_RAW, AF_INET);
|
||||
if (routes < 0) {
|
||||
LogPrintf(LogERROR, "sifproxyarp: opening routing socket: %s\n",
|
||||
log_Printf(LogERROR, "arp_SetProxy: opening routing socket: %s\n",
|
||||
strerror(errno));
|
||||
return 0;
|
||||
}
|
||||
if (write(routes, &arpmsg, arpmsg.hdr.rtm_msglen) < 0) {
|
||||
LogPrintf(LogERROR, "Delete proxy arp entry: %s\n", strerror(errno));
|
||||
log_Printf(LogERROR, "Delete proxy arp entry: %s\n", strerror(errno));
|
||||
close(routes);
|
||||
return 0;
|
||||
}
|
||||
@ -165,10 +165,10 @@ cifproxyarp(struct bundle *bundle, struct in_addr addr, int s)
|
||||
#else /* RTM_VERSION */
|
||||
|
||||
/*
|
||||
* sifproxyarp - Make a proxy ARP entry for the peer.
|
||||
* arp_SetProxy - Make a proxy ARP entry for the peer.
|
||||
*/
|
||||
int
|
||||
sifproxyarp(struct bundle *bundle, struct in_addr addr, int s)
|
||||
arp_SetProxy(struct bundle *bundle, struct in_addr addr, int s)
|
||||
{
|
||||
struct arpreq arpreq;
|
||||
struct {
|
||||
@ -183,7 +183,7 @@ sifproxyarp(struct bundle *bundle, struct in_addr addr, int s)
|
||||
* address.
|
||||
*/
|
||||
if (!get_ether_addr(s, addr, &dls.sdl)) {
|
||||
LogPrintf(LOG_PHASE_BIT, "Cannot determine ethernet address for proxy ARP\n");
|
||||
log_Printf(LOG_PHASE_BIT, "Cannot determine ethernet address for proxy ARP\n");
|
||||
return 0;
|
||||
}
|
||||
arpreq.arp_ha.sa_len = sizeof(struct sockaddr);
|
||||
@ -193,17 +193,17 @@ sifproxyarp(struct bundle *bundle, struct in_addr addr, int s)
|
||||
((struct sockaddr_in *)&arpreq.arp_pa)->sin_addr.s_addr = addr.s_addr;
|
||||
arpreq.arp_flags = ATF_PERM | ATF_PUBL;
|
||||
if (ID0ioctl(s, SIOCSARP, (caddr_t) & arpreq) < 0) {
|
||||
LogPrintf(LogERROR, "sifproxyarp: ioctl(SIOCSARP): %s\n", strerror(errno));
|
||||
log_Printf(LogERROR, "arp_SetProxy: ioctl(SIOCSARP): %s\n", strerror(errno));
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
* cifproxyarp - Delete the proxy ARP entry for the peer.
|
||||
* arp_ClearProxy - Delete the proxy ARP entry for the peer.
|
||||
*/
|
||||
int
|
||||
cifproxyarp(struct bundle *bundle, struct in_addr addr, int s)
|
||||
arp_ClearProxy(struct bundle *bundle, struct in_addr addr, int s)
|
||||
{
|
||||
struct arpreq arpreq;
|
||||
|
||||
@ -211,7 +211,7 @@ cifproxyarp(struct bundle *bundle, struct in_addr addr, int s)
|
||||
SET_SA_FAMILY(arpreq.arp_pa, AF_INET);
|
||||
((struct sockaddr_in *)&arpreq.arp_pa)->sin_addr.s_addr = addr.s_addr;
|
||||
if (ID0ioctl(s, SIOCDARP, (caddr_t) & arpreq) < 0) {
|
||||
LogPrintf(LogERROR, "cifproxyarp: ioctl(SIOCDARP): %s\n", strerror(errno));
|
||||
log_Printf(LogERROR, "arp_ClearProxy: ioctl(SIOCDARP): %s\n", strerror(errno));
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
@ -245,7 +245,7 @@ get_ether_addr(int s, struct in_addr ipaddr, struct sockaddr_dl *hwaddr)
|
||||
mib[5] = 0;
|
||||
|
||||
if (sysctl(mib, 6, NULL, &needed, NULL, 0) < 0) {
|
||||
LogPrintf(LogERROR, "get_ether_addr: sysctl: estimate: %s\n",
|
||||
log_Printf(LogERROR, "get_ether_addr: sysctl: estimate: %s\n",
|
||||
strerror(errno));
|
||||
return 0;
|
||||
}
|
||||
@ -278,9 +278,9 @@ get_ether_addr(int s, struct in_addr ipaddr, struct sockaddr_dl *hwaddr)
|
||||
(RTA_NETMASK|RTA_IFA))
|
||||
continue;
|
||||
/* Found a candidate. Do the addresses match ? */
|
||||
if (LogIsKept(LogDEBUG) &&
|
||||
if (log_IsKept(LogDEBUG) &&
|
||||
ptr == (char *)ifm + ifm->ifm_msglen + ifam->ifam_msglen)
|
||||
LogPrintf(LogDEBUG, "%.*s interface is a candidate for proxy\n",
|
||||
log_Printf(LogDEBUG, "%.*s interface is a candidate for proxy\n",
|
||||
dl->sdl_nlen, dl->sdl_data);
|
||||
b = 1;
|
||||
ifa = mask = NULL;
|
||||
@ -304,17 +304,17 @@ get_ether_addr(int s, struct in_addr ipaddr, struct sockaddr_dl *hwaddr)
|
||||
}
|
||||
b <<= 1;
|
||||
}
|
||||
if (LogIsKept(LogDEBUG)) {
|
||||
if (log_IsKept(LogDEBUG)) {
|
||||
char a[16];
|
||||
strncpy(a, inet_ntoa(mask->sin_addr), sizeof a - 1);
|
||||
a[sizeof a - 1] = '\0';
|
||||
LogPrintf(LogDEBUG, "Check addr %s, mask %s\n",
|
||||
log_Printf(LogDEBUG, "Check addr %s, mask %s\n",
|
||||
inet_ntoa(ifa->sin_addr), a);
|
||||
}
|
||||
if (ifa->sin_family == AF_INET &&
|
||||
(ifa->sin_addr.s_addr & mask->sin_addr.s_addr) ==
|
||||
(ipaddr.s_addr & mask->sin_addr.s_addr)) {
|
||||
LogPrintf(LogPHASE, "Found interface %.*s for %s\n",
|
||||
log_Printf(LogPHASE, "Found interface %.*s for %s\n",
|
||||
dl->sdl_alen, dl->sdl_data, inet_ntoa(ipaddr));
|
||||
memcpy(hwaddr, dl, dl->sdl_len);
|
||||
free(buf);
|
||||
|
@ -17,13 +17,13 @@
|
||||
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* $Id: arp.h,v 1.7.2.5 1998/04/07 00:53:16 brian Exp $
|
||||
* $Id: arp.h,v 1.7.2.6 1998/04/23 23:50:37 brian Exp $
|
||||
*
|
||||
*/
|
||||
|
||||
struct sockaddr_dl;
|
||||
struct bundle;
|
||||
|
||||
extern int cifproxyarp(struct bundle *, struct in_addr, int);
|
||||
extern int sifproxyarp(struct bundle *, struct in_addr, int);
|
||||
extern int arp_ClearProxy(struct bundle *, struct in_addr, int);
|
||||
extern int arp_SetProxy(struct bundle *, struct in_addr, int);
|
||||
extern int get_ether_addr(int, struct in_addr, struct sockaddr_dl *);
|
||||
|
@ -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.15.2.12 1998/04/19 01:18:51 brian Exp $
|
||||
* $Id: async.c,v 1.15.2.13 1998/04/21 01:02:08 brian Exp $
|
||||
*
|
||||
*/
|
||||
#include <sys/types.h>
|
||||
@ -89,8 +89,8 @@ async_Output(int pri, struct mbuf *bp, int proto, struct physical *physical)
|
||||
struct mbuf *wp;
|
||||
int cnt;
|
||||
|
||||
if (plength(bp) > HDLCSIZE) {
|
||||
pfree(bp);
|
||||
if (mbuf_Length(bp) > HDLCSIZE) {
|
||||
mbuf_Free(bp);
|
||||
return;
|
||||
}
|
||||
cp = physical->async.xbuff;
|
||||
@ -102,7 +102,7 @@ async_Output(int pri, struct mbuf *bp, int proto, struct physical *physical)
|
||||
for (cnt = wp->cnt; cnt > 0; cnt--) {
|
||||
HdlcPutByte(&physical->async, &cp, *sp++, proto);
|
||||
if (cp >= ep) {
|
||||
pfree(bp);
|
||||
mbuf_Free(bp);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -111,10 +111,10 @@ async_Output(int pri, struct mbuf *bp, int proto, struct physical *physical)
|
||||
*cp++ = HDLC_SYN;
|
||||
|
||||
cnt = cp - physical->async.xbuff;
|
||||
LogDumpBuff(LogASYNC, "WriteModem", physical->async.xbuff, cnt);
|
||||
link_Write(physical2link(physical), pri, (char *)physical->async.xbuff, cnt);
|
||||
link_AddOutOctets(physical2link(physical), cnt);
|
||||
pfree(bp);
|
||||
log_DumpBuff(LogASYNC, "WriteModem", physical->async.xbuff, cnt);
|
||||
link_Write(&physical->link, pri, (char *)physical->async.xbuff, cnt);
|
||||
link_AddOutOctets(&physical->link, cnt);
|
||||
mbuf_Free(bp);
|
||||
}
|
||||
|
||||
static struct mbuf *
|
||||
@ -129,8 +129,8 @@ async_Decode(struct async *async, u_char c)
|
||||
case HDLC_SYN:
|
||||
async->mode &= ~MODE_HUNT;
|
||||
if (async->length) { /* packet is ready. */
|
||||
bp = mballoc(async->length, MB_ASYNC);
|
||||
mbwrite(bp, async->hbuff, async->length);
|
||||
bp = mbuf_Alloc(async->length, MB_ASYNC);
|
||||
mbuf_Write(bp, async->hbuff, async->length);
|
||||
async->length = 0;
|
||||
return bp;
|
||||
}
|
||||
@ -144,7 +144,7 @@ async_Decode(struct async *async, u_char c)
|
||||
default:
|
||||
if (async->length >= HDLCSIZE) {
|
||||
/* packet is too large, discard it */
|
||||
LogPrintf(LogERROR, "Packet too large (%d), discarding.\n", async->length);
|
||||
log_Printf(LogERROR, "Packet too large (%d), discarding.\n", async->length);
|
||||
async->length = 0;
|
||||
async->mode = MODE_HUNT;
|
||||
break;
|
||||
@ -165,18 +165,18 @@ async_Input(struct bundle *bundle, u_char *buff, int cnt,
|
||||
{
|
||||
struct mbuf *bp;
|
||||
|
||||
link_AddInOctets(physical2link(physical), cnt);
|
||||
link_AddInOctets(&physical->link, cnt);
|
||||
|
||||
if (Physical_IsSync(physical)) {
|
||||
bp = mballoc(cnt, MB_ASYNC);
|
||||
if (physical_IsSync(physical)) {
|
||||
bp = mbuf_Alloc(cnt, MB_ASYNC);
|
||||
memcpy(MBUF_CTOP(bp), buff, cnt);
|
||||
bp->cnt = cnt;
|
||||
HdlcInput(bundle, bp, physical);
|
||||
hdlc_Input(bundle, bp, physical);
|
||||
} else {
|
||||
while (cnt > 0) {
|
||||
bp = async_Decode(&physical->async, *buff++);
|
||||
if (bp)
|
||||
HdlcInput(bundle, bp, physical);
|
||||
hdlc_Input(bundle, bp, physical);
|
||||
cnt--;
|
||||
}
|
||||
}
|
||||
|
@ -17,7 +17,7 @@
|
||||
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* $Id: auth.c,v 1.27.2.24 1998/04/24 19:15:55 brian Exp $
|
||||
* $Id: auth.c,v 1.27.2.25 1998/04/28 01:25:03 brian Exp $
|
||||
*
|
||||
* TODO:
|
||||
* o Implement check against with registered IP addresses.
|
||||
@ -87,7 +87,7 @@ auth_CheckPasswd(const char *name, const char *data, const char *key)
|
||||
}
|
||||
|
||||
int
|
||||
AuthSelect(struct bundle *bundle, const char *name, struct physical *physical)
|
||||
auth_Select(struct bundle *bundle, const char *name, struct physical *physical)
|
||||
{
|
||||
FILE *fp;
|
||||
int n;
|
||||
@ -115,7 +115,7 @@ AuthSelect(struct bundle *bundle, const char *name, struct physical *physical)
|
||||
memset(&bundle->ncp.ipcp.cfg.peer_range, '\0',
|
||||
sizeof bundle->ncp.ipcp.cfg.peer_range);
|
||||
*/
|
||||
if (n > 2 && !UseHisaddr(bundle, vector[2], 1))
|
||||
if (n > 2 && !ipcp_UseHisaddr(bundle, vector[2], 1))
|
||||
return 0;
|
||||
ipcp_Setup(&bundle->ncp.ipcp);
|
||||
if (n > 3)
|
||||
@ -136,7 +136,7 @@ AuthSelect(struct bundle *bundle, const char *name, struct physical *physical)
|
||||
}
|
||||
|
||||
int
|
||||
AuthValidate(struct bundle *bundle, const char *system,
|
||||
auth_Validate(struct bundle *bundle, const char *system,
|
||||
const char *key, struct physical *physical)
|
||||
{
|
||||
/* Used by PAP routines */
|
||||
@ -173,7 +173,7 @@ AuthValidate(struct bundle *bundle, const char *system,
|
||||
}
|
||||
|
||||
char *
|
||||
AuthGetSecret(struct bundle *bundle, const char *system, int len,
|
||||
auth_GetSecret(struct bundle *bundle, const char *system, int len,
|
||||
struct physical *physical)
|
||||
{
|
||||
/* Used by CHAP routines */
|
||||
@ -209,27 +209,27 @@ AuthTimeout(void *vauthp)
|
||||
{
|
||||
struct authinfo *authp = (struct authinfo *)vauthp;
|
||||
|
||||
StopTimer(&authp->authtimer);
|
||||
timer_Stop(&authp->authtimer);
|
||||
if (--authp->retry > 0) {
|
||||
StartTimer(&authp->authtimer);
|
||||
timer_Start(&authp->authtimer);
|
||||
(*authp->ChallengeFunc)(authp, ++authp->id, authp->physical);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
authinfo_Init(struct authinfo *authinfo)
|
||||
auth_Init(struct authinfo *authinfo)
|
||||
{
|
||||
memset(authinfo, '\0', sizeof(struct authinfo));
|
||||
authinfo->cfg.fsmretry = DEF_FSMRETRY;
|
||||
}
|
||||
|
||||
void
|
||||
StartAuthChallenge(struct authinfo *authp, struct physical *physical,
|
||||
auth_StartChallenge(struct authinfo *authp, struct physical *physical,
|
||||
void (*fn)(struct authinfo *, int, struct physical *))
|
||||
{
|
||||
authp->ChallengeFunc = fn;
|
||||
authp->physical = physical;
|
||||
StopTimer(&authp->authtimer);
|
||||
timer_Stop(&authp->authtimer);
|
||||
authp->authtimer.func = AuthTimeout;
|
||||
authp->authtimer.name = "auth";
|
||||
authp->authtimer.load = authp->cfg.fsmretry * SECTICKS;
|
||||
@ -237,12 +237,12 @@ StartAuthChallenge(struct authinfo *authp, struct physical *physical,
|
||||
authp->retry = 3;
|
||||
authp->id = 1;
|
||||
(*authp->ChallengeFunc)(authp, authp->id, physical);
|
||||
StartTimer(&authp->authtimer);
|
||||
timer_Start(&authp->authtimer);
|
||||
}
|
||||
|
||||
void
|
||||
StopAuthTimer(struct authinfo *authp)
|
||||
auth_StopTimer(struct authinfo *authp)
|
||||
{
|
||||
StopTimer(&authp->authtimer);
|
||||
timer_Stop(&authp->authtimer);
|
||||
authp->physical = NULL;
|
||||
}
|
||||
|
@ -15,7 +15,7 @@
|
||||
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* $Id: auth.h,v 1.10.2.7 1998/04/07 00:53:20 brian Exp $
|
||||
* $Id: auth.h,v 1.10.2.8 1998/04/24 19:15:56 brian Exp $
|
||||
*
|
||||
* TODO:
|
||||
*/
|
||||
@ -34,14 +34,15 @@ struct authinfo {
|
||||
} cfg;
|
||||
};
|
||||
|
||||
extern void authinfo_Init(struct authinfo *);
|
||||
|
||||
extern const char *Auth2Nam(u_short);
|
||||
extern void StopAuthTimer(struct authinfo *);
|
||||
extern void StartAuthChallenge(struct authinfo *, struct physical *,
|
||||
void (*fn)(struct authinfo *, int, struct physical *));
|
||||
extern int AuthValidate(struct bundle *, const char *, const char *,
|
||||
struct physical *);
|
||||
extern char *AuthGetSecret(struct bundle *, const char *, int,
|
||||
struct physical *);
|
||||
extern int AuthSelect(struct bundle *, const char *, struct physical *);
|
||||
|
||||
extern void auth_Init(struct authinfo *);
|
||||
extern void auth_StopTimer(struct authinfo *);
|
||||
extern void auth_StartChallenge(struct authinfo *, struct physical *,
|
||||
void (*fn)(struct authinfo *, int,
|
||||
struct physical *));
|
||||
extern int auth_Validate(struct bundle *, const char *, const char *,
|
||||
struct physical *);
|
||||
extern char *auth_GetSecret(struct bundle *, const char *, int,
|
||||
struct physical *);
|
||||
extern int auth_Select(struct bundle *, const char *, struct physical *);
|
||||
|
@ -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.1.2.66 1998/05/01 19:19:54 brian Exp $
|
||||
* $Id: bundle.c,v 1.1.2.67 1998/05/01 19:22:09 brian Exp $
|
||||
*/
|
||||
|
||||
#include <sys/types.h>
|
||||
@ -99,7 +99,7 @@ bundle_NewPhase(struct bundle *bundle, u_int new)
|
||||
return;
|
||||
|
||||
if (new <= PHASE_TERMINATE)
|
||||
LogPrintf(LogPHASE, "bundle: %s\n", PhaseNames[new]);
|
||||
log_Printf(LogPHASE, "bundle: %s\n", PhaseNames[new]);
|
||||
|
||||
switch (new) {
|
||||
case PHASE_DEAD:
|
||||
@ -117,8 +117,8 @@ bundle_NewPhase(struct bundle *bundle, u_int new)
|
||||
|
||||
case PHASE_NETWORK:
|
||||
ipcp_Setup(&bundle->ncp.ipcp);
|
||||
FsmUp(&bundle->ncp.ipcp.fsm);
|
||||
FsmOpen(&bundle->ncp.ipcp.fsm);
|
||||
fsm_Up(&bundle->ncp.ipcp.fsm);
|
||||
fsm_Open(&bundle->ncp.ipcp.fsm);
|
||||
bundle->phase = new;
|
||||
bundle_DisplayPrompt(bundle);
|
||||
break;
|
||||
@ -140,7 +140,7 @@ bundle_CleanInterface(const struct bundle *bundle)
|
||||
|
||||
s = ID0socket(AF_INET, SOCK_DGRAM, 0);
|
||||
if (s < 0) {
|
||||
LogPrintf(LogERROR, "bundle_CleanInterface: socket(): %s\n",
|
||||
log_Printf(LogERROR, "bundle_CleanInterface: socket(): %s\n",
|
||||
strerror(errno));
|
||||
return (-1);
|
||||
}
|
||||
@ -153,7 +153,7 @@ bundle_CleanInterface(const struct bundle *bundle)
|
||||
ifra.ifra_addr = ifrq.ifr_addr;
|
||||
if (ID0ioctl(s, SIOCGIFDSTADDR, &ifrq) < 0) {
|
||||
if (ifra.ifra_addr.sa_family == AF_INET)
|
||||
LogPrintf(LogERROR,
|
||||
log_Printf(LogERROR,
|
||||
"bundle_CleanInterface: Can't get dst for %s on %s !\n",
|
||||
inet_ntoa(((struct sockaddr_in *)&ifra.ifra_addr)->sin_addr),
|
||||
bundle->ifname);
|
||||
@ -162,7 +162,7 @@ bundle_CleanInterface(const struct bundle *bundle)
|
||||
ifra.ifra_broadaddr = ifrq.ifr_dstaddr;
|
||||
if (ID0ioctl(s, SIOCDIFADDR, &ifra) < 0) {
|
||||
if (ifra.ifra_addr.sa_family == AF_INET)
|
||||
LogPrintf(LogERROR,
|
||||
log_Printf(LogERROR,
|
||||
"bundle_CleanInterface: Can't delete %s address on %s !\n",
|
||||
inet_ntoa(((struct sockaddr_in *)&ifra.ifra_addr)->sin_addr),
|
||||
bundle->ifname);
|
||||
@ -185,9 +185,9 @@ bundle_Notify(struct bundle *bundle, char c)
|
||||
{
|
||||
if (bundle->notify.fd != -1) {
|
||||
if (write(bundle->notify.fd, &c, 1) == 1)
|
||||
LogPrintf(LogPHASE, "Parent notified of success.\n");
|
||||
log_Printf(LogPHASE, "Parent notified of success.\n");
|
||||
else
|
||||
LogPrintf(LogPHASE, "Failed to notify parent of success.\n");
|
||||
log_Printf(LogPHASE, "Failed to notify parent of success.\n");
|
||||
close(bundle->notify.fd);
|
||||
bundle->notify.fd = -1;
|
||||
}
|
||||
@ -261,8 +261,8 @@ bundle_LayerFinish(void *v, struct fsm *fp)
|
||||
{
|
||||
/* The given fsm is now down (fp cannot be NULL)
|
||||
*
|
||||
* If it's the last LCP, FsmDown all NCPs
|
||||
* If it's the last NCP, FsmClose all LCPs
|
||||
* If it's the last LCP, fsm_Down all NCPs
|
||||
* If it's the last NCP, fsm_Close all LCPs
|
||||
*/
|
||||
|
||||
struct bundle *bundle = (struct bundle *)v;
|
||||
@ -273,8 +273,8 @@ bundle_LayerFinish(void *v, struct fsm *fp)
|
||||
bundle_NewPhase(bundle, PHASE_TERMINATE);
|
||||
for (dl = bundle->links; dl; dl = dl->next)
|
||||
datalink_Close(dl, 0);
|
||||
FsmDown(fp);
|
||||
FsmClose(fp);
|
||||
fsm_Down(fp);
|
||||
fsm_Close(fp);
|
||||
} else if (fp->proto == PROTO_LCP) {
|
||||
int others_active;
|
||||
|
||||
@ -285,8 +285,8 @@ bundle_LayerFinish(void *v, struct fsm *fp)
|
||||
others_active++;
|
||||
|
||||
if (!others_active) {
|
||||
FsmDown(&bundle->ncp.ipcp.fsm);
|
||||
FsmClose(&bundle->ncp.ipcp.fsm); /* ST_INITIAL please */
|
||||
fsm_Down(&bundle->ncp.ipcp.fsm);
|
||||
fsm_Close(&bundle->ncp.ipcp.fsm); /* ST_INITIAL please */
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -302,7 +302,7 @@ bundle_Close(struct bundle *bundle, const char *name, int staydown)
|
||||
{
|
||||
/*
|
||||
* Please close the given datalink.
|
||||
* If name == NULL or name is the last datalink, FsmClose all NCPs
|
||||
* If name == NULL or name is the last datalink, fsm_Close all NCPs
|
||||
* (except our MP)
|
||||
* If it isn't the last datalink, just Close that datalink.
|
||||
*/
|
||||
@ -327,18 +327,18 @@ bundle_Close(struct bundle *bundle, const char *name, int staydown)
|
||||
}
|
||||
|
||||
if (name && this_dl == NULL) {
|
||||
LogPrintf(LogWARN, "%s: Invalid datalink name\n", name);
|
||||
log_Printf(LogWARN, "%s: Invalid datalink name\n", name);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!others_active) {
|
||||
if (bundle->ncp.ipcp.fsm.state > ST_CLOSED ||
|
||||
bundle->ncp.ipcp.fsm.state == ST_STARTING)
|
||||
FsmClose(&bundle->ncp.ipcp.fsm);
|
||||
fsm_Close(&bundle->ncp.ipcp.fsm);
|
||||
else {
|
||||
if (bundle->ncp.ipcp.fsm.state > ST_INITIAL) {
|
||||
FsmClose(&bundle->ncp.ipcp.fsm);
|
||||
FsmDown(&bundle->ncp.ipcp.fsm);
|
||||
fsm_Close(&bundle->ncp.ipcp.fsm);
|
||||
fsm_Down(&bundle->ncp.ipcp.fsm);
|
||||
}
|
||||
for (dl = bundle->links; dl; dl = dl->next)
|
||||
datalink_Close(dl, staydown);
|
||||
@ -425,7 +425,7 @@ bundle_Create(const char *prefix, struct prompt *prompt, int type)
|
||||
static struct bundle bundle; /* there can be only one */
|
||||
|
||||
if (bundle.ifname != NULL) { /* Already allocated ! */
|
||||
LogPrintf(LogERROR, "bundle_Create: There's only one BUNDLE !\n");
|
||||
log_Printf(LogERROR, "bundle_Create: There's only one BUNDLE !\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@ -447,16 +447,16 @@ bundle_Create(const char *prefix, struct prompt *prompt, int type)
|
||||
}
|
||||
|
||||
if (bundle.tun_fd < 0) {
|
||||
LogPrintf(LogWARN, "No available tunnel devices found (%s).\n",
|
||||
log_Printf(LogWARN, "No available tunnel devices found (%s).\n",
|
||||
strerror(err));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
LogSetTun(bundle.unit);
|
||||
log_SetTun(bundle.unit);
|
||||
|
||||
s = socket(AF_INET, SOCK_DGRAM, 0);
|
||||
if (s < 0) {
|
||||
LogPrintf(LogERROR, "bundle_Create: socket(): %s\n", strerror(errno));
|
||||
log_Printf(LogERROR, "bundle_Create: socket(): %s\n", strerror(errno));
|
||||
close(bundle.tun_fd);
|
||||
return NULL;
|
||||
}
|
||||
@ -474,7 +474,7 @@ bundle_Create(const char *prefix, struct prompt *prompt, int type)
|
||||
strncpy(ifrq.ifr_name, bundle.ifname, sizeof ifrq.ifr_name - 1);
|
||||
ifrq.ifr_name[sizeof ifrq.ifr_name - 1] = '\0';
|
||||
if (ID0ioctl(s, SIOCGIFFLAGS, &ifrq) < 0) {
|
||||
LogPrintf(LogERROR, "OpenTunnel: ioctl(SIOCGIFFLAGS): %s\n",
|
||||
log_Printf(LogERROR, "OpenTunnel: ioctl(SIOCGIFFLAGS): %s\n",
|
||||
strerror(errno));
|
||||
close(s);
|
||||
close(bundle.tun_fd);
|
||||
@ -483,7 +483,7 @@ bundle_Create(const char *prefix, struct prompt *prompt, int type)
|
||||
}
|
||||
ifrq.ifr_flags |= IFF_UP;
|
||||
if (ID0ioctl(s, SIOCSIFFLAGS, &ifrq) < 0) {
|
||||
LogPrintf(LogERROR, "OpenTunnel: ioctl(SIOCSIFFLAGS): %s\n",
|
||||
log_Printf(LogERROR, "OpenTunnel: ioctl(SIOCSIFFLAGS): %s\n",
|
||||
strerror(errno));
|
||||
close(s);
|
||||
close(bundle.tun_fd);
|
||||
@ -494,14 +494,14 @@ bundle_Create(const char *prefix, struct prompt *prompt, int type)
|
||||
close(s);
|
||||
|
||||
if ((bundle.ifIndex = GetIfIndex(bundle.ifname)) < 0) {
|
||||
LogPrintf(LogERROR, "OpenTunnel: Can't find ifindex.\n");
|
||||
log_Printf(LogERROR, "OpenTunnel: Can't find ifindex.\n");
|
||||
close(bundle.tun_fd);
|
||||
bundle.ifname = NULL;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
prompt_Printf(prompt, "Using interface: %s\n", bundle.ifname);
|
||||
LogPrintf(LogPHASE, "Using interface: %s\n", bundle.ifname);
|
||||
log_Printf(LogPHASE, "Using interface: %s\n", bundle.ifname);
|
||||
|
||||
bundle.routing_seq = 0;
|
||||
bundle.phase = PHASE_DEAD;
|
||||
@ -523,7 +523,7 @@ bundle_Create(const char *prefix, struct prompt *prompt, int type)
|
||||
|
||||
bundle.links = datalink_Create("deflink", &bundle, type);
|
||||
if (bundle.links == NULL) {
|
||||
LogPrintf(LogERROR, "Cannot create data link: %s\n", strerror(errno));
|
||||
log_Printf(LogERROR, "Cannot create data link: %s\n", strerror(errno));
|
||||
close(bundle.tun_fd);
|
||||
bundle.ifname = NULL;
|
||||
return NULL;
|
||||
@ -573,11 +573,11 @@ bundle_DownInterface(struct bundle *bundle)
|
||||
struct ifreq ifrq;
|
||||
int s;
|
||||
|
||||
DeleteIfRoutes(bundle, 1);
|
||||
route_IfDelete(bundle, 1);
|
||||
|
||||
s = ID0socket(AF_INET, SOCK_DGRAM, 0);
|
||||
if (s < 0) {
|
||||
LogPrintf(LogERROR, "bundle_DownInterface: socket: %s\n", strerror(errno));
|
||||
log_Printf(LogERROR, "bundle_DownInterface: socket: %s\n", strerror(errno));
|
||||
return;
|
||||
}
|
||||
|
||||
@ -585,14 +585,14 @@ bundle_DownInterface(struct bundle *bundle)
|
||||
strncpy(ifrq.ifr_name, bundle->ifname, sizeof ifrq.ifr_name - 1);
|
||||
ifrq.ifr_name[sizeof ifrq.ifr_name - 1] = '\0';
|
||||
if (ID0ioctl(s, SIOCGIFFLAGS, &ifrq) < 0) {
|
||||
LogPrintf(LogERROR, "bundle_DownInterface: ioctl(SIOCGIFFLAGS): %s\n",
|
||||
log_Printf(LogERROR, "bundle_DownInterface: ioctl(SIOCGIFFLAGS): %s\n",
|
||||
strerror(errno));
|
||||
close(s);
|
||||
return;
|
||||
}
|
||||
ifrq.ifr_flags &= ~IFF_UP;
|
||||
if (ID0ioctl(s, SIOCSIFFLAGS, &ifrq) < 0) {
|
||||
LogPrintf(LogERROR, "bundle_DownInterface: ioctl(SIOCSIFFLAGS): %s\n",
|
||||
log_Printf(LogERROR, "bundle_DownInterface: ioctl(SIOCSIFFLAGS): %s\n",
|
||||
strerror(errno));
|
||||
close(s);
|
||||
return;
|
||||
@ -607,7 +607,7 @@ bundle_Destroy(struct bundle *bundle)
|
||||
struct descriptor *desc, *ndesc;
|
||||
|
||||
if (bundle->phys_type & PHYS_DEMAND) {
|
||||
IpcpCleanInterface(&bundle->ncp.ipcp);
|
||||
ipcp_CleanInterface(&bundle->ncp.ipcp);
|
||||
bundle_DownInterface(bundle);
|
||||
}
|
||||
|
||||
@ -623,7 +623,7 @@ bundle_Destroy(struct bundle *bundle)
|
||||
if (desc->type == PROMPT_DESCRIPTOR)
|
||||
prompt_Destroy((struct prompt *)desc, 1);
|
||||
else
|
||||
LogPrintf(LogERROR, "bundle_Destroy: Don't know how to delete descriptor"
|
||||
log_Printf(LogERROR, "bundle_Destroy: Don't know how to delete descriptor"
|
||||
" type %d\n", desc->type);
|
||||
desc = ndesc;
|
||||
}
|
||||
@ -652,7 +652,7 @@ bundle_SetRoute(struct bundle *bundle, int cmd, struct in_addr dst,
|
||||
cmdstr = (cmd == RTM_ADD ? "Add" : "Delete");
|
||||
s = ID0socket(PF_ROUTE, SOCK_RAW, 0);
|
||||
if (s < 0) {
|
||||
LogPrintf(LogERROR, "bundle_SetRoute: socket(): %s\n", strerror(errno));
|
||||
log_Printf(LogERROR, "bundle_SetRoute: socket(): %s\n", strerror(errno));
|
||||
return;
|
||||
}
|
||||
memset(&rtmes, '\0', sizeof rtmes);
|
||||
@ -714,16 +714,16 @@ bundle_SetRoute(struct bundle *bundle, int cmd, struct in_addr dst,
|
||||
rtmes.m_rtm.rtm_msglen = nb;
|
||||
wb = ID0write(s, &rtmes, nb);
|
||||
if (wb < 0) {
|
||||
LogPrintf(LogTCPIP, "bundle_SetRoute failure:\n");
|
||||
LogPrintf(LogTCPIP, "bundle_SetRoute: Cmd = %s\n", cmdstr);
|
||||
LogPrintf(LogTCPIP, "bundle_SetRoute: Dst = %s\n", inet_ntoa(dst));
|
||||
LogPrintf(LogTCPIP, "bundle_SetRoute: Gateway = %s\n", inet_ntoa(gateway));
|
||||
LogPrintf(LogTCPIP, "bundle_SetRoute: Mask = %s\n", inet_ntoa(mask));
|
||||
log_Printf(LogTCPIP, "bundle_SetRoute failure:\n");
|
||||
log_Printf(LogTCPIP, "bundle_SetRoute: Cmd = %s\n", cmdstr);
|
||||
log_Printf(LogTCPIP, "bundle_SetRoute: Dst = %s\n", inet_ntoa(dst));
|
||||
log_Printf(LogTCPIP, "bundle_SetRoute: Gateway = %s\n", inet_ntoa(gateway));
|
||||
log_Printf(LogTCPIP, "bundle_SetRoute: Mask = %s\n", inet_ntoa(mask));
|
||||
failed:
|
||||
if (cmd == RTM_ADD && (rtmes.m_rtm.rtm_errno == EEXIST ||
|
||||
(rtmes.m_rtm.rtm_errno == 0 && errno == EEXIST))) {
|
||||
if (!bang)
|
||||
LogPrintf(LogWARN, "Add route failed: %s already exists\n",
|
||||
log_Printf(LogWARN, "Add route failed: %s already exists\n",
|
||||
inet_ntoa(dst));
|
||||
else {
|
||||
rtmes.m_rtm.rtm_type = cmd = RTM_CHANGE;
|
||||
@ -734,16 +734,16 @@ bundle_SetRoute(struct bundle *bundle, int cmd, struct in_addr dst,
|
||||
(rtmes.m_rtm.rtm_errno == ESRCH ||
|
||||
(rtmes.m_rtm.rtm_errno == 0 && errno == ESRCH))) {
|
||||
if (!bang)
|
||||
LogPrintf(LogWARN, "Del route failed: %s: Non-existent\n",
|
||||
log_Printf(LogWARN, "Del route failed: %s: Non-existent\n",
|
||||
inet_ntoa(dst));
|
||||
} else if (rtmes.m_rtm.rtm_errno == 0)
|
||||
LogPrintf(LogWARN, "%s route failed: %s: errno: %s\n", cmdstr,
|
||||
log_Printf(LogWARN, "%s route failed: %s: errno: %s\n", cmdstr,
|
||||
inet_ntoa(dst), strerror(errno));
|
||||
else
|
||||
LogPrintf(LogWARN, "%s route failed: %s: %s\n",
|
||||
log_Printf(LogWARN, "%s route failed: %s: %s\n",
|
||||
cmdstr, inet_ntoa(dst), strerror(rtmes.m_rtm.rtm_errno));
|
||||
}
|
||||
LogPrintf(LogDEBUG, "wrote %d: cmd = %s, dst = %x, gateway = %x\n",
|
||||
log_Printf(LogDEBUG, "wrote %d: cmd = %s, dst = %x, gateway = %x\n",
|
||||
wb, cmdstr, (unsigned)dst.s_addr, (unsigned)gateway.s_addr);
|
||||
close(s);
|
||||
}
|
||||
@ -770,8 +770,8 @@ bundle_LinkClosed(struct bundle *bundle, struct datalink *dl)
|
||||
bundle_DownInterface(bundle);
|
||||
if (bundle->ncp.ipcp.fsm.state > ST_CLOSED ||
|
||||
bundle->ncp.ipcp.fsm.state == ST_STARTING) {
|
||||
FsmDown(&bundle->ncp.ipcp.fsm);
|
||||
FsmClose(&bundle->ncp.ipcp.fsm); /* ST_INITIAL please */
|
||||
fsm_Down(&bundle->ncp.ipcp.fsm);
|
||||
fsm_Close(&bundle->ncp.ipcp.fsm); /* ST_INITIAL please */
|
||||
}
|
||||
bundle_NewPhase(bundle, PHASE_DEAD);
|
||||
bundle_DisplayPrompt(bundle);
|
||||
@ -820,7 +820,7 @@ bundle_FillQueues(struct bundle *bundle)
|
||||
} else {
|
||||
total = link_QueueLen(&bundle->links->physical->link);
|
||||
if (total == 0 && bundle->links->physical->out == NULL)
|
||||
total = IpFlushPacket(&bundle->links->physical->link, bundle);
|
||||
total = ip_FlushPacket(&bundle->links->physical->link, bundle);
|
||||
}
|
||||
|
||||
return total + ip_QueueLen();
|
||||
@ -891,7 +891,7 @@ bundle_IdleTimeout(void *v)
|
||||
struct bundle *bundle = (struct bundle *)v;
|
||||
|
||||
bundle->idle.done = 0;
|
||||
LogPrintf(LogPHASE, "Idle timer expired.\n");
|
||||
log_Printf(LogPHASE, "Idle timer expired.\n");
|
||||
bundle_Close(bundle, NULL, 1);
|
||||
}
|
||||
|
||||
@ -903,13 +903,13 @@ void
|
||||
bundle_StartIdleTimer(struct bundle *bundle)
|
||||
{
|
||||
if (!(bundle->phys_type & (PHYS_DEDICATED|PHYS_PERM))) {
|
||||
StopTimer(&bundle->idle.timer);
|
||||
timer_Stop(&bundle->idle.timer);
|
||||
if (bundle->cfg.idle_timeout) {
|
||||
bundle->idle.timer.func = bundle_IdleTimeout;
|
||||
bundle->idle.timer.name = "idle";
|
||||
bundle->idle.timer.load = bundle->cfg.idle_timeout * SECTICKS;
|
||||
bundle->idle.timer.arg = bundle;
|
||||
StartTimer(&bundle->idle.timer);
|
||||
timer_Start(&bundle->idle.timer);
|
||||
bundle->idle.done = time(NULL) + bundle->cfg.idle_timeout;
|
||||
}
|
||||
}
|
||||
@ -926,7 +926,7 @@ bundle_SetIdleTimer(struct bundle *bundle, int value)
|
||||
void
|
||||
bundle_StopIdleTimer(struct bundle *bundle)
|
||||
{
|
||||
StopTimer(&bundle->idle.timer);
|
||||
timer_Stop(&bundle->idle.timer);
|
||||
bundle->idle.done = 0;
|
||||
}
|
||||
|
||||
@ -1101,14 +1101,14 @@ bundle_ReceiveDatalink(struct bundle *bundle, int fd)
|
||||
* We then pass the rest of the stream to datalink.
|
||||
*/
|
||||
|
||||
LogPrintf(LogPHASE, "Receiving datalink\n");
|
||||
log_Printf(LogPHASE, "Receiving datalink\n");
|
||||
|
||||
vlen = strlen(Version);
|
||||
get = sizeof(int) * 2 + vlen;
|
||||
buf = (u_char *)malloc(get);
|
||||
got = fullread(fd, buf, get);
|
||||
if (got != get) {
|
||||
LogPrintf(LogWARN, "Cannot receive datalink header"
|
||||
log_Printf(LogWARN, "Cannot receive datalink header"
|
||||
" (got %d bytes, not %d)\n", got, get);
|
||||
close(fd);
|
||||
free(buf);
|
||||
@ -1116,7 +1116,7 @@ bundle_ReceiveDatalink(struct bundle *bundle, int fd)
|
||||
}
|
||||
if (*(int *)buf != vlen || *(int *)(buf + sizeof(int) + vlen) != sizeof *dl ||
|
||||
memcmp(buf + sizeof(int), Version, vlen)) {
|
||||
LogPrintf(LogWARN, "Cannot receive datalink, incorrect version\n");
|
||||
log_Printf(LogWARN, "Cannot receive datalink, incorrect version\n");
|
||||
close(fd);
|
||||
free(buf);
|
||||
return;
|
||||
@ -1137,7 +1137,7 @@ bundle_ReceiveDatalink(struct bundle *bundle, int fd)
|
||||
ndl->next = bundle->links;
|
||||
bundle->links = ndl;
|
||||
bundle_GenPhysType(bundle);
|
||||
LogPrintf(LogPHASE, "%s: Created in %s state\n",
|
||||
log_Printf(LogPHASE, "%s: Created in %s state\n",
|
||||
ndl->name, datalink_State(ndl));
|
||||
datalink_AuthOk(ndl);
|
||||
}
|
||||
@ -1159,7 +1159,7 @@ bundle_SendDatalink(struct datalink *dl, int ppp_fd)
|
||||
* We then pass the rest of the stream to datalink.
|
||||
*/
|
||||
|
||||
LogPrintf(LogPHASE, "Transmitting datalink %s\n", dl->name);
|
||||
log_Printf(LogPHASE, "Transmitting datalink %s\n", dl->name);
|
||||
|
||||
/* First, un-hook the datalink */
|
||||
for (pdl = &bundle->links; *pdl; pdl = &(*pdl)->next)
|
||||
@ -1181,7 +1181,7 @@ bundle_SendDatalink(struct datalink *dl, int ppp_fd)
|
||||
err++;
|
||||
|
||||
if (err) {
|
||||
LogPrintf(LogERROR, "Failed sending version\n");
|
||||
log_Printf(LogERROR, "Failed sending version\n");
|
||||
close(ppp_fd);
|
||||
ppp_fd = -1;
|
||||
}
|
||||
@ -1191,7 +1191,7 @@ bundle_SendDatalink(struct datalink *dl, int ppp_fd)
|
||||
if (link_fd != -1) {
|
||||
switch (fork()) {
|
||||
case 0:
|
||||
TermTimerService();
|
||||
timer_TermService();
|
||||
|
||||
ppp_fd = fcntl(ppp_fd, F_DUPFD, 3);
|
||||
link_fd = fcntl(link_fd, F_DUPFD, 3);
|
||||
@ -1214,7 +1214,7 @@ bundle_SendDatalink(struct datalink *dl, int ppp_fd)
|
||||
dl->name, *dl->physical->name.base ?
|
||||
dl->physical->name.base : "network");
|
||||
execl(CATPROG, procname, NULL);
|
||||
LogPrintf(LogERROR, "exec: %s: %s\n", CATPROG, strerror(errno));
|
||||
log_Printf(LogERROR, "exec: %s: %s\n", CATPROG, strerror(errno));
|
||||
break;
|
||||
case -1:
|
||||
break;
|
||||
@ -1225,13 +1225,13 @@ bundle_SendDatalink(struct datalink *dl, int ppp_fd)
|
||||
dl->name, *dl->physical->name.base ?
|
||||
dl->physical->name.base : "network");
|
||||
execl(CATPROG, procname, NULL);
|
||||
LogPrintf(LogERROR, "exec: %s: %s\n", CATPROG, strerror(errno));
|
||||
log_Printf(LogERROR, "exec: %s: %s\n", CATPROG, strerror(errno));
|
||||
break;
|
||||
}
|
||||
exit(1);
|
||||
break;
|
||||
case -1:
|
||||
LogPrintf(LogERROR, "fork: %s\n", strerror(errno));
|
||||
log_Printf(LogERROR, "fork: %s\n", strerror(errno));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -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.30.2.40 1998/04/28 01:25:07 brian Exp $
|
||||
* $Id: ccp.c,v 1.30.2.41 1998/04/30 23:53:23 brian Exp $
|
||||
*
|
||||
* TODO:
|
||||
* o Support other compression protocols
|
||||
@ -132,7 +132,7 @@ static const struct ccp_algorithm *algorithm[] = {
|
||||
int
|
||||
ccp_ReportStatus(struct cmdargs const *arg)
|
||||
{
|
||||
struct link *l = ChooseLink(arg);
|
||||
struct link *l = command_ChooseLink(arg);
|
||||
struct ccp *ccp = &l->ccp;
|
||||
|
||||
prompt_Printf(arg->prompt, "%s: %s [%s]\n", l->name, ccp->fsm.name,
|
||||
@ -245,7 +245,7 @@ CcpSendConfigReq(struct fsm *fp)
|
||||
}
|
||||
|
||||
if (cp + (*o)->val.len > buff + sizeof buff) {
|
||||
LogPrintf(LogERROR, "%s: CCP REQ buffer overrun !\n", fp->link->name);
|
||||
log_Printf(LogERROR, "%s: CCP REQ buffer overrun !\n", fp->link->name);
|
||||
break;
|
||||
}
|
||||
memcpy(cp, &(*o)->val, (*o)->val.len);
|
||||
@ -258,18 +258,18 @@ CcpSendConfigReq(struct fsm *fp)
|
||||
o = &(*o)->next;
|
||||
}
|
||||
|
||||
FsmOutput(fp, CODE_CONFIGREQ, fp->reqid, buff, cp - buff);
|
||||
fsm_Output(fp, CODE_CONFIGREQ, fp->reqid, buff, cp - buff);
|
||||
}
|
||||
|
||||
void
|
||||
CcpSendResetReq(struct fsm *fp)
|
||||
ccp_SendResetReq(struct fsm *fp)
|
||||
{
|
||||
/* We can't read our input - ask peer to reset */
|
||||
struct ccp *ccp = fsm2ccp(fp);
|
||||
|
||||
ccp->reset_sent = fp->reqid;
|
||||
ccp->last_reset = -1;
|
||||
FsmOutput(fp, CODE_RESETREQ, fp->reqid, NULL, 0);
|
||||
fsm_Output(fp, CODE_RESETREQ, fp->reqid, NULL, 0);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -282,7 +282,7 @@ static void
|
||||
CcpSendTerminateAck(struct fsm *fp, u_char id)
|
||||
{
|
||||
/* Send Term ACK please */
|
||||
FsmOutput(fp, CODE_TERMACK, id, NULL, 0);
|
||||
fsm_Output(fp, CODE_TERMACK, id, NULL, 0);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -298,7 +298,7 @@ static void
|
||||
CcpLayerStart(struct fsm *fp)
|
||||
{
|
||||
/* We're about to start up ! */
|
||||
LogPrintf(LogCCP, "%s: CcpLayerStart.\n", fp->link->name);
|
||||
log_Printf(LogCCP, "%s: CcpLayerStart.\n", fp->link->name);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -308,7 +308,7 @@ CcpLayerFinish(struct fsm *fp)
|
||||
struct ccp *ccp = fsm2ccp(fp);
|
||||
struct ccp_opt *next;
|
||||
|
||||
LogPrintf(LogCCP, "%s: CcpLayerFinish.\n", fp->link->name);
|
||||
log_Printf(LogCCP, "%s: CcpLayerFinish.\n", fp->link->name);
|
||||
if (ccp->in.state != NULL) {
|
||||
(*algorithm[ccp->in.algorithm]->i.Term)(ccp->in.state);
|
||||
ccp->in.state = NULL;
|
||||
@ -332,7 +332,7 @@ static void
|
||||
CcpLayerDown(struct fsm *fp)
|
||||
{
|
||||
/* About to come down */
|
||||
LogPrintf(LogCCP, "%s: CcpLayerDown.\n", fp->link->name);
|
||||
log_Printf(LogCCP, "%s: CcpLayerDown.\n", fp->link->name);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -343,15 +343,15 @@ CcpLayerUp(struct fsm *fp)
|
||||
{
|
||||
/* We're now up */
|
||||
struct ccp *ccp = fsm2ccp(fp);
|
||||
LogPrintf(LogCCP, "%s: CcpLayerUp.\n", fp->link->name);
|
||||
log_Printf(LogCCP, "%s: CcpLayerUp.\n", fp->link->name);
|
||||
if (ccp->in.state == NULL && ccp->in.algorithm >= 0 &&
|
||||
ccp->in.algorithm < NALGORITHMS) {
|
||||
ccp->in.state = (*algorithm[ccp->in.algorithm]->i.Init)(&ccp->in.opt);
|
||||
if (ccp->in.state == NULL) {
|
||||
LogPrintf(LogERROR, "%s: %s (in) initialisation failure\n",
|
||||
log_Printf(LogERROR, "%s: %s (in) initialisation failure\n",
|
||||
fp->link->name, protoname(ccp->his_proto));
|
||||
ccp->his_proto = ccp->my_proto = -1;
|
||||
FsmClose(fp);
|
||||
fsm_Close(fp);
|
||||
}
|
||||
}
|
||||
|
||||
@ -360,14 +360,14 @@ CcpLayerUp(struct fsm *fp)
|
||||
ccp->out.state = (*algorithm[ccp->out.algorithm]->o.Init)
|
||||
(&ccp->out.opt->val);
|
||||
if (ccp->out.state == NULL) {
|
||||
LogPrintf(LogERROR, "%s: %s (out) initialisation failure\n",
|
||||
log_Printf(LogERROR, "%s: %s (out) initialisation failure\n",
|
||||
fp->link->name, protoname(ccp->my_proto));
|
||||
ccp->his_proto = ccp->my_proto = -1;
|
||||
FsmClose(fp);
|
||||
fsm_Close(fp);
|
||||
}
|
||||
}
|
||||
|
||||
LogPrintf(LogCCP, "%s: Out = %s[%d], In = %s[%d]\n",
|
||||
log_Printf(LogCCP, "%s: Out = %s[%d], In = %s[%d]\n",
|
||||
fp->link->name, protoname(ccp->my_proto), ccp->my_proto,
|
||||
protoname(ccp->his_proto), ccp->his_proto);
|
||||
return 1;
|
||||
@ -388,13 +388,13 @@ CcpDecodeConfig(struct fsm *fp, u_char *cp, int plen, int mode_type,
|
||||
length = cp[1];
|
||||
|
||||
if (length == 0) {
|
||||
LogPrintf(LogCCP, "%s: CCP size zero\n", fp->link->name);
|
||||
log_Printf(LogCCP, "%s: CCP size zero\n", fp->link->name);
|
||||
break;
|
||||
}
|
||||
|
||||
if (length > sizeof(struct lcp_opt)) {
|
||||
length = sizeof(struct lcp_opt);
|
||||
LogPrintf(LogCCP, "%s: Warning: Truncating length to %d\n",
|
||||
log_Printf(LogCCP, "%s: Warning: Truncating length to %d\n",
|
||||
fp->link->name, length);
|
||||
}
|
||||
|
||||
@ -407,9 +407,9 @@ CcpDecodeConfig(struct fsm *fp, u_char *cp, int plen, int mode_type,
|
||||
end = "";
|
||||
|
||||
if (type < NCFTYPES)
|
||||
LogPrintf(LogCCP, " %s[%d] %s\n", cftypes[type], length, end);
|
||||
log_Printf(LogCCP, " %s[%d] %s\n", cftypes[type], length, end);
|
||||
else
|
||||
LogPrintf(LogCCP, " ???[%d] %s\n", length, end);
|
||||
log_Printf(LogCCP, " ???[%d] %s\n", length, end);
|
||||
|
||||
if (f == -1) {
|
||||
/* Don't understand that :-( */
|
||||
@ -452,7 +452,7 @@ CcpDecodeConfig(struct fsm *fp, u_char *cp, int plen, int mode_type,
|
||||
if (o->val.id == cp[0])
|
||||
break;
|
||||
if (o == NULL)
|
||||
LogPrintf(LogCCP, "%s: Warning: Ignoring peer NAK of unsent option\n",
|
||||
log_Printf(LogCCP, "%s: Warning: Ignoring peer NAK of unsent option\n",
|
||||
fp->link->name);
|
||||
else {
|
||||
memcpy(&o->val, cp, length);
|
||||
@ -496,15 +496,15 @@ CcpDecodeConfig(struct fsm *fp, u_char *cp, int plen, int mode_type,
|
||||
}
|
||||
|
||||
void
|
||||
CcpInput(struct ccp *ccp, struct bundle *bundle, struct mbuf *bp)
|
||||
ccp_Input(struct ccp *ccp, struct bundle *bundle, struct mbuf *bp)
|
||||
{
|
||||
/* Got PROTO_CCP from link */
|
||||
if (bundle_Phase(bundle) == PHASE_NETWORK)
|
||||
FsmInput(&ccp->fsm, bp);
|
||||
fsm_Input(&ccp->fsm, bp);
|
||||
else if (bundle_Phase(bundle) < PHASE_NETWORK) {
|
||||
LogPrintf(LogCCP, "%s: Error: Unexpected CCP in phase %s (ignored)\n",
|
||||
log_Printf(LogCCP, "%s: Error: Unexpected CCP in phase %s (ignored)\n",
|
||||
ccp->fsm.link->name, bundle_PhaseName(bundle));
|
||||
pfree(bp);
|
||||
mbuf_Free(bp);
|
||||
}
|
||||
}
|
||||
|
||||
@ -516,16 +516,16 @@ CcpRecvResetAck(struct fsm *fp, u_char id)
|
||||
|
||||
if (ccp->reset_sent != -1) {
|
||||
if (id != ccp->reset_sent) {
|
||||
LogPrintf(LogWARN, "CCP: %s: Incorrect ResetAck (id %d, not %d)"
|
||||
log_Printf(LogWARN, "CCP: %s: Incorrect ResetAck (id %d, not %d)"
|
||||
" ignored\n", fp->link->name, id, ccp->reset_sent);
|
||||
return;
|
||||
}
|
||||
/* Whaddaya know - a correct reset ack */
|
||||
} else if (id == ccp->last_reset)
|
||||
LogPrintf(LogCCP, "%s: Duplicate ResetAck (resetting again)\n",
|
||||
log_Printf(LogCCP, "%s: Duplicate ResetAck (resetting again)\n",
|
||||
fp->link->name);
|
||||
else {
|
||||
LogPrintf(LogWARN, "CCP: %s: Unexpected ResetAck (id %d) ignored\n",
|
||||
log_Printf(LogWARN, "CCP: %s: Unexpected ResetAck (id %d) ignored\n",
|
||||
fp->link->name, id);
|
||||
return;
|
||||
}
|
||||
@ -560,11 +560,11 @@ ccp_Decompress(struct ccp *ccp, u_short *proto, struct mbuf *bp)
|
||||
/* Decompress incoming data */
|
||||
if (ccp->reset_sent != -1)
|
||||
/* Send another REQ and put the packet in the bit bucket */
|
||||
FsmOutput(&ccp->fsm, CODE_RESETREQ, ccp->reset_sent, NULL, 0);
|
||||
fsm_Output(&ccp->fsm, CODE_RESETREQ, ccp->reset_sent, NULL, 0);
|
||||
else if (ccp->in.state != NULL)
|
||||
return (*algorithm[ccp->in.algorithm]->i.Read)
|
||||
(ccp->in.state, ccp, proto, bp);
|
||||
pfree(bp);
|
||||
mbuf_Free(bp);
|
||||
bp = NULL;
|
||||
} else if ((*proto & 0xfff1) == 0x21 && ccp->in.state != NULL)
|
||||
/* Add incoming Network Layer traffic to our dictionary */
|
||||
|
@ -15,7 +15,7 @@
|
||||
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* $Id: ccp.h,v 1.14.2.18 1998/04/24 19:15:24 brian Exp $
|
||||
* $Id: ccp.h,v 1.14.2.19 1998/04/30 23:53:24 brian Exp $
|
||||
*
|
||||
* TODO:
|
||||
*/
|
||||
@ -118,8 +118,8 @@ extern void ccp_Init(struct ccp *, struct bundle *, struct link *,
|
||||
const struct fsm_parent *);
|
||||
extern void ccp_Setup(struct ccp *);
|
||||
|
||||
extern void CcpSendResetReq(struct fsm *);
|
||||
extern void CcpInput(struct ccp *, struct bundle *, struct mbuf *);
|
||||
extern void ccp_SendResetReq(struct fsm *);
|
||||
extern void ccp_Input(struct ccp *, struct bundle *, struct mbuf *);
|
||||
extern int ccp_ReportStatus(struct cmdargs const *);
|
||||
extern int ccp_Compress(struct ccp *, struct link *, int, u_short, struct mbuf *);
|
||||
extern struct mbuf *ccp_Decompress(struct ccp *, u_short *, struct mbuf *);
|
||||
|
@ -17,7 +17,7 @@
|
||||
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* $Id: chap.c,v 1.28.2.25 1998/04/24 19:15:58 brian Exp $
|
||||
* $Id: chap.c,v 1.28.2.26 1998/04/28 01:25:08 brian Exp $
|
||||
*
|
||||
* TODO:
|
||||
*/
|
||||
@ -73,17 +73,17 @@ ChapOutput(struct physical *physical, u_int code, u_int id,
|
||||
lh.code = code;
|
||||
lh.id = id;
|
||||
lh.length = htons(plen);
|
||||
bp = mballoc(plen, MB_FSM);
|
||||
bp = mbuf_Alloc(plen, MB_FSM);
|
||||
memcpy(MBUF_CTOP(bp), &lh, sizeof(struct fsmheader));
|
||||
if (count)
|
||||
memcpy(MBUF_CTOP(bp) + sizeof(struct fsmheader), ptr, count);
|
||||
LogDumpBp(LogDEBUG, "ChapOutput", bp);
|
||||
LogPrintf(LogLCP, "ChapOutput: %s\n", chapcodes[code]);
|
||||
HdlcOutput(physical2link(physical), PRI_LINK, PROTO_CHAP, bp);
|
||||
log_DumpBp(LogDEBUG, "ChapOutput", bp);
|
||||
log_Printf(LogLCP, "ChapOutput: %s\n", chapcodes[code]);
|
||||
hdlc_Output(&physical->link, PRI_LINK, PROTO_CHAP, bp);
|
||||
}
|
||||
|
||||
void
|
||||
SendChapChallenge(struct authinfo *auth, int chapid, struct physical *physical)
|
||||
chap_SendChallenge(struct authinfo *auth, int chapid, struct physical *physical)
|
||||
{
|
||||
struct chap *chap = auth2chap(auth);
|
||||
int len, i;
|
||||
@ -118,14 +118,14 @@ RecvChapTalk(struct bundle *bundle, struct fsmheader *chp, struct mbuf *bp,
|
||||
#endif
|
||||
|
||||
len = ntohs(chp->length);
|
||||
LogPrintf(LogDEBUG, "RecvChapTalk: length: %d\n", len);
|
||||
log_Printf(LogDEBUG, "RecvChapTalk: length: %d\n", len);
|
||||
arglen = len - sizeof(struct fsmheader);
|
||||
cp = (char *) MBUF_CTOP(bp);
|
||||
valsize = *cp++ & 255;
|
||||
name = cp + valsize;
|
||||
namelen = arglen - valsize - 1;
|
||||
name[namelen] = 0;
|
||||
LogPrintf(LogLCP, " Valsize = %d, Name = \"%s\"\n", valsize, name);
|
||||
log_Printf(LogLCP, " Valsize = %d, Name = \"%s\"\n", valsize, name);
|
||||
|
||||
switch (chp->code) {
|
||||
case CHAP_CHALLENGE:
|
||||
@ -156,7 +156,7 @@ RecvChapTalk(struct bundle *bundle, struct fsmheader *chp, struct mbuf *bp,
|
||||
memcpy(ap, keyp, keylen);
|
||||
ap += 2 * keylen;
|
||||
memcpy(ap, cp, valsize);
|
||||
LogDumpBuff(LogDEBUG, "recv", ap, valsize);
|
||||
log_DumpBuff(LogDEBUG, "recv", ap, valsize);
|
||||
ap += valsize;
|
||||
for (ix = keylen; ix > 0 ; ix--) {
|
||||
answer[2*ix-2] = answer[ix-1];
|
||||
@ -167,8 +167,8 @@ RecvChapTalk(struct bundle *bundle, struct fsmheader *chp, struct mbuf *bp,
|
||||
MD4Final(digest, &MD4context);
|
||||
memcpy(digest + 25, name, namelen);
|
||||
ap += 2 * keylen;
|
||||
ChapMS(digest, answer + 2 * keylen, valsize);
|
||||
LogDumpBuff(LogDEBUG, "answer", digest, 24);
|
||||
chap_MS(digest, answer + 2 * keylen, valsize);
|
||||
log_DumpBuff(LogDEBUG, "answer", digest, 24);
|
||||
ChapOutput(physical, CHAP_RESPONSE, chp->id, argp,
|
||||
namelen + MS_CHAP_RESPONSE_LEN + 1);
|
||||
} else {
|
||||
@ -180,12 +180,12 @@ RecvChapTalk(struct bundle *bundle, struct fsmheader *chp, struct mbuf *bp,
|
||||
memcpy(ap, keyp, keylen);
|
||||
ap += keylen;
|
||||
memcpy(ap, cp, valsize);
|
||||
LogDumpBuff(LogDEBUG, "recv", ap, valsize);
|
||||
log_DumpBuff(LogDEBUG, "recv", ap, valsize);
|
||||
ap += valsize;
|
||||
MD5Init(&MD5context);
|
||||
MD5Update(&MD5context, answer, ap - answer);
|
||||
MD5Final(digest, &MD5context);
|
||||
LogDumpBuff(LogDEBUG, "answer", digest, 16);
|
||||
log_DumpBuff(LogDEBUG, "answer", digest, 16);
|
||||
memcpy(digest + 16, name, namelen);
|
||||
ap += namelen;
|
||||
/* Send answer to the peer */
|
||||
@ -199,7 +199,7 @@ RecvChapTalk(struct bundle *bundle, struct fsmheader *chp, struct mbuf *bp,
|
||||
/*
|
||||
* Get a secret key corresponds to the peer
|
||||
*/
|
||||
keyp = AuthGetSecret(bundle, name, namelen, physical);
|
||||
keyp = auth_GetSecret(bundle, name, namelen, physical);
|
||||
if (keyp) {
|
||||
/*
|
||||
* Compute correct digest value
|
||||
@ -214,8 +214,8 @@ RecvChapTalk(struct bundle *bundle, struct fsmheader *chp, struct mbuf *bp,
|
||||
MD5Update(&MD5context, physical->dl->chap.challenge_data + 1,
|
||||
physical->dl->chap.challenge_len);
|
||||
MD5Final(cdigest, &MD5context);
|
||||
LogDumpBuff(LogDEBUG, "got", cp, 16);
|
||||
LogDumpBuff(LogDEBUG, "expect", cdigest, 16);
|
||||
log_DumpBuff(LogDEBUG, "got", cp, 16);
|
||||
log_DumpBuff(LogDEBUG, "expect", cdigest, 16);
|
||||
|
||||
/*
|
||||
* Compare with the response
|
||||
@ -224,7 +224,7 @@ RecvChapTalk(struct bundle *bundle, struct fsmheader *chp, struct mbuf *bp,
|
||||
datalink_GotAuthname(physical->dl, name, namelen);
|
||||
ChapOutput(physical, CHAP_SUCCESS, chp->id, "Welcome!!", 10);
|
||||
if (Enabled(bundle, OPT_UTMP))
|
||||
Physical_Login(physical, name);
|
||||
physical_Login(physical, name);
|
||||
|
||||
if (physical->link.lcp.auth_iwait == 0)
|
||||
/*
|
||||
@ -253,7 +253,7 @@ RecvChapResult(struct bundle *bundle, struct fsmheader *chp, struct mbuf *bp,
|
||||
int len;
|
||||
|
||||
len = ntohs(chp->length);
|
||||
LogPrintf(LogDEBUG, "RecvChapResult: length: %d\n", len);
|
||||
log_Printf(LogDEBUG, "RecvChapResult: length: %d\n", len);
|
||||
if (chp->code == CHAP_SUCCESS) {
|
||||
if (physical->link.lcp.auth_iwait == PROTO_CHAP) {
|
||||
physical->link.lcp.auth_iwait = 0;
|
||||
@ -267,15 +267,15 @@ RecvChapResult(struct bundle *bundle, struct fsmheader *chp, struct mbuf *bp,
|
||||
}
|
||||
} else {
|
||||
/* CHAP failed - it's not going to get any better */
|
||||
LogPrintf(LogPHASE, "Received CHAP_FAILURE\n");
|
||||
log_Printf(LogPHASE, "Received CHAP_FAILURE\n");
|
||||
datalink_AuthNotOk(physical->dl);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
ChapInput(struct bundle *bundle, struct mbuf *bp, struct physical *physical)
|
||||
chap_Input(struct bundle *bundle, struct mbuf *bp, struct physical *physical)
|
||||
{
|
||||
int len = plength(bp);
|
||||
int len = mbuf_Length(bp);
|
||||
struct fsmheader *chp;
|
||||
|
||||
if (len >= sizeof(struct fsmheader)) {
|
||||
@ -283,14 +283,14 @@ ChapInput(struct bundle *bundle, struct mbuf *bp, struct physical *physical)
|
||||
if (len >= ntohs(chp->length)) {
|
||||
if (chp->code < 1 || chp->code > 4)
|
||||
chp->code = 0;
|
||||
LogPrintf(LogLCP, "ChapInput: %s\n", chapcodes[chp->code]);
|
||||
log_Printf(LogLCP, "chap_Input: %s\n", chapcodes[chp->code]);
|
||||
|
||||
bp->offset += sizeof(struct fsmheader);
|
||||
bp->cnt -= sizeof(struct fsmheader);
|
||||
|
||||
switch (chp->code) {
|
||||
case CHAP_RESPONSE:
|
||||
StopAuthTimer(&physical->dl->chap.auth);
|
||||
auth_StopTimer(&physical->dl->chap.auth);
|
||||
/* Fall into.. */
|
||||
case CHAP_CHALLENGE:
|
||||
RecvChapTalk(bundle, chp, bp, physical);
|
||||
@ -302,5 +302,5 @@ ChapInput(struct bundle *bundle, struct mbuf *bp, struct physical *physical)
|
||||
}
|
||||
}
|
||||
}
|
||||
pfree(bp);
|
||||
mbuf_Free(bp);
|
||||
}
|
||||
|
@ -15,7 +15,7 @@
|
||||
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* $Id: chap.h,v 1.9.2.4 1998/04/03 19:26:18 brian Exp $
|
||||
* $Id: chap.h,v 1.9.2.5 1998/04/07 00:53:26 brian Exp $
|
||||
*
|
||||
* TODO:
|
||||
*/
|
||||
@ -38,5 +38,5 @@ struct chap {
|
||||
|
||||
#define auth2chap(a) ((struct chap *)(a))
|
||||
|
||||
extern void ChapInput(struct bundle *, struct mbuf *, struct physical *);
|
||||
extern void SendChapChallenge(struct authinfo *, int, struct physical *);
|
||||
extern void chap_Input(struct bundle *, struct mbuf *, struct physical *);
|
||||
extern void chap_SendChallenge(struct authinfo *, int, struct physical *);
|
||||
|
@ -19,7 +19,7 @@
|
||||
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* $Id: chap_ms.c,v 1.5.4.1 1998/03/16 22:53:08 brian Exp $
|
||||
* $Id: chap_ms.c,v 1.5.4.2 1998/04/06 09:12:24 brian Exp $
|
||||
*
|
||||
*/
|
||||
|
||||
@ -97,7 +97,7 @@ static void MakeKey(u_char *key, u_char *des_key)
|
||||
challenge 8-bytes peer CHAP challenge
|
||||
since passwordHash is in a 24-byte buffer, response is written in there */
|
||||
void
|
||||
ChapMS(char *passwordHash, char *challenge, int challenge_len)
|
||||
chap_MS(char *passwordHash, char *challenge, int challenge_len)
|
||||
{
|
||||
u_char response[24];
|
||||
|
||||
|
@ -19,7 +19,7 @@
|
||||
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* $Id: chap_ms.h,v 1.1 1997/09/25 00:58:20 brian Exp $
|
||||
* $Id: chap_ms.h,v 1.2 1997/10/26 01:02:20 brian Exp $
|
||||
*/
|
||||
|
||||
/* Max # of (Unicode) chars in an NT password */
|
||||
@ -28,4 +28,4 @@
|
||||
/* Don't rely on sizeof(MS_ChapResponse) in case of struct padding */
|
||||
#define MS_CHAP_RESPONSE_LEN 49
|
||||
|
||||
extern void ChapMS(char *, char *, int);
|
||||
extern void chap_MS(char *, char *, int);
|
||||
|
@ -23,7 +23,7 @@
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $Id: chat.c,v 1.44.2.27 1998/04/30 23:53:26 brian Exp $
|
||||
* $Id: chat.c,v 1.44.2.28 1998/05/01 19:22:14 brian Exp $
|
||||
*/
|
||||
|
||||
#include <sys/types.h>
|
||||
@ -78,39 +78,39 @@ static void
|
||||
chat_PauseTimer(void *v)
|
||||
{
|
||||
struct chat *c = (struct chat *)v;
|
||||
StopTimer(&c->pause);
|
||||
timer_Stop(&c->pause);
|
||||
c->pause.load = 0;
|
||||
}
|
||||
|
||||
static void
|
||||
chat_Pause(struct chat *c, u_long load)
|
||||
{
|
||||
StopTimer(&c->pause);
|
||||
timer_Stop(&c->pause);
|
||||
c->pause.load += load;
|
||||
c->pause.func = chat_PauseTimer;
|
||||
c->pause.name = "chat pause";
|
||||
c->pause.arg = c;
|
||||
StartTimer(&c->pause);
|
||||
timer_Start(&c->pause);
|
||||
}
|
||||
|
||||
static void
|
||||
chat_TimeoutTimer(void *v)
|
||||
{
|
||||
struct chat *c = (struct chat *)v;
|
||||
StopTimer(&c->timeout);
|
||||
timer_Stop(&c->timeout);
|
||||
c->TimedOut = 1;
|
||||
}
|
||||
|
||||
static void
|
||||
chat_SetTimeout(struct chat *c)
|
||||
{
|
||||
StopTimer(&c->timeout);
|
||||
timer_Stop(&c->timeout);
|
||||
if (c->TimeoutSec > 0) {
|
||||
c->timeout.load = SECTICKS * c->TimeoutSec;
|
||||
c->timeout.func = chat_TimeoutTimer;
|
||||
c->timeout.name = "chat timeout";
|
||||
c->timeout.arg = c;
|
||||
StartTimer(&c->timeout);
|
||||
timer_Start(&c->timeout);
|
||||
}
|
||||
}
|
||||
|
||||
@ -139,7 +139,7 @@ chat_UpdateSet(struct descriptor *d, fd_set *r, fd_set *w, fd_set *e, int *n)
|
||||
return 0;
|
||||
|
||||
if (TimedOut) {
|
||||
LogPrintf(LogCHAT, "Expect timeout\n");
|
||||
log_Printf(LogCHAT, "Expect timeout\n");
|
||||
if (c->nargptr == NULL)
|
||||
c->state = CHAT_FAILED;
|
||||
else {
|
||||
@ -189,7 +189,7 @@ chat_UpdateSet(struct descriptor *d, fd_set *r, fd_set *w, fd_set *e, int *n)
|
||||
}
|
||||
|
||||
if (minus % 2)
|
||||
LogPrintf(LogWARN, "chat_UpdateSet: \"%s\": Uneven number of"
|
||||
log_Printf(LogWARN, "chat_UpdateSet: \"%s\": Uneven number of"
|
||||
" '-' chars, all ignored\n", c->argptr);
|
||||
else if (minus) {
|
||||
c->nargptr = chat_NextChar(c->argptr, '-');
|
||||
@ -229,7 +229,7 @@ chat_UpdateSet(struct descriptor *d, fd_set *r, fd_set *w, fd_set *e, int *n)
|
||||
memcpy(c->abort.string[i].data, c->exp+2, len+1);
|
||||
c->abort.num++;
|
||||
} else
|
||||
LogPrintf(LogERROR, "chat_UpdateSet: too many abort strings\n");
|
||||
log_Printf(LogERROR, "chat_UpdateSet: too many abort strings\n");
|
||||
gotabort = 0;
|
||||
} else if (gottimeout) {
|
||||
c->TimeoutSec = atoi(c->exp + 2);
|
||||
@ -256,9 +256,9 @@ chat_UpdateSet(struct descriptor *d, fd_set *r, fd_set *w, fd_set *e, int *n)
|
||||
|
||||
if (special) {
|
||||
if (gottimeout)
|
||||
LogPrintf(LogWARN, "chat_UpdateSet: TIMEOUT: Argument expected\n");
|
||||
log_Printf(LogWARN, "chat_UpdateSet: TIMEOUT: Argument expected\n");
|
||||
else if (gotabort)
|
||||
LogPrintf(LogWARN, "chat_UpdateSet: ABORT: Argument expected\n");
|
||||
log_Printf(LogWARN, "chat_UpdateSet: ABORT: Argument expected\n");
|
||||
|
||||
/* End of script - all ok */
|
||||
c->state = CHAT_DONE;
|
||||
@ -285,7 +285,7 @@ chat_UpdateSet(struct descriptor *d, fd_set *r, fd_set *w, fd_set *e, int *n)
|
||||
return chat_UpdateSet(d, r, w, e, n);
|
||||
}
|
||||
|
||||
LogPrintf(LogCHAT, "Expect(%d): %s\n", c->TimeoutSec, c->argptr);
|
||||
log_Printf(LogCHAT, "Expect(%d): %s\n", c->TimeoutSec, c->argptr);
|
||||
chat_SetTimeout(c);
|
||||
}
|
||||
}
|
||||
@ -297,22 +297,22 @@ chat_UpdateSet(struct descriptor *d, fd_set *r, fd_set *w, fd_set *e, int *n)
|
||||
*/
|
||||
|
||||
if (c->state == CHAT_EXPECT)
|
||||
return Physical_UpdateSet(&c->physical->desc, r, NULL, e, n, 1);
|
||||
return physical_UpdateSet(&c->physical->desc, r, NULL, e, n, 1);
|
||||
else
|
||||
return Physical_UpdateSet(&c->physical->desc, NULL, w, e, n, 1);
|
||||
return physical_UpdateSet(&c->physical->desc, NULL, w, e, n, 1);
|
||||
}
|
||||
|
||||
static int
|
||||
chat_IsSet(struct descriptor *d, const fd_set *fdset)
|
||||
{
|
||||
struct chat *c = descriptor2chat(d);
|
||||
return Physical_IsSet(&c->physical->desc, fdset);
|
||||
return physical_IsSet(&c->physical->desc, fdset);
|
||||
}
|
||||
|
||||
static void
|
||||
chat_UpdateLog(struct chat *c, int in)
|
||||
{
|
||||
if (LogIsKept(LogCHAT) || LogIsKept(LogCONNECT)) {
|
||||
if (log_IsKept(LogCHAT) || log_IsKept(LogCONNECT)) {
|
||||
/*
|
||||
* If a linefeed appears in the last `in' characters of `c's input
|
||||
* buffer, output from there, all the way back to the last linefeed.
|
||||
@ -321,7 +321,7 @@ chat_UpdateLog(struct chat *c, int in)
|
||||
char *ptr, *end, *stop, ch;
|
||||
int level;
|
||||
|
||||
level = LogIsKept(LogCHAT) ? LogCHAT : LogCONNECT;
|
||||
level = log_IsKept(LogCHAT) ? LogCHAT : LogCONNECT;
|
||||
if (in == -1)
|
||||
end = ptr = c->bufend;
|
||||
else {
|
||||
@ -343,7 +343,7 @@ chat_UpdateLog(struct chat *c, int in)
|
||||
ch = *stop;
|
||||
*stop = '\0';
|
||||
if (level == LogCHAT || strstr(ptr, "CONNECT"))
|
||||
LogPrintf(level, "Received: %s\n", ptr);
|
||||
log_Printf(level, "Received: %s\n", ptr);
|
||||
*stop = ch;
|
||||
ptr = stop + 1;
|
||||
}
|
||||
@ -369,7 +369,7 @@ chat_Read(struct descriptor *d, struct bundle *bundle, const fd_set *fdset)
|
||||
if (in > sizeof c->buf / 2)
|
||||
in = sizeof c->buf / 2;
|
||||
|
||||
in = Physical_Read(c->physical, c->bufend, in);
|
||||
in = physical_Read(c->physical, c->bufend, in);
|
||||
if (in <= 0)
|
||||
return;
|
||||
|
||||
@ -473,32 +473,32 @@ chat_Write(struct descriptor *d, struct bundle *bundle, const fd_set *fdset)
|
||||
int wrote;
|
||||
|
||||
if (strstr(c->argv[c->arg], "\\P")) /* Don't log the password */
|
||||
LogPrintf(LogCHAT, "Send: %s\n", c->argv[c->arg]);
|
||||
log_Printf(LogCHAT, "Send: %s\n", c->argv[c->arg]);
|
||||
else {
|
||||
int sz;
|
||||
|
||||
sz = c->arglen - 1;
|
||||
while (sz >= 0 && c->argptr[sz] == '\n')
|
||||
sz--;
|
||||
LogPrintf(LogCHAT, "Send: %.*s\n", sz + 1, c->argptr);
|
||||
log_Printf(LogCHAT, "Send: %.*s\n", sz + 1, c->argptr);
|
||||
}
|
||||
|
||||
if (Physical_IsSync(c->physical)) {
|
||||
if (physical_IsSync(c->physical)) {
|
||||
/* There's always room for the HDLC header */
|
||||
c->argptr -= 2;
|
||||
c->arglen += 2;
|
||||
memcpy(c->argptr, "\377\003", 2); /* Prepend HDLC header */
|
||||
}
|
||||
|
||||
wrote = Physical_Write(c->physical, c->argptr, c->arglen);
|
||||
wrote = physical_Write(c->physical, c->argptr, c->arglen);
|
||||
if (wrote == -1) {
|
||||
if (errno != EINTR)
|
||||
LogPrintf(LogERROR, "chat_Write: %s\n", strerror(errno));
|
||||
if (Physical_IsSync(c->physical)) {
|
||||
log_Printf(LogERROR, "chat_Write: %s\n", strerror(errno));
|
||||
if (physical_IsSync(c->physical)) {
|
||||
c->argptr += 2;
|
||||
c->arglen -= 2;
|
||||
}
|
||||
} else if (wrote < 2 && Physical_IsSync(c->physical)) {
|
||||
} else if (wrote < 2 && physical_IsSync(c->physical)) {
|
||||
/* Oops - didn't even write our HDLC header ! */
|
||||
c->argptr += 2;
|
||||
c->arglen -= 2;
|
||||
@ -551,8 +551,8 @@ chat_Init(struct chat *c, struct physical *p, const char *data, int emptybuf,
|
||||
void
|
||||
chat_Destroy(struct chat *c)
|
||||
{
|
||||
StopTimer(&c->pause);
|
||||
StopTimer(&c->timeout);
|
||||
timer_Stop(&c->pause);
|
||||
timer_Stop(&c->timeout);
|
||||
while (c->abort.num)
|
||||
free(c->abort.string[--c->abort.num].data);
|
||||
c->abort.num = 0;
|
||||
@ -718,20 +718,20 @@ ExecStr(struct physical *physical, char *command, char *out, int olen)
|
||||
char *vector[MAXARGS], *startout, *endout;
|
||||
int stat, nb;
|
||||
|
||||
LogPrintf(LogCHAT, "Exec: %s\n", command);
|
||||
log_Printf(LogCHAT, "Exec: %s\n", command);
|
||||
MakeArgs(command, vector, VECSIZE(vector));
|
||||
|
||||
if (pipe(fids) < 0) {
|
||||
LogPrintf(LogCHAT, "Unable to create pipe in ExecStr: %s\n",
|
||||
log_Printf(LogCHAT, "Unable to create pipe in ExecStr: %s\n",
|
||||
strerror(errno));
|
||||
*out = '\0';
|
||||
return;
|
||||
}
|
||||
if ((pid = fork()) == 0) {
|
||||
TermTimerService();
|
||||
timer_TermService();
|
||||
|
||||
fids[1] = fcntl(fids[1], F_DUPFD, 4);
|
||||
dup2(Physical_GetFD(physical), STDIN_FILENO);
|
||||
dup2(physical_GetFD(physical), STDIN_FILENO);
|
||||
dup2(STDIN_FILENO, STDOUT_FILENO);
|
||||
dup2(fids[1], STDERR_FILENO);
|
||||
close(3);
|
||||
@ -760,7 +760,7 @@ ExecStr(struct physical *physical, char *command, char *out, int olen)
|
||||
close(fids[1]);
|
||||
waitpid(pid, &stat, WNOHANG);
|
||||
if (WIFSIGNALED(stat)) {
|
||||
LogPrintf(LogWARN, "%s: signal %d\n", name, WTERMSIG(stat));
|
||||
log_Printf(LogWARN, "%s: signal %d\n", name, WTERMSIG(stat));
|
||||
free(name);
|
||||
*out = '\0';
|
||||
return;
|
||||
@ -770,20 +770,20 @@ ExecStr(struct physical *physical, char *command, char *out, int olen)
|
||||
free(name);
|
||||
break;
|
||||
case 127:
|
||||
LogPrintf(LogWARN, "%s: %s\n", name, startout);
|
||||
log_Printf(LogWARN, "%s: %s\n", name, startout);
|
||||
free(name);
|
||||
*out = '\0';
|
||||
return;
|
||||
break;
|
||||
default:
|
||||
LogPrintf(LogWARN, "%s: exit %d\n", name, WEXITSTATUS(stat));
|
||||
log_Printf(LogWARN, "%s: exit %d\n", name, WEXITSTATUS(stat));
|
||||
free(name);
|
||||
*out = '\0';
|
||||
return;
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
LogPrintf(LogWARN, "%s: Unexpected exit result\n", name);
|
||||
log_Printf(LogWARN, "%s: Unexpected exit result\n", name);
|
||||
free(name);
|
||||
*out = '\0';
|
||||
return;
|
||||
|
@ -23,7 +23,7 @@
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $Id: chat.h,v 1.9.2.6 1998/03/13 21:08:00 brian Exp $
|
||||
* $Id: chat.h,v 1.9.2.7 1998/04/07 00:53:29 brian Exp $
|
||||
*/
|
||||
|
||||
#define CHAT_EXPECT 0
|
||||
@ -72,14 +72,11 @@ struct chat {
|
||||
struct pppTimer timeout; /* TimeoutSec timer */
|
||||
};
|
||||
|
||||
#define chat2descriptor(c) (&(c)->desc)
|
||||
#define descriptor2chat(d) \
|
||||
((d)->type == CHAT_DESCRIPTOR ? (struct chat *)(d) : NULL)
|
||||
|
||||
void chat_Init(struct chat *, struct physical *, const char *, int,
|
||||
const char *);
|
||||
void chat_Destroy(struct chat *);
|
||||
|
||||
#define VECSIZE(v) (sizeof(v) / sizeof(v[0]))
|
||||
|
||||
extern void chat_Init(struct chat *, struct physical *, const char *, int,
|
||||
const char *);
|
||||
extern void chat_Destroy(struct chat *);
|
||||
extern int MakeArgs(char *, char **, int); /* Mangles the first arg ! */
|
||||
|
@ -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.131.2.75 1998/05/01 19:19:58 brian Exp $
|
||||
* $Id: command.c,v 1.131.2.76 1998/05/01 19:22:16 brian Exp $
|
||||
*
|
||||
*/
|
||||
#include <sys/types.h>
|
||||
@ -123,7 +123,7 @@
|
||||
#define NEG_DNS 50
|
||||
|
||||
const char Version[] = "2.0-beta";
|
||||
const char VersionDate[] = "$Date: 1998/05/01 19:19:58 $";
|
||||
const char VersionDate[] = "$Date: 1998/05/01 19:22:16 $";
|
||||
|
||||
static int ShowCommand(struct cmdargs const *);
|
||||
static int TerminalCommand(struct cmdargs const *);
|
||||
@ -150,7 +150,7 @@ HelpCommand(struct cmdargs const *arg)
|
||||
int n, cmax, dmax, cols;
|
||||
|
||||
if (!arg->prompt) {
|
||||
LogPrintf(LogWARN, "help: Cannot help without a prompt\n");
|
||||
log_Printf(LogWARN, "help: Cannot help without a prompt\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -198,7 +198,7 @@ CloneCommand(struct cmdargs const *arg)
|
||||
return -1;
|
||||
|
||||
if (!arg->bundle->ncp.mp.cfg.mrru) {
|
||||
LogPrintf(LogWARN, "clone: Only available in multilink mode\n");
|
||||
log_Printf(LogWARN, "clone: Only available in multilink mode\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -214,7 +214,7 @@ RemoveCommand(struct cmdargs const *arg)
|
||||
return -1;
|
||||
|
||||
if (arg->cx->state != DATALINK_CLOSED) {
|
||||
LogPrintf(LogWARN, "remove: Cannot delete links that aren't closed\n");
|
||||
log_Printf(LogWARN, "remove: Cannot delete links that aren't closed\n");
|
||||
return 2;
|
||||
}
|
||||
|
||||
@ -232,8 +232,8 @@ LoadCommand(struct cmdargs const *arg)
|
||||
else
|
||||
name = "default";
|
||||
|
||||
if (!ValidSystem(name, arg->prompt, arg->bundle->phys_type)) {
|
||||
LogPrintf(LogERROR, "%s: Label not allowed\n", name);
|
||||
if (!system_IsValid(name, arg->prompt, arg->bundle->phys_type)) {
|
||||
log_Printf(LogERROR, "%s: Label not allowed\n", name);
|
||||
return 1;
|
||||
} else {
|
||||
/*
|
||||
@ -241,9 +241,9 @@ LoadCommand(struct cmdargs const *arg)
|
||||
* we handle nested `load' commands.
|
||||
*/
|
||||
bundle_SetLabel(arg->bundle, arg->argc > arg->argn ? name : NULL);
|
||||
if (SelectSystem(arg->bundle, name, CONFFILE, arg->prompt) < 0) {
|
||||
if (system_Select(arg->bundle, name, CONFFILE, arg->prompt) < 0) {
|
||||
bundle_SetLabel(arg->bundle, NULL);
|
||||
LogPrintf(LogWARN, "%s: label not found.\n", name);
|
||||
log_Printf(LogWARN, "%s: label not found.\n", name);
|
||||
return -1;
|
||||
}
|
||||
bundle_SetLabel(arg->bundle, arg->argc > arg->argn ? name : NULL);
|
||||
@ -254,7 +254,7 @@ LoadCommand(struct cmdargs const *arg)
|
||||
int
|
||||
SaveCommand(struct cmdargs const *arg)
|
||||
{
|
||||
LogPrintf(LogWARN, "save command is not implemented (yet).\n");
|
||||
log_Printf(LogWARN, "save command is not implemented (yet).\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -265,7 +265,7 @@ DialCommand(struct cmdargs const *arg)
|
||||
|
||||
if ((arg->cx && !(arg->cx->physical->type & (PHYS_MANUAL|PHYS_DEMAND)))
|
||||
|| (!arg->cx && (arg->bundle->phys_type & ~(PHYS_MANUAL|PHYS_DEMAND)))) {
|
||||
LogPrintf(LogWARN, "Manual dial is only available for auto and"
|
||||
log_Printf(LogWARN, "Manual dial is only available for auto and"
|
||||
" interactive links\n");
|
||||
return 1;
|
||||
}
|
||||
@ -289,22 +289,22 @@ ShellCommand(struct cmdargs const *arg, int bg)
|
||||
#ifdef SHELL_ONLY_INTERACTIVELY
|
||||
/* we're only allowed to shell when we run ppp interactively */
|
||||
if (arg->prompt && arg->prompt->owner) {
|
||||
LogPrintf(LogWARN, "Can't start a shell from a network connection\n");
|
||||
log_Printf(LogWARN, "Can't start a shell from a network connection\n");
|
||||
return 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (arg->argc == arg->argn) {
|
||||
if (!arg->prompt) {
|
||||
LogPrintf(LogWARN, "Can't start an interactive shell from"
|
||||
log_Printf(LogWARN, "Can't start an interactive shell from"
|
||||
" a config file\n");
|
||||
return 1;
|
||||
} else if (arg->prompt->owner) {
|
||||
LogPrintf(LogWARN, "Can't start an interactive shell from"
|
||||
log_Printf(LogWARN, "Can't start an interactive shell from"
|
||||
" a socket connection\n");
|
||||
return 1;
|
||||
} else if (bg) {
|
||||
LogPrintf(LogWARN, "Can only start an interactive shell in"
|
||||
log_Printf(LogWARN, "Can only start an interactive shell in"
|
||||
" the foreground mode\n");
|
||||
return 1;
|
||||
}
|
||||
@ -316,12 +316,12 @@ ShellCommand(struct cmdargs const *arg, int bg)
|
||||
if ((shell = getenv("SHELL")) == 0)
|
||||
shell = _PATH_BSHELL;
|
||||
|
||||
TermTimerService();
|
||||
timer_TermService();
|
||||
|
||||
if (arg->prompt)
|
||||
fd = arg->prompt->fd_out;
|
||||
else if ((fd = open(_PATH_DEVNULL, O_RDWR)) == -1) {
|
||||
LogPrintf(LogALERT, "Failed to open %s: %s\n",
|
||||
log_Printf(LogALERT, "Failed to open %s: %s\n",
|
||||
_PATH_DEVNULL, strerror(errno));
|
||||
exit(1);
|
||||
}
|
||||
@ -350,7 +350,7 @@ ShellCommand(struct cmdargs const *arg, int bg)
|
||||
|
||||
p = getpid();
|
||||
if (daemon(1, 1) == -1) {
|
||||
LogPrintf(LogERROR, "%d: daemon: %s\n", p, strerror(errno));
|
||||
log_Printf(LogERROR, "%d: daemon: %s\n", p, strerror(errno));
|
||||
exit(1);
|
||||
}
|
||||
} else if (arg->prompt)
|
||||
@ -363,13 +363,13 @@ ShellCommand(struct cmdargs const *arg, int bg)
|
||||
execl(shell, shell, NULL);
|
||||
}
|
||||
|
||||
LogPrintf(LogWARN, "exec() of %s failed\n",
|
||||
log_Printf(LogWARN, "exec() of %s failed\n",
|
||||
arg->argc > arg->argn ? arg->argv[arg->argn] : shell);
|
||||
exit(255);
|
||||
}
|
||||
|
||||
if (shpid == (pid_t) - 1)
|
||||
LogPrintf(LogERROR, "Fork failed: %s\n", strerror(errno));
|
||||
log_Printf(LogERROR, "Fork failed: %s\n", strerror(errno));
|
||||
else {
|
||||
int status;
|
||||
waitpid(shpid, &status, 0);
|
||||
@ -477,7 +477,7 @@ ShowEscape(struct cmdargs const *arg)
|
||||
static int
|
||||
ShowTimerList(struct cmdargs const *arg)
|
||||
{
|
||||
ShowTimers(0, arg->prompt);
|
||||
timer_Show(0, arg->prompt);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -513,7 +513,7 @@ ShowVersion(struct cmdargs const *arg)
|
||||
static int
|
||||
ShowProtocolStats(struct cmdargs const *arg)
|
||||
{
|
||||
struct link *l = ChooseLink(arg);
|
||||
struct link *l = command_ChooseLink(arg);
|
||||
|
||||
prompt_Printf(arg->prompt, "%s:\n", l->name);
|
||||
link_ReportProtocolStatus(l, arg->prompt);
|
||||
@ -525,15 +525,15 @@ static struct cmdtab const ShowCommands[] = {
|
||||
"Show bundle details", "show bundle"},
|
||||
{"ccp", NULL, ccp_ReportStatus, LOCAL_AUTH | LOCAL_CX_OPT,
|
||||
"Show CCP status", "show cpp"},
|
||||
{"compress", NULL, ReportCompress, LOCAL_AUTH,
|
||||
{"compress", NULL, sl_Show, LOCAL_AUTH,
|
||||
"Show compression stats", "show compress"},
|
||||
{"escape", NULL, ShowEscape, LOCAL_AUTH | LOCAL_CX,
|
||||
"Show escape characters", "show escape"},
|
||||
{"filter", NULL, ShowFilter, LOCAL_AUTH,
|
||||
{"filter", NULL, filter_Show, LOCAL_AUTH,
|
||||
"Show packet filters", "show filter [in|out|dial|alive]"},
|
||||
{"hdlc", NULL, hdlc_ReportStatus, LOCAL_AUTH | LOCAL_CX,
|
||||
"Show HDLC errors", "show hdlc"},
|
||||
{"ipcp", NULL, ReportIpcpStatus, LOCAL_AUTH,
|
||||
{"ipcp", NULL, ipcp_Show, LOCAL_AUTH,
|
||||
"Show IPCP status", "show ipcp"},
|
||||
{"lcp", NULL, lcp_ReportStatus, LOCAL_AUTH | LOCAL_CX,
|
||||
"Show LCP status", "show lcp"},
|
||||
@ -543,7 +543,7 @@ static struct cmdtab const ShowCommands[] = {
|
||||
"Show available link names", "show links"},
|
||||
{"log", NULL, log_ShowLevel, LOCAL_AUTH,
|
||||
"Show log levels", "show log"},
|
||||
{"mem", NULL, ShowMemMap, LOCAL_AUTH,
|
||||
{"mem", NULL, mbuf_Show, LOCAL_AUTH,
|
||||
"Show memory map", "show mem"},
|
||||
{"modem", NULL, modem_ShowStatus, LOCAL_AUTH | LOCAL_CX,
|
||||
"Show (low-level) link info", "show modem"},
|
||||
@ -551,7 +551,7 @@ static struct cmdtab const ShowCommands[] = {
|
||||
"Show multilink setup", "show mp"},
|
||||
{"proto", NULL, ShowProtocolStats, LOCAL_AUTH | LOCAL_CX_OPT,
|
||||
"Show protocol summary", "show proto"},
|
||||
{"route", NULL, ShowRoute, LOCAL_AUTH,
|
||||
{"route", NULL, route_Show, LOCAL_AUTH,
|
||||
"Show routing table", "show route"},
|
||||
{"stopped", NULL, ShowStopped, LOCAL_AUTH | LOCAL_CX,
|
||||
"Show STOPPED timeout", "show stopped"},
|
||||
@ -629,7 +629,7 @@ FindExec(struct bundle *bundle, struct cmdtab const *cmds, int argc, int argn,
|
||||
|
||||
cmd = FindCommand(cmds, argv[argn], &nmatch);
|
||||
if (nmatch > 1)
|
||||
LogPrintf(LogWARN, "%s: Ambiguous command\n",
|
||||
log_Printf(LogWARN, "%s: Ambiguous command\n",
|
||||
mkPrefix(argn+1, argv, prefix, sizeof prefix));
|
||||
else if (cmd && (!prompt || (cmd->lauth & prompt->auth))) {
|
||||
if ((cmd->lauth & LOCAL_CX) && !cx)
|
||||
@ -637,11 +637,11 @@ FindExec(struct bundle *bundle, struct cmdtab const *cmds, int argc, int argn,
|
||||
cx = bundle2datalink(bundle, NULL);
|
||||
|
||||
if ((cmd->lauth & LOCAL_CX) && !cx)
|
||||
LogPrintf(LogWARN, "%s: No context (use the `link' command)\n",
|
||||
log_Printf(LogWARN, "%s: No context (use the `link' command)\n",
|
||||
mkPrefix(argn+1, argv, prefix, sizeof prefix));
|
||||
else {
|
||||
if (cx && !(cmd->lauth & (LOCAL_CX|LOCAL_CX_OPT))) {
|
||||
LogPrintf(LogWARN, "%s: Redundant context (%s) ignored\n",
|
||||
log_Printf(LogWARN, "%s: Redundant context (%s) ignored\n",
|
||||
mkPrefix(argn+1, argv, prefix, sizeof prefix), cx->name);
|
||||
cx = NULL;
|
||||
}
|
||||
@ -656,20 +656,20 @@ FindExec(struct bundle *bundle, struct cmdtab const *cmds, int argc, int argn,
|
||||
val = (*cmd->func) (&arg);
|
||||
}
|
||||
} else
|
||||
LogPrintf(LogWARN, "%s: Invalid command\n",
|
||||
log_Printf(LogWARN, "%s: Invalid command\n",
|
||||
mkPrefix(argn+1, argv, prefix, sizeof prefix));
|
||||
|
||||
if (val == -1)
|
||||
LogPrintf(LogWARN, "Usage: %s\n", cmd->syntax);
|
||||
log_Printf(LogWARN, "Usage: %s\n", cmd->syntax);
|
||||
else if (val)
|
||||
LogPrintf(LogWARN, "%s: Failed %d\n",
|
||||
log_Printf(LogWARN, "%s: Failed %d\n",
|
||||
mkPrefix(argn+1, argv, prefix, sizeof prefix), val);
|
||||
|
||||
return val;
|
||||
}
|
||||
|
||||
void
|
||||
InterpretCommand(char *buff, int nb, int *argc, char ***argv)
|
||||
command_Interpret(char *buff, int nb, int *argc, char ***argv)
|
||||
{
|
||||
static char *vector[MAXARGS];
|
||||
char *cp;
|
||||
@ -703,11 +703,11 @@ arghidden(int argc, char const *const *argv, int n)
|
||||
}
|
||||
|
||||
void
|
||||
RunCommand(struct bundle *bundle, int argc, char const *const *argv,
|
||||
command_Run(struct bundle *bundle, int argc, char const *const *argv,
|
||||
struct prompt *prompt, const char *label)
|
||||
{
|
||||
if (argc > 0) {
|
||||
if (LogIsKept(LogCOMMAND)) {
|
||||
if (log_IsKept(LogCOMMAND)) {
|
||||
static char buf[LINE_LEN];
|
||||
int f, n;
|
||||
|
||||
@ -727,28 +727,28 @@ RunCommand(struct bundle *bundle, int argc, char const *const *argv,
|
||||
strncpy(buf+n, argv[f], sizeof buf - n - 1);
|
||||
n += strlen(buf+n);
|
||||
}
|
||||
LogPrintf(LogCOMMAND, "%s\n", buf);
|
||||
log_Printf(LogCOMMAND, "%s\n", buf);
|
||||
}
|
||||
FindExec(bundle, Commands, argc, 0, argv, prompt, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
DecodeCommand(struct bundle *bundle, char *buff, int nb, struct prompt *prompt,
|
||||
command_Decode(struct bundle *bundle, char *buff, int nb, struct prompt *prompt,
|
||||
const char *label)
|
||||
{
|
||||
int argc;
|
||||
char **argv;
|
||||
|
||||
InterpretCommand(buff, nb, &argc, &argv);
|
||||
RunCommand(bundle, argc, (char const *const *)argv, prompt, label);
|
||||
command_Interpret(buff, nb, &argc, &argv);
|
||||
command_Run(bundle, argc, (char const *const *)argv, prompt, label);
|
||||
}
|
||||
|
||||
static int
|
||||
ShowCommand(struct cmdargs const *arg)
|
||||
{
|
||||
if (!arg->prompt)
|
||||
LogPrintf(LogWARN, "show: Cannot show without a prompt\n");
|
||||
log_Printf(LogWARN, "show: Cannot show without a prompt\n");
|
||||
else if (arg->argc > arg->argn)
|
||||
FindExec(arg->bundle, ShowCommands, arg->argc, arg->argn, arg->argv,
|
||||
arg->prompt, arg->cx);
|
||||
@ -762,7 +762,7 @@ static int
|
||||
TerminalCommand(struct cmdargs const *arg)
|
||||
{
|
||||
if (!arg->prompt) {
|
||||
LogPrintf(LogWARN, "term: Need a prompt\n");
|
||||
log_Printf(LogWARN, "term: Need a prompt\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -798,13 +798,13 @@ OpenCommand(struct cmdargs const *arg)
|
||||
bundle_Open(arg->bundle, arg->cx ? arg->cx->name : NULL, PHYS_ALL);
|
||||
else if (arg->argc == arg->argn+1 &&
|
||||
!strcasecmp(arg->argv[arg->argn], "ccp")) {
|
||||
struct fsm *fp = &ChooseLink(arg)->ccp.fsm;
|
||||
struct fsm *fp = &command_ChooseLink(arg)->ccp.fsm;
|
||||
|
||||
if (fp->link->lcp.fsm.state != ST_OPENED)
|
||||
LogPrintf(LogWARN, "open: LCP must be open before opening CCP\n");
|
||||
log_Printf(LogWARN, "open: LCP must be open before opening CCP\n");
|
||||
else if (fp->state != ST_OPENED) {
|
||||
FsmUp(fp);
|
||||
FsmOpen(fp);
|
||||
fsm_Up(fp);
|
||||
fsm_Open(fp);
|
||||
}
|
||||
} else
|
||||
return -1;
|
||||
@ -820,10 +820,10 @@ CloseCommand(struct cmdargs const *arg)
|
||||
bundle_Close(arg->bundle, arg->cx ? arg->cx->name : NULL, 1);
|
||||
else if (arg->argc == arg->argn+1 &&
|
||||
!strcasecmp(arg->argv[arg->argn], "ccp")) {
|
||||
struct fsm *fp = &ChooseLink(arg)->ccp.fsm;
|
||||
struct fsm *fp = &command_ChooseLink(arg)->ccp.fsm;
|
||||
|
||||
if (fp->state == ST_OPENED)
|
||||
FsmClose(fp);
|
||||
fsm_Close(fp);
|
||||
} else
|
||||
return -1;
|
||||
|
||||
@ -845,25 +845,25 @@ SetModemSpeed(struct cmdargs const *arg)
|
||||
|
||||
if (arg->argc > arg->argn && *arg->argv[arg->argn]) {
|
||||
if (arg->argc > arg->argn+1) {
|
||||
LogPrintf(LogWARN, "SetModemSpeed: Too many arguments");
|
||||
log_Printf(LogWARN, "SetModemSpeed: Too many arguments");
|
||||
return -1;
|
||||
}
|
||||
if (strcasecmp(arg->argv[arg->argn], "sync") == 0) {
|
||||
Physical_SetSync(arg->cx->physical);
|
||||
physical_SetSync(arg->cx->physical);
|
||||
return 0;
|
||||
}
|
||||
end = NULL;
|
||||
speed = strtol(arg->argv[arg->argn], &end, 10);
|
||||
if (*end) {
|
||||
LogPrintf(LogWARN, "SetModemSpeed: Bad argument \"%s\"",
|
||||
log_Printf(LogWARN, "SetModemSpeed: Bad argument \"%s\"",
|
||||
arg->argv[arg->argn]);
|
||||
return -1;
|
||||
}
|
||||
if (Physical_SetSpeed(arg->cx->physical, speed))
|
||||
if (physical_SetSpeed(arg->cx->physical, speed))
|
||||
return 0;
|
||||
LogPrintf(LogWARN, "%s: Invalid speed\n", arg->argv[arg->argn]);
|
||||
log_Printf(LogWARN, "%s: Invalid speed\n", arg->argv[arg->argn]);
|
||||
} else
|
||||
LogPrintf(LogWARN, "SetModemSpeed: No speed specified\n");
|
||||
log_Printf(LogWARN, "SetModemSpeed: No speed specified\n");
|
||||
|
||||
return -1;
|
||||
}
|
||||
@ -908,8 +908,8 @@ SetServer(struct cmdargs const *arg)
|
||||
if (!ismask(mask))
|
||||
return -1;
|
||||
} else if (strcasecmp(port, "none") == 0) {
|
||||
if (ServerClose(arg->bundle))
|
||||
LogPrintf(LogPHASE, "Disabled server port.\n");
|
||||
if (server_Close(arg->bundle))
|
||||
log_Printf(LogPHASE, "Disabled server port.\n");
|
||||
return 0;
|
||||
} else
|
||||
return -1;
|
||||
@ -929,7 +929,7 @@ SetServer(struct cmdargs const *arg)
|
||||
return -1;
|
||||
} else
|
||||
imask = (mode_t)-1;
|
||||
res = ServerLocalOpen(arg->bundle, port, imask);
|
||||
res = server_LocalOpen(arg->bundle, port, imask);
|
||||
} else {
|
||||
int iport;
|
||||
|
||||
@ -941,12 +941,12 @@ SetServer(struct cmdargs const *arg)
|
||||
|
||||
if ((s = getservbyname(port, "tcp")) == NULL) {
|
||||
iport = 0;
|
||||
LogPrintf(LogWARN, "%s: Invalid port or service\n", port);
|
||||
log_Printf(LogWARN, "%s: Invalid port or service\n", port);
|
||||
} else
|
||||
iport = ntohs(s->s_port);
|
||||
} else
|
||||
iport = atoi(port);
|
||||
res = iport ? ServerTcpOpen(arg->bundle, iport) : -1;
|
||||
res = iport ? server_TcpOpen(arg->bundle, iport) : -1;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1044,7 +1044,7 @@ SetInterfaceAddr(struct cmdargs const *arg)
|
||||
}
|
||||
|
||||
if (hisaddr &&
|
||||
!UseHisaddr(arg->bundle, hisaddr, arg->bundle->phys_type & PHYS_DEMAND))
|
||||
!ipcp_UseHisaddr(arg->bundle, hisaddr, arg->bundle->phys_type & PHYS_DEMAND))
|
||||
return 4;
|
||||
|
||||
return 0;
|
||||
@ -1058,7 +1058,7 @@ SetVariable(struct cmdargs const *arg)
|
||||
int param = (int)arg->cmd->args;
|
||||
struct datalink *cx = arg->cx; /* AUTH_CX uses this */
|
||||
const char *err = NULL;
|
||||
struct link *l = ChooseLink(arg); /* AUTH_CX_OPT uses this */
|
||||
struct link *l = command_ChooseLink(arg); /* AUTH_CX_OPT uses this */
|
||||
int dummyint;
|
||||
struct in_addr dummyaddr, *addr;
|
||||
|
||||
@ -1068,11 +1068,11 @@ SetVariable(struct cmdargs const *arg)
|
||||
argp = "";
|
||||
|
||||
if ((arg->cmd->lauth & LOCAL_CX) && !cx) {
|
||||
LogPrintf(LogWARN, "set %s: No context (use the `link' command)\n",
|
||||
log_Printf(LogWARN, "set %s: No context (use the `link' command)\n",
|
||||
arg->cmd->name);
|
||||
return 1;
|
||||
} else if (cx && !(arg->cmd->lauth & (LOCAL_CX|LOCAL_CX_OPT))) {
|
||||
LogPrintf(LogWARN, "set %s: Redundant context (%s) ignored\n",
|
||||
log_Printf(LogWARN, "set %s: Redundant context (%s) ignored\n",
|
||||
arg->cmd->name, cx->name);
|
||||
cx = NULL;
|
||||
}
|
||||
@ -1085,7 +1085,7 @@ SetVariable(struct cmdargs const *arg)
|
||||
arg->bundle->cfg.auth.key[sizeof arg->bundle->cfg.auth.key - 1] = '\0';
|
||||
} else {
|
||||
err = "set authkey: Only available at phase DEAD\n";
|
||||
LogPrintf(LogWARN, err);
|
||||
log_Printf(LogWARN, err);
|
||||
}
|
||||
break;
|
||||
case VAR_AUTHNAME:
|
||||
@ -1095,7 +1095,7 @@ SetVariable(struct cmdargs const *arg)
|
||||
arg->bundle->cfg.auth.name[sizeof arg->bundle->cfg.auth.name - 1] = '\0';
|
||||
} else {
|
||||
err = "set authname: Only available at phase DEAD\n";
|
||||
LogPrintf(LogWARN, err);
|
||||
log_Printf(LogWARN, err);
|
||||
}
|
||||
break;
|
||||
case VAR_DIAL:
|
||||
@ -1111,7 +1111,7 @@ SetVariable(struct cmdargs const *arg)
|
||||
l->ccp.cfg.deflate.out.winsize = atoi(arg->argv[arg->argn]);
|
||||
if (l->ccp.cfg.deflate.out.winsize < 8 ||
|
||||
l->ccp.cfg.deflate.out.winsize > 15) {
|
||||
LogPrintf(LogWARN, "%d: Invalid outgoing window size\n",
|
||||
log_Printf(LogWARN, "%d: Invalid outgoing window size\n",
|
||||
l->ccp.cfg.deflate.out.winsize);
|
||||
l->ccp.cfg.deflate.out.winsize = 15;
|
||||
}
|
||||
@ -1119,7 +1119,7 @@ SetVariable(struct cmdargs const *arg)
|
||||
l->ccp.cfg.deflate.in.winsize = atoi(arg->argv[arg->argn+1]);
|
||||
if (l->ccp.cfg.deflate.in.winsize < 8 ||
|
||||
l->ccp.cfg.deflate.in.winsize > 15) {
|
||||
LogPrintf(LogWARN, "%d: Invalid incoming window size\n",
|
||||
log_Printf(LogWARN, "%d: Invalid incoming window size\n",
|
||||
l->ccp.cfg.deflate.in.winsize);
|
||||
l->ccp.cfg.deflate.in.winsize = 15;
|
||||
}
|
||||
@ -1127,11 +1127,11 @@ SetVariable(struct cmdargs const *arg)
|
||||
l->ccp.cfg.deflate.in.winsize = 0;
|
||||
} else {
|
||||
err = "No window size specified\n";
|
||||
LogPrintf(LogWARN, err);
|
||||
log_Printf(LogWARN, err);
|
||||
}
|
||||
break;
|
||||
case VAR_DEVICE:
|
||||
Physical_SetDeviceList(cx->physical, arg->argc - arg->argn,
|
||||
physical_SetDeviceList(cx->physical, arg->argc - arg->argn,
|
||||
arg->argv + arg->argn);
|
||||
break;
|
||||
case VAR_ACCMAP:
|
||||
@ -1140,12 +1140,12 @@ SetVariable(struct cmdargs const *arg)
|
||||
cx->physical->link.lcp.cfg.accmap = ulong_val;
|
||||
} else {
|
||||
err = "No accmap specified\n";
|
||||
LogPrintf(LogWARN, err);
|
||||
log_Printf(LogWARN, err);
|
||||
}
|
||||
break;
|
||||
case VAR_MRRU:
|
||||
if (bundle_Phase(arg->bundle) != PHASE_DEAD)
|
||||
LogPrintf(LogWARN, "mrru: Only changable at phase DEAD\n");
|
||||
log_Printf(LogWARN, "mrru: Only changable at phase DEAD\n");
|
||||
else {
|
||||
ulong_val = atol(argp);
|
||||
if (ulong_val < MIN_MRU)
|
||||
@ -1155,7 +1155,7 @@ SetVariable(struct cmdargs const *arg)
|
||||
else
|
||||
arg->bundle->ncp.mp.cfg.mrru = ulong_val;
|
||||
if (err)
|
||||
LogPrintf(LogWARN, err, ulong_val);
|
||||
log_Printf(LogWARN, err, ulong_val);
|
||||
}
|
||||
break;
|
||||
case VAR_MRU:
|
||||
@ -1167,7 +1167,7 @@ SetVariable(struct cmdargs const *arg)
|
||||
else
|
||||
l->lcp.cfg.mru = ulong_val;
|
||||
if (err)
|
||||
LogPrintf(LogWARN, err, ulong_val);
|
||||
log_Printf(LogWARN, err, ulong_val);
|
||||
break;
|
||||
case VAR_MTU:
|
||||
ulong_val = atol(argp);
|
||||
@ -1180,7 +1180,7 @@ SetVariable(struct cmdargs const *arg)
|
||||
else
|
||||
arg->bundle->cfg.mtu = ulong_val;
|
||||
if (err)
|
||||
LogPrintf(LogWARN, err, ulong_val);
|
||||
log_Printf(LogWARN, err, ulong_val);
|
||||
break;
|
||||
case VAR_OPENMODE:
|
||||
if (strcasecmp(argp, "active") == 0)
|
||||
@ -1190,7 +1190,7 @@ SetVariable(struct cmdargs const *arg)
|
||||
cx->physical->link.lcp.cfg.openmode = OPEN_PASSIVE;
|
||||
else {
|
||||
err = "%s: Invalid openmode\n";
|
||||
LogPrintf(LogWARN, err, argp);
|
||||
log_Printf(LogWARN, err, argp);
|
||||
}
|
||||
break;
|
||||
case VAR_PHONE:
|
||||
@ -1207,13 +1207,13 @@ SetVariable(struct cmdargs const *arg)
|
||||
else if (arg->argc == arg->argn+1)
|
||||
bundle_SetIdleTimer(arg->bundle, atoi(argp));
|
||||
if (err)
|
||||
LogPrintf(LogWARN, err);
|
||||
log_Printf(LogWARN, err);
|
||||
break;
|
||||
case VAR_LQRPERIOD:
|
||||
ulong_val = atol(argp);
|
||||
if (ulong_val <= 0) {
|
||||
err = "%s: Invalid lqr period\n";
|
||||
LogPrintf(LogWARN, err, argp);
|
||||
log_Printf(LogWARN, err, argp);
|
||||
} else
|
||||
l->lcp.cfg.lqrperiod = ulong_val;
|
||||
break;
|
||||
@ -1221,7 +1221,7 @@ SetVariable(struct cmdargs const *arg)
|
||||
ulong_val = atol(argp);
|
||||
if (ulong_val <= 0) {
|
||||
err = "%s: Invalid LCP FSM retry period\n";
|
||||
LogPrintf(LogWARN, err, argp);
|
||||
log_Printf(LogWARN, err, argp);
|
||||
} else
|
||||
cx->physical->link.lcp.cfg.fsmretry = ulong_val;
|
||||
break;
|
||||
@ -1229,7 +1229,7 @@ SetVariable(struct cmdargs const *arg)
|
||||
ulong_val = atol(argp);
|
||||
if (ulong_val <= 0) {
|
||||
err = "%s: Invalid CHAP retry period\n";
|
||||
LogPrintf(LogWARN, err, argp);
|
||||
log_Printf(LogWARN, err, argp);
|
||||
} else
|
||||
cx->chap.auth.cfg.fsmretry = ulong_val;
|
||||
break;
|
||||
@ -1237,7 +1237,7 @@ SetVariable(struct cmdargs const *arg)
|
||||
ulong_val = atol(argp);
|
||||
if (ulong_val <= 0) {
|
||||
err = "%s: Invalid PAP retry period\n";
|
||||
LogPrintf(LogWARN, err, argp);
|
||||
log_Printf(LogWARN, err, argp);
|
||||
} else
|
||||
cx->pap.cfg.fsmretry = ulong_val;
|
||||
break;
|
||||
@ -1245,7 +1245,7 @@ SetVariable(struct cmdargs const *arg)
|
||||
ulong_val = atol(argp);
|
||||
if (ulong_val <= 0) {
|
||||
err = "%s: Invalid CCP FSM retry period\n";
|
||||
LogPrintf(LogWARN, err, argp);
|
||||
log_Printf(LogWARN, err, argp);
|
||||
} else
|
||||
l->ccp.cfg.fsmretry = ulong_val;
|
||||
break;
|
||||
@ -1253,7 +1253,7 @@ SetVariable(struct cmdargs const *arg)
|
||||
ulong_val = atol(argp);
|
||||
if (ulong_val <= 0) {
|
||||
err = "%s: Invalid IPCP FSM retry period\n";
|
||||
LogPrintf(LogWARN, err, argp);
|
||||
log_Printf(LogWARN, err, argp);
|
||||
} else
|
||||
arg->bundle->ncp.ipcp.cfg.fsmretry = ulong_val;
|
||||
break;
|
||||
@ -1289,9 +1289,9 @@ SetCtsRts(struct cmdargs const *arg)
|
||||
{
|
||||
if (arg->argc == arg->argn+1) {
|
||||
if (strcmp(arg->argv[arg->argn], "on") == 0)
|
||||
Physical_SetRtsCts(arg->cx->physical, 1);
|
||||
physical_SetRtsCts(arg->cx->physical, 1);
|
||||
else if (strcmp(arg->argv[arg->argn], "off") == 0)
|
||||
Physical_SetRtsCts(arg->cx->physical, 0);
|
||||
physical_SetRtsCts(arg->cx->physical, 0);
|
||||
else
|
||||
return -1;
|
||||
return 0;
|
||||
@ -1329,7 +1329,7 @@ static struct cmdtab const SetCommands[] = {
|
||||
"Set Endpoint Discriminator", "set enddisc [IP|magic|label|psn value]"},
|
||||
{"escape", NULL, SetEscape, LOCAL_AUTH | LOCAL_CX,
|
||||
"Set escape characters", "set escape hex-digit ..."},
|
||||
{"filter", NULL, SetFilter, LOCAL_AUTH,
|
||||
{"filter", NULL, filter_Set, LOCAL_AUTH,
|
||||
"Set packet filters", "set filter alive|dial|in|out rule-no permit|deny "
|
||||
"[src_addr[/width]] [dst_addr[/width]] [tcp|udp|icmp [src [lt|eq|gt port]] "
|
||||
"[dst [lt|eq|gt port]] [estab] [syn] [finrst]]"},
|
||||
@ -1375,7 +1375,7 @@ static struct cmdtab const SetCommands[] = {
|
||||
"Set STOPPED timeouts", "set stopped [LCPseconds [CCPseconds]]"},
|
||||
{"timeout", NULL, SetVariable, LOCAL_AUTH, "Set Idle timeout",
|
||||
"set timeout idletime", (const void *)VAR_IDLETIMEOUT},
|
||||
{"vj", NULL, SetInitVJ, LOCAL_AUTH,
|
||||
{"vj", NULL, ipcp_vjset, LOCAL_AUTH,
|
||||
"Set vj values", "set vj slots|slotcomp [value]"},
|
||||
{"weight", NULL, mp_SetDatalinkWeight, LOCAL_AUTH | LOCAL_CX,
|
||||
"Set datalink weighting", "set weight n"},
|
||||
@ -1394,7 +1394,7 @@ SetCommand(struct cmdargs const *arg)
|
||||
prompt_Printf(arg->prompt, "Use `set ?' to get a list or `set ? <var>' for"
|
||||
" syntax help.\n");
|
||||
else
|
||||
LogPrintf(LogWARN, "set command must have arguments\n");
|
||||
log_Printf(LogWARN, "set command must have arguments\n");
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -1444,7 +1444,7 @@ DeleteCommand(struct cmdargs const *arg)
|
||||
|
||||
if (arg->argc == arg->argn+1) {
|
||||
if(strcasecmp(arg->argv[arg->argn], "all") == 0)
|
||||
DeleteIfRoutes(arg->bundle, 0);
|
||||
route_IfDelete(arg->bundle, 0);
|
||||
else {
|
||||
if (strcasecmp(arg->argv[arg->argn], "MYADDR") == 0)
|
||||
dest = arg->bundle->ncp.ipcp.my_ip;
|
||||
@ -1465,7 +1465,7 @@ DeleteCommand(struct cmdargs const *arg)
|
||||
#ifndef NOALIAS
|
||||
static struct cmdtab const AliasCommands[] =
|
||||
{
|
||||
{"addr", NULL, AliasRedirectAddr, LOCAL_AUTH,
|
||||
{"addr", NULL, alias_RedirectAddr, LOCAL_AUTH,
|
||||
"static address translation", "alias addr [addr_local addr_alias]"},
|
||||
{"deny_incoming", NULL, AliasOption, LOCAL_AUTH,
|
||||
"stop incoming connections", "alias deny_incoming [yes|no]",
|
||||
@ -1475,7 +1475,7 @@ static struct cmdtab const AliasCommands[] =
|
||||
{"log", NULL, AliasOption, LOCAL_AUTH,
|
||||
"log aliasing link creation", "alias log [yes|no]",
|
||||
(const void *) PKT_ALIAS_LOG},
|
||||
{"port", NULL, AliasRedirectPort, LOCAL_AUTH,
|
||||
{"port", NULL, alias_RedirectPort, LOCAL_AUTH,
|
||||
"port redirection", "alias port [proto addr_local:port_local port_alias]"},
|
||||
{"same_ports", NULL, AliasOption, LOCAL_AUTH,
|
||||
"try to leave port numbers unchanged", "alias same_ports [yes|no]",
|
||||
@ -1503,7 +1503,7 @@ AliasCommand(struct cmdargs const *arg)
|
||||
prompt_Printf(arg->prompt, "Use `alias help' to get a list or `alias help"
|
||||
" <option>' for syntax help.\n");
|
||||
else
|
||||
LogPrintf(LogWARN, "alias command must have arguments\n");
|
||||
log_Printf(LogWARN, "alias command must have arguments\n");
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -1513,12 +1513,12 @@ AliasEnable(struct cmdargs const *arg)
|
||||
{
|
||||
if (arg->argc == arg->argn+1) {
|
||||
if (strcasecmp(arg->argv[arg->argn], "yes") == 0) {
|
||||
if (loadAliasHandlers() == 0)
|
||||
if (alias_Load() == 0)
|
||||
return 0;
|
||||
LogPrintf(LogWARN, "Cannot load alias library\n");
|
||||
log_Printf(LogWARN, "Cannot load alias library\n");
|
||||
return 1;
|
||||
} else if (strcasecmp(arg->argv[arg->argn], "no") == 0) {
|
||||
unloadAliasHandlers();
|
||||
alias_Unload();
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@ -1533,17 +1533,17 @@ AliasOption(struct cmdargs const *arg)
|
||||
unsigned param = (unsigned)arg->cmd->args;
|
||||
if (arg->argc == arg->argn+1) {
|
||||
if (strcasecmp(arg->argv[arg->argn], "yes") == 0) {
|
||||
if (AliasEnabled()) {
|
||||
if (alias_IsEnabled()) {
|
||||
(*PacketAlias.SetMode)(param, param);
|
||||
return 0;
|
||||
}
|
||||
LogPrintf(LogWARN, "alias not enabled\n");
|
||||
log_Printf(LogWARN, "alias not enabled\n");
|
||||
} else if (strcmp(arg->argv[arg->argn], "no") == 0) {
|
||||
if (AliasEnabled()) {
|
||||
if (alias_IsEnabled()) {
|
||||
(*PacketAlias.SetMode)(0, param);
|
||||
return 0;
|
||||
}
|
||||
LogPrintf(LogWARN, "alias not enabled\n");
|
||||
log_Printf(LogWARN, "alias not enabled\n");
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
@ -1563,7 +1563,7 @@ static struct cmdtab const AllowCommands[] = {
|
||||
static int
|
||||
AllowCommand(struct cmdargs const *arg)
|
||||
{
|
||||
/* arg->bundle may be NULL (see ValidSystem()) ! */
|
||||
/* arg->bundle may be NULL (see system_IsValid()) ! */
|
||||
if (arg->argc > arg->argn)
|
||||
FindExec(arg->bundle, AllowCommands, arg->argc, arg->argn, arg->argv,
|
||||
arg->prompt, arg->cx);
|
||||
@ -1571,7 +1571,7 @@ AllowCommand(struct cmdargs const *arg)
|
||||
prompt_Printf(arg->prompt, "Use `allow ?' to get a list or `allow ? <cmd>'"
|
||||
" for syntax help.\n");
|
||||
else
|
||||
LogPrintf(LogWARN, "allow command must have arguments\n");
|
||||
log_Printf(LogWARN, "allow command must have arguments\n");
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -1585,11 +1585,11 @@ LinkCommand(struct cmdargs const *arg)
|
||||
FindExec(arg->bundle, Commands, arg->argc, arg->argn+1, arg->argv,
|
||||
arg->prompt, cx);
|
||||
else {
|
||||
LogPrintf(LogWARN, "link: %s: Invalid link name\n", arg->argv[arg->argn]);
|
||||
log_Printf(LogWARN, "link: %s: Invalid link name\n", arg->argv[arg->argn]);
|
||||
return 1;
|
||||
}
|
||||
} else {
|
||||
LogPrintf(LogWARN, "Usage: %s\n", arg->cmd->syntax);
|
||||
log_Printf(LogWARN, "Usage: %s\n", arg->cmd->syntax);
|
||||
return 2;
|
||||
}
|
||||
|
||||
@ -1597,7 +1597,7 @@ LinkCommand(struct cmdargs const *arg)
|
||||
}
|
||||
|
||||
struct link *
|
||||
ChooseLink(struct cmdargs const *arg)
|
||||
command_ChooseLink(struct cmdargs const *arg)
|
||||
{
|
||||
if (arg->cx)
|
||||
return &arg->cx->physical->link;
|
||||
@ -1675,7 +1675,7 @@ static int
|
||||
NegotiateSet(struct cmdargs const *arg)
|
||||
{
|
||||
int param = (int)arg->cmd->args;
|
||||
struct link *l = ChooseLink(arg); /* AUTH_CX_OPT uses this */
|
||||
struct link *l = command_ChooseLink(arg); /* AUTH_CX_OPT uses this */
|
||||
struct datalink *cx = arg->cx; /* AUTH_CX uses this */
|
||||
const char *cmd;
|
||||
unsigned keep; /* Keep these bits */
|
||||
@ -1685,11 +1685,11 @@ NegotiateSet(struct cmdargs const *arg)
|
||||
return 1;
|
||||
|
||||
if ((arg->cmd->lauth & LOCAL_CX) && !cx) {
|
||||
LogPrintf(LogWARN, "%s %s: No context (use the `link' command)\n",
|
||||
log_Printf(LogWARN, "%s %s: No context (use the `link' command)\n",
|
||||
cmd, arg->cmd->name);
|
||||
return 2;
|
||||
} else if (cx && !(arg->cmd->lauth & (LOCAL_CX|LOCAL_CX_OPT))) {
|
||||
LogPrintf(LogWARN, "%s %s: Redundant context (%s) ignored\n",
|
||||
log_Printf(LogWARN, "%s %s: Redundant context (%s) ignored\n",
|
||||
cmd, arg->cmd->name, cx->name);
|
||||
cx = NULL;
|
||||
}
|
||||
@ -1733,7 +1733,7 @@ NegotiateSet(struct cmdargs const *arg)
|
||||
break;
|
||||
case NEG_SHORTSEQ:
|
||||
if (bundle_Phase(arg->bundle) != PHASE_DEAD)
|
||||
LogPrintf(LogWARN, "shortseq: Only changable at phase DEAD\n");
|
||||
log_Printf(LogWARN, "shortseq: Only changable at phase DEAD\n");
|
||||
else {
|
||||
arg->bundle->ncp.mp.cfg.shortseq &= keep;
|
||||
arg->bundle->ncp.mp.cfg.shortseq |= add;
|
||||
@ -1823,7 +1823,7 @@ NegotiateCommand(struct cmdargs const *arg)
|
||||
prompt_Printf(arg->prompt, "Use `%s ?' to get a list.\n",
|
||||
arg->argv[arg->argn-1]);
|
||||
else
|
||||
LogPrintf(LogWARN, "%s command must have arguments\n",
|
||||
log_Printf(LogWARN, "%s command must have arguments\n",
|
||||
arg->argv[arg->argn] );
|
||||
|
||||
return 0;
|
||||
|
@ -15,7 +15,7 @@
|
||||
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* $Id: command.h,v 1.12.2.11 1998/04/16 00:25:55 brian Exp $
|
||||
* $Id: command.h,v 1.12.2.12 1998/04/30 23:53:31 brian Exp $
|
||||
*
|
||||
* TODO:
|
||||
*/
|
||||
@ -54,11 +54,10 @@ struct cmdtab {
|
||||
extern const char Version[];
|
||||
extern const char VersionDate[];
|
||||
|
||||
extern int IsInteractive(struct prompt *);
|
||||
extern void InterpretCommand(char *, int, int *, char ***);
|
||||
extern void RunCommand(struct bundle *, int, char const *const *,
|
||||
struct prompt *, const char *);
|
||||
extern void DecodeCommand(struct bundle *, char *, int, struct prompt *,
|
||||
const char *);
|
||||
extern struct link *ChooseLink(struct cmdargs const *);
|
||||
const char *command_ShowNegval(unsigned);
|
||||
extern void command_Interpret(char *, int, int *, char ***);
|
||||
extern void command_Run(struct bundle *, int, char const *const *,
|
||||
struct prompt *, const char *);
|
||||
extern void command_Decode(struct bundle *, char *, int, struct prompt *,
|
||||
const char *);
|
||||
extern struct link *command_ChooseLink(struct cmdargs const *);
|
||||
extern const char *command_ShowNegval(unsigned);
|
||||
|
@ -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.1.2.51 1998/04/30 23:53:32 brian Exp $
|
||||
* $Id: datalink.c,v 1.1.2.52 1998/05/01 19:20:01 brian Exp $
|
||||
*/
|
||||
|
||||
#include <sys/types.h>
|
||||
@ -76,15 +76,15 @@ datalink_OpenTimeout(void *v)
|
||||
{
|
||||
struct datalink *dl = (struct datalink *)v;
|
||||
|
||||
StopTimer(&dl->dial_timer);
|
||||
timer_Stop(&dl->dial_timer);
|
||||
if (dl->state == DATALINK_OPENING)
|
||||
LogPrintf(LogPHASE, "%s: Redial timer expired.\n", dl->name);
|
||||
log_Printf(LogPHASE, "%s: Redial timer expired.\n", dl->name);
|
||||
}
|
||||
|
||||
static void
|
||||
datalink_StartDialTimer(struct datalink *dl, int Timeout)
|
||||
{
|
||||
StopTimer(&dl->dial_timer);
|
||||
timer_Stop(&dl->dial_timer);
|
||||
|
||||
if (Timeout) {
|
||||
if (Timeout > 0)
|
||||
@ -94,9 +94,9 @@ datalink_StartDialTimer(struct datalink *dl, int Timeout)
|
||||
dl->dial_timer.func = datalink_OpenTimeout;
|
||||
dl->dial_timer.name = "dial";
|
||||
dl->dial_timer.arg = dl;
|
||||
StartTimer(&dl->dial_timer);
|
||||
timer_Start(&dl->dial_timer);
|
||||
if (dl->state == DATALINK_OPENING)
|
||||
LogPrintf(LogPHASE, "%s: Enter pause (%d) for redialing.\n",
|
||||
log_Printf(LogPHASE, "%s: Enter pause (%d) for redialing.\n",
|
||||
dl->name, Timeout);
|
||||
}
|
||||
}
|
||||
@ -105,7 +105,7 @@ static void
|
||||
datalink_HangupDone(struct datalink *dl)
|
||||
{
|
||||
if (dl->physical->type == PHYS_DEDICATED && !dl->bundle->CleaningUp &&
|
||||
Physical_GetFD(dl->physical) != -1) {
|
||||
physical_GetFD(dl->physical) != -1) {
|
||||
/* Don't close our modem if the link is dedicated */
|
||||
datalink_LoginDone(dl);
|
||||
return;
|
||||
@ -118,7 +118,7 @@ datalink_HangupDone(struct datalink *dl)
|
||||
(dl->physical->type == PHYS_DIRECT) ||
|
||||
((!dl->dial_tries || (dl->dial_tries < 0 && !dl->reconnect_tries)) &&
|
||||
!(dl->physical->type & (PHYS_PERM|PHYS_DEDICATED)))) {
|
||||
LogPrintf(LogPHASE, "%s: Entering CLOSED state\n", dl->name);
|
||||
log_Printf(LogPHASE, "%s: Entering CLOSED state\n", dl->name);
|
||||
dl->state = DATALINK_CLOSED;
|
||||
dl->dial_tries = -1;
|
||||
dl->reconnect_tries = 0;
|
||||
@ -126,7 +126,7 @@ datalink_HangupDone(struct datalink *dl)
|
||||
if (!dl->bundle->CleaningUp)
|
||||
datalink_StartDialTimer(dl, dl->cfg.dial.timeout);
|
||||
} else {
|
||||
LogPrintf(LogPHASE, "%s: Re-entering OPENING state\n", dl->name);
|
||||
log_Printf(LogPHASE, "%s: Re-entering OPENING state\n", dl->name);
|
||||
dl->state = DATALINK_OPENING;
|
||||
if (dl->dial_tries < 0) {
|
||||
datalink_StartDialTimer(dl, dl->cfg.reconnect.timeout);
|
||||
@ -157,7 +157,7 @@ datalink_ChoosePhoneNumber(struct datalink *dl)
|
||||
phone = strsep(&dl->phone.alt, "|");
|
||||
dl->phone.chosen = *phone ? phone : "[NONE]";
|
||||
if (*phone)
|
||||
LogPrintf(LogPHASE, "Phone: %s\n", phone);
|
||||
log_Printf(LogPHASE, "Phone: %s\n", phone);
|
||||
return phone;
|
||||
}
|
||||
|
||||
@ -166,13 +166,13 @@ datalink_LoginDone(struct datalink *dl)
|
||||
{
|
||||
if (!dl->script.packetmode) {
|
||||
dl->dial_tries = -1;
|
||||
LogPrintf(LogPHASE, "%s: Entering READY state\n", dl->name);
|
||||
log_Printf(LogPHASE, "%s: Entering READY state\n", dl->name);
|
||||
dl->state = DATALINK_READY;
|
||||
} else if (modem_Raw(dl->physical, dl->bundle) < 0) {
|
||||
dl->dial_tries = 0;
|
||||
LogPrintf(LogWARN, "datalink_LoginDone: Not connected.\n");
|
||||
log_Printf(LogWARN, "datalink_LoginDone: Not connected.\n");
|
||||
if (dl->script.run) {
|
||||
LogPrintf(LogPHASE, "%s: Entering HANGUP state\n", dl->name);
|
||||
log_Printf(LogPHASE, "%s: Entering HANGUP state\n", dl->name);
|
||||
dl->state = DATALINK_HANGUP;
|
||||
modem_Offline(dl->physical);
|
||||
chat_Init(&dl->chat, dl->physical, dl->cfg.script.hangup, 1, NULL);
|
||||
@ -192,10 +192,10 @@ datalink_LoginDone(struct datalink *dl)
|
||||
0 : dl->physical->link.lcp.cfg.openmode);
|
||||
ccp_Setup(&dl->physical->link.ccp);
|
||||
|
||||
LogPrintf(LogPHASE, "%s: Entering LCP state\n", dl->name);
|
||||
log_Printf(LogPHASE, "%s: Entering LCP state\n", dl->name);
|
||||
dl->state = DATALINK_LCP;
|
||||
FsmUp(&dl->physical->link.lcp.fsm);
|
||||
FsmOpen(&dl->physical->link.lcp.fsm);
|
||||
fsm_Up(&dl->physical->link.lcp.fsm);
|
||||
fsm_Open(&dl->physical->link.lcp.fsm);
|
||||
}
|
||||
}
|
||||
|
||||
@ -227,13 +227,13 @@ datalink_UpdateSet(struct descriptor *d, fd_set *r, fd_set *w, fd_set *e,
|
||||
dl->dial_tries = 0;
|
||||
if (modem_Open(dl->physical, dl->bundle) >= 0) {
|
||||
if (dl->script.run) {
|
||||
LogPrintf(LogPHASE, "%s: Entering DIAL state\n", dl->name);
|
||||
log_Printf(LogPHASE, "%s: Entering DIAL state\n", dl->name);
|
||||
dl->state = DATALINK_DIAL;
|
||||
chat_Init(&dl->chat, dl->physical, dl->cfg.script.dial, 1,
|
||||
datalink_ChoosePhoneNumber(dl));
|
||||
if (!(dl->physical->type & (PHYS_PERM|PHYS_DEDICATED)) &&
|
||||
dl->cfg.dial.max)
|
||||
LogPrintf(LogCHAT, "%s: Dial attempt %u of %d\n",
|
||||
log_Printf(LogCHAT, "%s: Dial attempt %u of %d\n",
|
||||
dl->name, dl->cfg.dial.max - dl->dial_tries,
|
||||
dl->cfg.dial.max);
|
||||
return datalink_UpdateSet(d, r, w, e, n);
|
||||
@ -242,15 +242,15 @@ datalink_UpdateSet(struct descriptor *d, fd_set *r, fd_set *w, fd_set *e,
|
||||
} else {
|
||||
if (!(dl->physical->type & (PHYS_PERM|PHYS_DEDICATED)) &&
|
||||
dl->cfg.dial.max)
|
||||
LogPrintf(LogCHAT, "Failed to open modem (attempt %u of %d)\n",
|
||||
log_Printf(LogCHAT, "Failed to open modem (attempt %u of %d)\n",
|
||||
dl->cfg.dial.max - dl->dial_tries, dl->cfg.dial.max);
|
||||
else
|
||||
LogPrintf(LogCHAT, "Failed to open modem\n");
|
||||
log_Printf(LogCHAT, "Failed to open modem\n");
|
||||
|
||||
if (dl->bundle->CleaningUp ||
|
||||
(!(dl->physical->type & (PHYS_PERM|PHYS_DEDICATED)) &&
|
||||
dl->cfg.dial.max && dl->dial_tries == 0)) {
|
||||
LogPrintf(LogPHASE, "%s: Entering CLOSED state\n", dl->name);
|
||||
log_Printf(LogPHASE, "%s: Entering CLOSED state\n", dl->name);
|
||||
dl->state = DATALINK_CLOSED;
|
||||
dl->reconnect_tries = 0;
|
||||
dl->dial_tries = -1;
|
||||
@ -275,7 +275,7 @@ datalink_UpdateSet(struct descriptor *d, fd_set *r, fd_set *w, fd_set *e,
|
||||
datalink_HangupDone(dl);
|
||||
break;
|
||||
case DATALINK_DIAL:
|
||||
LogPrintf(LogPHASE, "%s: Entering LOGIN state\n", dl->name);
|
||||
log_Printf(LogPHASE, "%s: Entering LOGIN state\n", dl->name);
|
||||
dl->state = DATALINK_LOGIN;
|
||||
chat_Init(&dl->chat, dl->physical, dl->cfg.script.login, 0, NULL);
|
||||
return datalink_UpdateSet(d, r, w, e, n);
|
||||
@ -286,7 +286,7 @@ datalink_UpdateSet(struct descriptor *d, fd_set *r, fd_set *w, fd_set *e,
|
||||
break;
|
||||
case CHAT_FAILED:
|
||||
/* Going down - script failed */
|
||||
LogPrintf(LogWARN, "Chat script failed\n");
|
||||
log_Printf(LogWARN, "Chat script failed\n");
|
||||
chat_Destroy(&dl->chat);
|
||||
switch(dl->state) {
|
||||
case DATALINK_HANGUP:
|
||||
@ -294,7 +294,7 @@ datalink_UpdateSet(struct descriptor *d, fd_set *r, fd_set *w, fd_set *e,
|
||||
break;
|
||||
case DATALINK_DIAL:
|
||||
case DATALINK_LOGIN:
|
||||
LogPrintf(LogPHASE, "%s: Entering HANGUP state\n", dl->name);
|
||||
log_Printf(LogPHASE, "%s: Entering HANGUP state\n", dl->name);
|
||||
dl->state = DATALINK_HANGUP;
|
||||
modem_Offline(dl->physical);
|
||||
chat_Init(&dl->chat, dl->physical, dl->cfg.script.hangup, 1, NULL);
|
||||
@ -399,7 +399,7 @@ datalink_ComeDown(struct datalink *dl, int stay)
|
||||
if (dl->state != DATALINK_CLOSED && dl->state != DATALINK_HANGUP) {
|
||||
modem_Offline(dl->physical);
|
||||
if (dl->script.run && dl->state != DATALINK_OPENING) {
|
||||
LogPrintf(LogPHASE, "%s: Entering HANGUP state\n", dl->name);
|
||||
log_Printf(LogPHASE, "%s: Entering HANGUP state\n", dl->name);
|
||||
dl->state = DATALINK_HANGUP;
|
||||
chat_Init(&dl->chat, dl->physical, dl->cfg.script.hangup, 1, NULL);
|
||||
} else
|
||||
@ -430,13 +430,13 @@ datalink_LayerUp(void *v, struct fsm *fp)
|
||||
if (dl->physical->link.lcp.his_auth || dl->physical->link.lcp.want_auth) {
|
||||
if (bundle_Phase(dl->bundle) == PHASE_ESTABLISH)
|
||||
bundle_NewPhase(dl->bundle, PHASE_AUTHENTICATE);
|
||||
LogPrintf(LogPHASE, "%s: his = %s, mine = %s\n", dl->name,
|
||||
log_Printf(LogPHASE, "%s: his = %s, mine = %s\n", dl->name,
|
||||
Auth2Nam(dl->physical->link.lcp.his_auth),
|
||||
Auth2Nam(dl->physical->link.lcp.want_auth));
|
||||
if (dl->physical->link.lcp.his_auth == PROTO_PAP)
|
||||
StartAuthChallenge(&dl->pap, dl->physical, SendPapChallenge);
|
||||
auth_StartChallenge(&dl->pap, dl->physical, pap_SendChallenge);
|
||||
if (dl->physical->link.lcp.want_auth == PROTO_CHAP)
|
||||
StartAuthChallenge(&dl->chap.auth, dl->physical, SendChapChallenge);
|
||||
auth_StartChallenge(&dl->chap.auth, dl->physical, chap_SendChallenge);
|
||||
} else
|
||||
datalink_AuthOk(dl);
|
||||
}
|
||||
@ -461,7 +461,7 @@ datalink_AuthOk(struct datalink *dl)
|
||||
/* We've handed the link off to another ppp ! */
|
||||
return;
|
||||
case MP_UP:
|
||||
AuthSelect(dl->bundle, dl->peer.authname, dl->physical);
|
||||
auth_Select(dl->bundle, dl->peer.authname, dl->physical);
|
||||
/* Fall through */
|
||||
case MP_ADDED:
|
||||
/* We're in multilink mode ! */
|
||||
@ -471,17 +471,17 @@ datalink_AuthOk(struct datalink *dl)
|
||||
return;
|
||||
}
|
||||
} else if (bundle_Phase(dl->bundle) == PHASE_NETWORK) {
|
||||
LogPrintf(LogPHASE, "%s: Already in NETWORK phase\n", dl->name);
|
||||
log_Printf(LogPHASE, "%s: Already in NETWORK phase\n", dl->name);
|
||||
datalink_AuthNotOk(dl);
|
||||
return;
|
||||
} else {
|
||||
dl->bundle->ncp.mp.peer = dl->peer;
|
||||
ipcp_SetLink(&dl->bundle->ncp.ipcp, &dl->physical->link);
|
||||
AuthSelect(dl->bundle, dl->peer.authname, dl->physical);
|
||||
auth_Select(dl->bundle, dl->peer.authname, dl->physical);
|
||||
}
|
||||
|
||||
FsmUp(&dl->physical->link.ccp.fsm);
|
||||
FsmOpen(&dl->physical->link.ccp.fsm);
|
||||
fsm_Up(&dl->physical->link.ccp.fsm);
|
||||
fsm_Open(&dl->physical->link.ccp.fsm);
|
||||
dl->state = DATALINK_OPEN;
|
||||
bundle_NewPhase(dl->bundle, PHASE_NETWORK);
|
||||
(*dl->parent->LayerUp)(dl->parent->object, &dl->physical->link.lcp.fsm);
|
||||
@ -491,7 +491,7 @@ void
|
||||
datalink_AuthNotOk(struct datalink *dl)
|
||||
{
|
||||
dl->state = DATALINK_LCP;
|
||||
FsmClose(&dl->physical->link.lcp.fsm);
|
||||
fsm_Close(&dl->physical->link.lcp.fsm);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -504,14 +504,14 @@ datalink_LayerDown(void *v, struct fsm *fp)
|
||||
switch (dl->state) {
|
||||
case DATALINK_OPEN:
|
||||
peerid_Init(&dl->peer);
|
||||
FsmDown(&dl->physical->link.ccp.fsm);
|
||||
FsmClose(&dl->physical->link.ccp.fsm);
|
||||
fsm_Down(&dl->physical->link.ccp.fsm);
|
||||
fsm_Close(&dl->physical->link.ccp.fsm);
|
||||
(*dl->parent->LayerDown)(dl->parent->object, fp);
|
||||
/* fall through */
|
||||
|
||||
case DATALINK_AUTH:
|
||||
StopTimer(&dl->pap.authtimer);
|
||||
StopTimer(&dl->chap.auth.authtimer);
|
||||
timer_Stop(&dl->pap.authtimer);
|
||||
timer_Stop(&dl->chap.auth.authtimer);
|
||||
}
|
||||
dl->state = DATALINK_LCP;
|
||||
}
|
||||
@ -524,7 +524,7 @@ datalink_LayerFinish(void *v, struct fsm *fp)
|
||||
struct datalink *dl = (struct datalink *)v;
|
||||
|
||||
if (fp->proto == PROTO_LCP) {
|
||||
FsmDown(fp); /* Bring us to INITIAL or STARTING */
|
||||
fsm_Down(fp); /* Bring us to INITIAL or STARTING */
|
||||
(*dl->parent->LayerFinish)(dl->parent->object, fp);
|
||||
datalink_ComeDown(dl, 0);
|
||||
}
|
||||
@ -583,8 +583,8 @@ datalink_Create(const char *name, struct bundle *bundle, int type)
|
||||
dl->fsmp.LayerFinish = datalink_LayerFinish;
|
||||
dl->fsmp.object = dl;
|
||||
|
||||
authinfo_Init(&dl->pap);
|
||||
authinfo_Init(&dl->chap.auth);
|
||||
auth_Init(&dl->pap);
|
||||
auth_Init(&dl->chap.auth);
|
||||
|
||||
if ((dl->physical = modem_Create(dl, type)) == NULL) {
|
||||
free(dl->name);
|
||||
@ -593,7 +593,7 @@ datalink_Create(const char *name, struct bundle *bundle, int type)
|
||||
}
|
||||
chat_Init(&dl->chat, dl->physical, NULL, 1, NULL);
|
||||
|
||||
LogPrintf(LogPHASE, "%s: Created in CLOSED state\n", dl->name);
|
||||
log_Printf(LogPHASE, "%s: Created in CLOSED state\n", dl->name);
|
||||
|
||||
return dl;
|
||||
}
|
||||
@ -632,10 +632,10 @@ datalink_Clone(struct datalink *odl, const char *name)
|
||||
dl->parent = odl->parent;
|
||||
memcpy(&dl->fsmp, &odl->fsmp, sizeof dl->fsmp);
|
||||
dl->fsmp.object = dl;
|
||||
authinfo_Init(&dl->pap);
|
||||
auth_Init(&dl->pap);
|
||||
dl->pap.cfg.fsmretry = odl->pap.cfg.fsmretry;
|
||||
|
||||
authinfo_Init(&dl->chap.auth);
|
||||
auth_Init(&dl->chap.auth);
|
||||
dl->chap.auth.cfg.fsmretry = odl->chap.auth.cfg.fsmretry;
|
||||
|
||||
if ((dl->physical = modem_Create(dl, PHYS_MANUAL)) == NULL) {
|
||||
@ -653,7 +653,7 @@ datalink_Clone(struct datalink *odl, const char *name)
|
||||
|
||||
chat_Init(&dl->chat, dl->physical, NULL, 1, NULL);
|
||||
|
||||
LogPrintf(LogPHASE, "%s: Created in CLOSED state\n", dl->name);
|
||||
log_Printf(LogPHASE, "%s: Created in CLOSED state\n", dl->name);
|
||||
|
||||
return dl;
|
||||
}
|
||||
@ -664,7 +664,7 @@ datalink_Destroy(struct datalink *dl)
|
||||
struct datalink *result;
|
||||
|
||||
if (dl->state != DATALINK_CLOSED) {
|
||||
LogPrintf(LogERROR, "Oops, destroying a datalink in state %s\n",
|
||||
log_Printf(LogERROR, "Oops, destroying a datalink in state %s\n",
|
||||
datalink_State(dl));
|
||||
switch (dl->state) {
|
||||
case DATALINK_HANGUP:
|
||||
@ -692,7 +692,7 @@ datalink_Up(struct datalink *dl, int runscripts, int packetmode)
|
||||
|
||||
switch (dl->state) {
|
||||
case DATALINK_CLOSED:
|
||||
LogPrintf(LogPHASE, "%s: Entering OPENING state\n", dl->name);
|
||||
log_Printf(LogPHASE, "%s: Entering OPENING state\n", dl->name);
|
||||
if (bundle_Phase(dl->bundle) == PHASE_DEAD ||
|
||||
bundle_Phase(dl->bundle) == PHASE_TERMINATE)
|
||||
bundle_NewPhase(dl->bundle, PHASE_ESTABLISH);
|
||||
@ -728,13 +728,13 @@ datalink_Close(struct datalink *dl, int stay)
|
||||
switch (dl->state) {
|
||||
case DATALINK_OPEN:
|
||||
peerid_Init(&dl->peer);
|
||||
FsmDown(&dl->physical->link.ccp.fsm);
|
||||
FsmClose(&dl->physical->link.ccp.fsm);
|
||||
fsm_Down(&dl->physical->link.ccp.fsm);
|
||||
fsm_Close(&dl->physical->link.ccp.fsm);
|
||||
/* fall through */
|
||||
|
||||
case DATALINK_AUTH:
|
||||
case DATALINK_LCP:
|
||||
FsmClose(&dl->physical->link.lcp.fsm);
|
||||
fsm_Close(&dl->physical->link.lcp.fsm);
|
||||
if (stay) {
|
||||
dl->dial_tries = -1;
|
||||
dl->reconnect_tries = 0;
|
||||
@ -753,17 +753,17 @@ datalink_Down(struct datalink *dl, int stay)
|
||||
switch (dl->state) {
|
||||
case DATALINK_OPEN:
|
||||
peerid_Init(&dl->peer);
|
||||
FsmDown(&dl->physical->link.ccp.fsm);
|
||||
FsmClose(&dl->physical->link.ccp.fsm);
|
||||
fsm_Down(&dl->physical->link.ccp.fsm);
|
||||
fsm_Close(&dl->physical->link.ccp.fsm);
|
||||
/* fall through */
|
||||
|
||||
case DATALINK_AUTH:
|
||||
case DATALINK_LCP:
|
||||
FsmDown(&dl->physical->link.lcp.fsm);
|
||||
fsm_Down(&dl->physical->link.lcp.fsm);
|
||||
if (stay)
|
||||
FsmClose(&dl->physical->link.lcp.fsm);
|
||||
fsm_Close(&dl->physical->link.lcp.fsm);
|
||||
else
|
||||
FsmOpen(&dl->physical->link.ccp.fsm);
|
||||
fsm_Open(&dl->physical->link.ccp.fsm);
|
||||
/* fall through */
|
||||
|
||||
default:
|
||||
@ -857,7 +857,7 @@ datalink_SetRedial(struct cmdargs const *arg)
|
||||
if (timeout >= 0)
|
||||
arg->cx->cfg.dial.timeout = timeout;
|
||||
else {
|
||||
LogPrintf(LogWARN, "Invalid redial timeout\n");
|
||||
log_Printf(LogWARN, "Invalid redial timeout\n");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
@ -872,7 +872,7 @@ datalink_SetRedial(struct cmdargs const *arg)
|
||||
if (timeout >= 0)
|
||||
arg->cx->cfg.dial.next_timeout = timeout;
|
||||
else {
|
||||
LogPrintf(LogWARN, "Invalid next redial timeout\n");
|
||||
log_Printf(LogWARN, "Invalid next redial timeout\n");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
@ -886,7 +886,7 @@ datalink_SetRedial(struct cmdargs const *arg)
|
||||
if (tries >= 0) {
|
||||
arg->cx->cfg.dial.max = tries;
|
||||
} else {
|
||||
LogPrintf(LogWARN, "Invalid retry value\n");
|
||||
log_Printf(LogWARN, "Invalid retry value\n");
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
@ -932,7 +932,7 @@ datalink_FromBinary(struct bundle *bundle, int fd)
|
||||
|
||||
got = fullread(fd, dl, sizeof *dl);
|
||||
if (got != sizeof *dl) {
|
||||
LogPrintf(LogWARN, "Cannot receive datalink"
|
||||
log_Printf(LogWARN, "Cannot receive datalink"
|
||||
" (got %d bytes, not %d)\n", got, sizeof *dl);
|
||||
close(fd);
|
||||
free(dl);
|
||||
@ -941,7 +941,7 @@ datalink_FromBinary(struct bundle *bundle, int fd)
|
||||
|
||||
got = fullread(fd, &get, sizeof get);
|
||||
if (got != sizeof get) {
|
||||
LogPrintf(LogWARN, "Cannot receive name length"
|
||||
log_Printf(LogWARN, "Cannot receive name length"
|
||||
" (got %d bytes, not %d)\n", got, sizeof get);
|
||||
close(fd);
|
||||
free(dl);
|
||||
@ -951,7 +951,7 @@ datalink_FromBinary(struct bundle *bundle, int fd)
|
||||
dl->name = (char *)malloc(get + 1);
|
||||
got = fullread(fd, dl->name, get);
|
||||
if (got != get) {
|
||||
LogPrintf(LogWARN, "Cannot receive name"
|
||||
log_Printf(LogWARN, "Cannot receive name"
|
||||
" (got %d bytes, not %d)\n", got, get);
|
||||
close(fd);
|
||||
free(dl->name);
|
||||
@ -986,16 +986,16 @@ datalink_FromBinary(struct bundle *bundle, int fd)
|
||||
dl->fsmp.object = dl;
|
||||
|
||||
retry = dl->pap.cfg.fsmretry;
|
||||
authinfo_Init(&dl->pap);
|
||||
auth_Init(&dl->pap);
|
||||
dl->pap.cfg.fsmretry = retry;
|
||||
|
||||
retry = dl->chap.auth.cfg.fsmretry;
|
||||
authinfo_Init(&dl->chap.auth);
|
||||
auth_Init(&dl->chap.auth);
|
||||
dl->chap.auth.cfg.fsmretry = retry;
|
||||
|
||||
got = fullread(fd, &get, sizeof get);
|
||||
if (got != sizeof get) {
|
||||
LogPrintf(LogWARN, "Cannot receive physical length"
|
||||
log_Printf(LogWARN, "Cannot receive physical length"
|
||||
" (got %d bytes, not %d)\n", got, sizeof get);
|
||||
close(fd);
|
||||
free(dl->name);
|
||||
@ -1023,9 +1023,9 @@ datalink_ToBinary(struct datalink *dl, int fd)
|
||||
* `----------'----------'------'--------------'
|
||||
*/
|
||||
|
||||
StopTimer(&dl->dial_timer);
|
||||
StopTimer(&dl->pap.authtimer);
|
||||
StopTimer(&dl->chap.auth.authtimer);
|
||||
timer_Stop(&dl->dial_timer);
|
||||
timer_Stop(&dl->pap.authtimer);
|
||||
timer_Stop(&dl->chap.auth.authtimer);
|
||||
|
||||
if (fd != -1) {
|
||||
int err;
|
||||
@ -1043,7 +1043,7 @@ datalink_ToBinary(struct datalink *dl, int fd)
|
||||
err++;
|
||||
|
||||
if (err) {
|
||||
LogPrintf(LogERROR, "Failed sending datalink\n");
|
||||
log_Printf(LogERROR, "Failed sending datalink\n");
|
||||
close(fd);
|
||||
fd = -1;
|
||||
}
|
||||
@ -1070,7 +1070,7 @@ datalink_Rename(struct datalink *dl)
|
||||
break;
|
||||
n = sprintf(name, "%.*s-", dl->name[f] == '-' ? f : f + 1, dl->name);
|
||||
sprintf(name + n, "%d", atoi(dl->name + f + 1) + 1);
|
||||
LogPrintf(LogPHASE, "Rename link %s to %s\n", dl->name, name);
|
||||
log_Printf(LogPHASE, "Rename link %s to %s\n", dl->name, name);
|
||||
free(dl->name);
|
||||
dl->physical->link.name = dl->name = name;
|
||||
}
|
||||
|
@ -23,7 +23,7 @@
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $Id: datalink.h,v 1.1.2.19 1998/04/24 19:16:02 brian Exp $
|
||||
* $Id: datalink.h,v 1.1.2.20 1998/04/30 23:53:33 brian Exp $
|
||||
*/
|
||||
|
||||
#define DATALINK_CLOSED (0)
|
||||
@ -100,7 +100,6 @@ struct datalink {
|
||||
struct datalink *next; /* Next in the list */
|
||||
};
|
||||
|
||||
#define datalink2descriptor(dl) (&(dl)->desc)
|
||||
#define descriptor2datalink(d) \
|
||||
((d)->type == DATALINK_DESCRIPTOR ? (struct datalink *)(d) : NULL)
|
||||
|
||||
|
@ -23,7 +23,7 @@
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $Id: deflate.c,v 1.6.4.13 1998/04/25 00:09:10 brian Exp $
|
||||
* $Id: deflate.c,v 1.6.4.14 1998/04/25 10:48:56 brian Exp $
|
||||
*/
|
||||
|
||||
#include <sys/types.h>
|
||||
@ -63,7 +63,7 @@ DeflateResetOutput(void *v)
|
||||
state->seqno = 0;
|
||||
state->uncomp_rec = 0;
|
||||
deflateReset(&state->cx);
|
||||
LogPrintf(LogCCP, "Deflate: Output channel reset\n");
|
||||
log_Printf(LogCCP, "Deflate: Output channel reset\n");
|
||||
}
|
||||
|
||||
static int
|
||||
@ -75,12 +75,12 @@ DeflateOutput(void *v, struct ccp *ccp, struct link *l, int pri, u_short proto,
|
||||
int olen, ilen, len, res, flush;
|
||||
struct mbuf *mo_head, *mo, *mi_head, *mi;
|
||||
|
||||
ilen = plength(mp);
|
||||
LogPrintf(LogDEBUG, "DeflateOutput: Proto %02x (%d bytes)\n", proto, ilen);
|
||||
LogDumpBp(LogDEBUG, "DeflateOutput: Compress packet:", mp);
|
||||
ilen = mbuf_Length(mp);
|
||||
log_Printf(LogDEBUG, "DeflateOutput: Proto %02x (%d bytes)\n", proto, ilen);
|
||||
log_DumpBp(LogDEBUG, "DeflateOutput: Compress packet:", mp);
|
||||
|
||||
/* Stuff the protocol in front of the input */
|
||||
mi_head = mi = mballoc(2, MB_HDLCOUT);
|
||||
mi_head = mi = mbuf_Alloc(2, MB_HDLCOUT);
|
||||
mi->next = mp;
|
||||
rp = MBUF_CTOP(mi);
|
||||
if (proto < 0x100) { /* Compress the protocol */
|
||||
@ -93,12 +93,12 @@ DeflateOutput(void *v, struct ccp *ccp, struct link *l, int pri, u_short proto,
|
||||
}
|
||||
|
||||
/* Allocate the initial output mbuf */
|
||||
mo_head = mo = mballoc(DEFLATE_CHUNK_LEN, MB_HDLCOUT);
|
||||
mo_head = mo = mbuf_Alloc(DEFLATE_CHUNK_LEN, MB_HDLCOUT);
|
||||
mo->cnt = 2;
|
||||
wp = MBUF_CTOP(mo);
|
||||
*wp++ = state->seqno >> 8;
|
||||
*wp++ = state->seqno & 0377;
|
||||
LogPrintf(LogDEBUG, "DeflateOutput: Seq %d\n", state->seqno);
|
||||
log_Printf(LogDEBUG, "DeflateOutput: Seq %d\n", state->seqno);
|
||||
state->seqno++;
|
||||
|
||||
/* Set up the deflation context */
|
||||
@ -113,10 +113,10 @@ DeflateOutput(void *v, struct ccp *ccp, struct link *l, int pri, u_short proto,
|
||||
if ((res = deflate(&state->cx, flush)) != Z_OK) {
|
||||
if (res == Z_STREAM_END)
|
||||
break; /* Done */
|
||||
LogPrintf(LogERROR, "DeflateOutput: deflate returned %d (%s)\n",
|
||||
log_Printf(LogERROR, "DeflateOutput: deflate returned %d (%s)\n",
|
||||
res, state->cx.msg ? state->cx.msg : "");
|
||||
pfree(mo_head);
|
||||
mbfree(mi_head);
|
||||
mbuf_Free(mo_head);
|
||||
mbuf_FreeSeg(mi_head);
|
||||
state->seqno--;
|
||||
return 1; /* packet dropped */
|
||||
}
|
||||
@ -133,7 +133,7 @@ DeflateOutput(void *v, struct ccp *ccp, struct link *l, int pri, u_short proto,
|
||||
}
|
||||
|
||||
if (state->cx.avail_out == 0) {
|
||||
mo->next = mballoc(DEFLATE_CHUNK_LEN, MB_HDLCOUT);
|
||||
mo->next = mbuf_Alloc(DEFLATE_CHUNK_LEN, MB_HDLCOUT);
|
||||
olen += (mo->cnt = DEFLATE_CHUNK_LEN);
|
||||
mo = mo->next;
|
||||
mo->cnt = 0;
|
||||
@ -147,20 +147,20 @@ DeflateOutput(void *v, struct ccp *ccp, struct link *l, int pri, u_short proto,
|
||||
|
||||
/*
|
||||
* If the output packet (including seqno and excluding the EMPTY_BLOCK)
|
||||
* got bigger, send the original - returning 0 to HdlcOutput() will
|
||||
* got bigger, send the original - returning 0 to hdlc_Output() will
|
||||
* continue to send ``mp''.
|
||||
*/
|
||||
if (olen >= ilen) {
|
||||
pfree(mo_head);
|
||||
mbfree(mi_head);
|
||||
LogPrintf(LogDEBUG, "DeflateOutput: %d => %d: Uncompressible (0x%04x)\n",
|
||||
mbuf_Free(mo_head);
|
||||
mbuf_FreeSeg(mi_head);
|
||||
log_Printf(LogDEBUG, "DeflateOutput: %d => %d: Uncompressible (0x%04x)\n",
|
||||
ilen, olen, proto);
|
||||
ccp->uncompout += ilen;
|
||||
ccp->compout += ilen; /* We measure this stuff too */
|
||||
return 0;
|
||||
}
|
||||
|
||||
pfree(mi_head);
|
||||
mbuf_Free(mi_head);
|
||||
|
||||
/*
|
||||
* Lose the last four bytes of our output.
|
||||
@ -171,17 +171,17 @@ DeflateOutput(void *v, struct ccp *ccp, struct link *l, int pri, u_short proto,
|
||||
;
|
||||
mo->cnt -= len - olen;
|
||||
if (mo->next != NULL) {
|
||||
pfree(mo->next);
|
||||
mbuf_Free(mo->next);
|
||||
mo->next = NULL;
|
||||
}
|
||||
|
||||
ccp->uncompout += ilen;
|
||||
ccp->compout += olen;
|
||||
|
||||
LogPrintf(LogDEBUG, "DeflateOutput: %d => %d bytes, proto 0x%04x\n",
|
||||
log_Printf(LogDEBUG, "DeflateOutput: %d => %d bytes, proto 0x%04x\n",
|
||||
ilen, olen, proto);
|
||||
|
||||
HdlcOutput(l, PRI_NORMAL, ccp_Proto(ccp), mo_head);
|
||||
hdlc_Output(l, PRI_NORMAL, ccp_Proto(ccp), mo_head);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -193,7 +193,7 @@ DeflateResetInput(void *v)
|
||||
state->seqno = 0;
|
||||
state->uncomp_rec = 0;
|
||||
inflateReset(&state->cx);
|
||||
LogPrintf(LogCCP, "Deflate: Input channel reset\n");
|
||||
log_Printf(LogCCP, "Deflate: Input channel reset\n");
|
||||
}
|
||||
|
||||
static struct mbuf *
|
||||
@ -206,13 +206,13 @@ DeflateInput(void *v, struct ccp *ccp, u_short *proto, struct mbuf *mi)
|
||||
int seq, flush, res, first;
|
||||
u_char hdr[2];
|
||||
|
||||
LogDumpBp(LogDEBUG, "DeflateInput: Decompress packet:", mi);
|
||||
mi_head = mi = mbread(mi, hdr, 2);
|
||||
log_DumpBp(LogDEBUG, "DeflateInput: Decompress packet:", mi);
|
||||
mi_head = mi = mbuf_Read(mi, hdr, 2);
|
||||
ilen = 2;
|
||||
|
||||
/* Check the sequence number. */
|
||||
seq = (hdr[0] << 8) + hdr[1];
|
||||
LogPrintf(LogDEBUG, "DeflateInput: Seq %d\n", seq);
|
||||
log_Printf(LogDEBUG, "DeflateInput: Seq %d\n", seq);
|
||||
if (seq != state->seqno) {
|
||||
if (seq <= state->uncomp_rec)
|
||||
/*
|
||||
@ -222,10 +222,10 @@ DeflateInput(void *v, struct ccp *ccp, u_short *proto, struct mbuf *mi)
|
||||
*/
|
||||
state->seqno = seq;
|
||||
else {
|
||||
LogPrintf(LogERROR, "DeflateInput: Seq error: Got %d, expected %d\n",
|
||||
log_Printf(LogERROR, "DeflateInput: Seq error: Got %d, expected %d\n",
|
||||
seq, state->seqno);
|
||||
pfree(mi_head);
|
||||
CcpSendResetReq(&ccp->fsm);
|
||||
mbuf_Free(mi_head);
|
||||
ccp_SendResetReq(&ccp->fsm);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
@ -233,7 +233,7 @@ DeflateInput(void *v, struct ccp *ccp, u_short *proto, struct mbuf *mi)
|
||||
state->uncomp_rec = 0;
|
||||
|
||||
/* Allocate an output mbuf */
|
||||
mo_head = mo = mballoc(DEFLATE_CHUNK_LEN, MB_IPIN);
|
||||
mo_head = mo = mbuf_Alloc(DEFLATE_CHUNK_LEN, MB_IPIN);
|
||||
|
||||
/* Our proto starts with 0 if it's compressed */
|
||||
wp = MBUF_CTOP(mo);
|
||||
@ -258,18 +258,18 @@ DeflateInput(void *v, struct ccp *ccp, u_short *proto, struct mbuf *mi)
|
||||
if ((res = inflate(&state->cx, flush)) != Z_OK) {
|
||||
if (res == Z_STREAM_END)
|
||||
break; /* Done */
|
||||
LogPrintf(LogERROR, "DeflateInput: inflate returned %d (%s)\n",
|
||||
log_Printf(LogERROR, "DeflateInput: inflate returned %d (%s)\n",
|
||||
res, state->cx.msg ? state->cx.msg : "");
|
||||
pfree(mo_head);
|
||||
pfree(mi);
|
||||
CcpSendResetReq(&ccp->fsm);
|
||||
mbuf_Free(mo_head);
|
||||
mbuf_Free(mi);
|
||||
ccp_SendResetReq(&ccp->fsm);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (flush == Z_SYNC_FLUSH && state->cx.avail_out != 0)
|
||||
break;
|
||||
|
||||
if (state->cx.avail_in == 0 && mi && (mi = mbfree(mi)) != NULL) {
|
||||
if (state->cx.avail_in == 0 && mi && (mi = mbuf_FreeSeg(mi)) != NULL) {
|
||||
/* underflow */
|
||||
state->cx.next_in = MBUF_CTOP(mi);
|
||||
ilen += (state->cx.avail_in = mi->cnt);
|
||||
@ -290,7 +290,7 @@ DeflateInput(void *v, struct ccp *ccp, u_short *proto, struct mbuf *mi)
|
||||
first = 0;
|
||||
} else {
|
||||
olen += (mo->cnt = DEFLATE_CHUNK_LEN);
|
||||
mo->next = mballoc(DEFLATE_CHUNK_LEN, MB_IPIN);
|
||||
mo->next = mbuf_Alloc(DEFLATE_CHUNK_LEN, MB_IPIN);
|
||||
mo = mo->next;
|
||||
state->cx.next_out = MBUF_CTOP(mo);
|
||||
state->cx.avail_out = DEFLATE_CHUNK_LEN;
|
||||
@ -299,12 +299,12 @@ DeflateInput(void *v, struct ccp *ccp, u_short *proto, struct mbuf *mi)
|
||||
}
|
||||
|
||||
if (mi != NULL)
|
||||
pfree(mi);
|
||||
mbuf_Free(mi);
|
||||
|
||||
if (first) {
|
||||
LogPrintf(LogERROR, "DeflateInput: Length error\n");
|
||||
pfree(mo_head);
|
||||
CcpSendResetReq(&ccp->fsm);
|
||||
log_Printf(LogERROR, "DeflateInput: Length error\n");
|
||||
mbuf_Free(mo_head);
|
||||
ccp_SendResetReq(&ccp->fsm);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@ -318,7 +318,7 @@ DeflateInput(void *v, struct ccp *ccp, u_short *proto, struct mbuf *mi)
|
||||
ccp->compin += ilen;
|
||||
ccp->uncompin += olen;
|
||||
|
||||
LogPrintf(LogDEBUG, "DeflateInput: %d => %d bytes, proto 0x%04x\n",
|
||||
log_Printf(LogDEBUG, "DeflateInput: %d => %d bytes, proto 0x%04x\n",
|
||||
ilen, olen, *proto);
|
||||
|
||||
/*
|
||||
@ -343,15 +343,15 @@ DeflateDictSetup(void *v, struct ccp *ccp, u_short proto, struct mbuf *mi)
|
||||
struct mbuf *mi_head;
|
||||
short len;
|
||||
|
||||
LogPrintf(LogDEBUG, "DeflateDictSetup: Got seq %d\n", state->seqno);
|
||||
log_Printf(LogDEBUG, "DeflateDictSetup: Got seq %d\n", state->seqno);
|
||||
|
||||
/*
|
||||
* Stuff an ``uncompressed data'' block header followed by the
|
||||
* protocol in front of the input
|
||||
*/
|
||||
mi_head = mballoc(7, MB_HDLCOUT);
|
||||
mi_head = mbuf_Alloc(7, MB_HDLCOUT);
|
||||
mi_head->next = mi;
|
||||
len = plength(mi);
|
||||
len = mbuf_Length(mi);
|
||||
mi = mi_head;
|
||||
rp = MBUF_CTOP(mi);
|
||||
if (proto < 0x100) { /* Compress the protocol */
|
||||
@ -383,12 +383,12 @@ DeflateDictSetup(void *v, struct ccp *ccp, u_short proto, struct mbuf *mi)
|
||||
break; /* Done */
|
||||
if (expect_error && res == Z_BUF_ERROR)
|
||||
break;
|
||||
LogPrintf(LogERROR, "DeflateDictSetup: inflate returned %d (%s)\n",
|
||||
log_Printf(LogERROR, "DeflateDictSetup: inflate returned %d (%s)\n",
|
||||
res, state->cx.msg ? state->cx.msg : "");
|
||||
LogPrintf(LogERROR, "DeflateDictSetup: avail_in %d, avail_out %d\n",
|
||||
log_Printf(LogERROR, "DeflateDictSetup: avail_in %d, avail_out %d\n",
|
||||
state->cx.avail_in, state->cx.avail_out);
|
||||
CcpSendResetReq(&ccp->fsm);
|
||||
mbfree(mi_head); /* lose our allocated ``head'' buf */
|
||||
ccp_SendResetReq(&ccp->fsm);
|
||||
mbuf_FreeSeg(mi_head); /* lose our allocated ``head'' buf */
|
||||
return;
|
||||
}
|
||||
|
||||
@ -428,7 +428,7 @@ DeflateDictSetup(void *v, struct ccp *ccp, u_short proto, struct mbuf *mi)
|
||||
|
||||
state->seqno++;
|
||||
state->uncomp_rec++;
|
||||
mbfree(mi_head); /* lose our allocated ``head'' buf */
|
||||
mbuf_FreeSeg(mi_head); /* lose our allocated ``head'' buf */
|
||||
}
|
||||
|
||||
static const char *
|
||||
|
@ -15,7 +15,7 @@
|
||||
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* $Id: defs.h,v 1.29.2.15 1998/04/30 23:53:36 brian Exp $
|
||||
* $Id: defs.h,v 1.29.2.16 1998/05/01 19:20:03 brian Exp $
|
||||
*
|
||||
* TODO:
|
||||
*/
|
||||
@ -31,6 +31,8 @@
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#define _PATH_PPP "/etc/ppp"
|
||||
|
||||
#define TUN_PREFIX "/dev/tun" /* tunnel device prefix */
|
||||
#define CATPROG "/bin/cat" /* Multilink pipe program name */
|
||||
|
||||
|
@ -17,7 +17,7 @@
|
||||
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* $Id: filter.c,v 1.22.2.17 1998/04/25 10:48:59 brian Exp $
|
||||
* $Id: filter.c,v 1.22.2.18 1998/04/28 01:25:14 brian Exp $
|
||||
*
|
||||
* TODO: Shoud send ICMP error message when we discard packets.
|
||||
*/
|
||||
@ -80,7 +80,7 @@ ParseAddr(struct ipcp *ipcp, int argc, char const *const *argv,
|
||||
const char *cp;
|
||||
|
||||
if (argc < 1) {
|
||||
LogPrintf(LogWARN, "ParseAddr: address/mask is expected.\n");
|
||||
log_Printf(LogWARN, "ParseAddr: address/mask is expected.\n");
|
||||
return (0);
|
||||
}
|
||||
|
||||
@ -95,20 +95,20 @@ ParseAddr(struct ipcp *ipcp, int argc, char const *const *argv,
|
||||
else if (strncasecmp(*argv, "MYADDR", len) == 0)
|
||||
*paddr = ipcp->my_ip;
|
||||
else if (len > 15)
|
||||
LogPrintf(LogWARN, "ParseAddr: %s: Bad address\n", *argv);
|
||||
log_Printf(LogWARN, "ParseAddr: %s: Bad address\n", *argv);
|
||||
else {
|
||||
char s[16];
|
||||
strncpy(s, *argv, len);
|
||||
s[len] = '\0';
|
||||
if (inet_aton(s, paddr) == 0) {
|
||||
LogPrintf(LogWARN, "ParseAddr: %s: Bad address\n", s);
|
||||
log_Printf(LogWARN, "ParseAddr: %s: Bad address\n", s);
|
||||
return (0);
|
||||
}
|
||||
}
|
||||
if (cp && *++cp) {
|
||||
bits = strtol(cp, &wp, 0);
|
||||
if (cp == wp || bits < 0 || bits > 32) {
|
||||
LogPrintf(LogWARN, "ParseAddr: bad mask width.\n");
|
||||
log_Printf(LogWARN, "ParseAddr: bad mask width.\n");
|
||||
return (0);
|
||||
}
|
||||
} else if (paddr->s_addr == INADDR_ANY)
|
||||
@ -152,7 +152,7 @@ ParsePort(const char *service, int proto)
|
||||
|
||||
port = strtol(service, &cp, 0);
|
||||
if (cp == service) {
|
||||
LogPrintf(LogWARN, "ParsePort: %s is not a port name or number.\n",
|
||||
log_Printf(LogWARN, "ParsePort: %s is not a port name or number.\n",
|
||||
service);
|
||||
return (0);
|
||||
}
|
||||
@ -178,7 +178,7 @@ ParseIcmp(int argc, char const *const *argv, struct filterent *tgt)
|
||||
if (!strcmp(*argv, "src") && !strcmp(argv[1], "eq")) {
|
||||
type = strtol(argv[2], &cp, 0);
|
||||
if (cp == argv[2]) {
|
||||
LogPrintf(LogWARN, "ParseIcmp: type is expected.\n");
|
||||
log_Printf(LogWARN, "ParseIcmp: type is expected.\n");
|
||||
return (0);
|
||||
}
|
||||
tgt->opt.srcop = OP_EQ;
|
||||
@ -187,7 +187,7 @@ ParseIcmp(int argc, char const *const *argv, struct filterent *tgt)
|
||||
break;
|
||||
|
||||
default:
|
||||
LogPrintf(LogWARN, "ParseIcmp: bad icmp syntax.\n");
|
||||
log_Printf(LogWARN, "ParseIcmp: bad icmp syntax.\n");
|
||||
return (0);
|
||||
}
|
||||
return (1);
|
||||
@ -206,7 +206,7 @@ ParseUdpOrTcp(int argc, char const *const *argv, int proto,
|
||||
if (argc >= 3 && !strcmp(*argv, "src")) {
|
||||
tgt->opt.srcop = filter_Nam2Op(argv[1]);
|
||||
if (tgt->opt.srcop == OP_NONE) {
|
||||
LogPrintf(LogWARN, "ParseUdpOrTcp: bad operation\n");
|
||||
log_Printf(LogWARN, "ParseUdpOrTcp: bad operation\n");
|
||||
return (0);
|
||||
}
|
||||
tgt->opt.srcport = ParsePort(argv[2], proto);
|
||||
@ -219,7 +219,7 @@ ParseUdpOrTcp(int argc, char const *const *argv, int proto,
|
||||
if (argc >= 3 && !strcmp(argv[0], "dst")) {
|
||||
tgt->opt.dstop = filter_Nam2Op(argv[1]);
|
||||
if (tgt->opt.dstop == OP_NONE) {
|
||||
LogPrintf(LogWARN, "ParseUdpOrTcp: bad operation\n");
|
||||
log_Printf(LogWARN, "ParseUdpOrTcp: bad operation\n");
|
||||
return (0);
|
||||
}
|
||||
tgt->opt.dstport = ParsePort(argv[2], proto);
|
||||
@ -242,7 +242,7 @@ ParseUdpOrTcp(int argc, char const *const *argv, int proto,
|
||||
}
|
||||
|
||||
if (argc > 0) {
|
||||
LogPrintf(LogWARN, "ParseUdpOrTcp: bad src/dst port syntax: %s\n", *argv);
|
||||
log_Printf(LogWARN, "ParseUdpOrTcp: bad src/dst port syntax: %s\n", *argv);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -260,7 +260,7 @@ Parse(struct ipcp *ipcp, int argc, char const *const *argv,
|
||||
|
||||
val = strtol(*argv, &wp, 0);
|
||||
if (*argv == wp || val > MAXFILTERS) {
|
||||
LogPrintf(LogWARN, "Parse: invalid filter number.\n");
|
||||
log_Printf(LogWARN, "Parse: invalid filter number.\n");
|
||||
return (0);
|
||||
}
|
||||
if (val < 0) {
|
||||
@ -268,13 +268,13 @@ Parse(struct ipcp *ipcp, int argc, char const *const *argv,
|
||||
ofp->action = A_NONE;
|
||||
ofp++;
|
||||
}
|
||||
LogPrintf(LogWARN, "Parse: filter cleared.\n");
|
||||
log_Printf(LogWARN, "Parse: filter cleared.\n");
|
||||
return (1);
|
||||
}
|
||||
ofp += val;
|
||||
|
||||
if (--argc == 0) {
|
||||
LogPrintf(LogWARN, "Parse: missing action.\n");
|
||||
log_Printf(LogWARN, "Parse: missing action.\n");
|
||||
return (0);
|
||||
}
|
||||
argv++;
|
||||
@ -290,7 +290,7 @@ Parse(struct ipcp *ipcp, int argc, char const *const *argv,
|
||||
ofp->action = A_NONE;
|
||||
return (1);
|
||||
} else {
|
||||
LogPrintf(LogWARN, "Parse: bad action: %s\n", *argv);
|
||||
log_Printf(LogWARN, "Parse: bad action: %s\n", *argv);
|
||||
return (0);
|
||||
}
|
||||
filterdata.action = action;
|
||||
@ -332,7 +332,7 @@ Parse(struct ipcp *ipcp, int argc, char const *const *argv,
|
||||
argv++;
|
||||
}
|
||||
} else {
|
||||
LogPrintf(LogWARN, "Parse: Address/protocol expected.\n");
|
||||
log_Printf(LogWARN, "Parse: Address/protocol expected.\n");
|
||||
return (0);
|
||||
}
|
||||
} else {
|
||||
@ -355,19 +355,19 @@ Parse(struct ipcp *ipcp, int argc, char const *const *argv,
|
||||
break;
|
||||
}
|
||||
|
||||
LogPrintf(LogDEBUG, "Parse: Src: %s\n", inet_ntoa(filterdata.saddr));
|
||||
LogPrintf(LogDEBUG, "Parse: Src mask: %s\n", inet_ntoa(filterdata.smask));
|
||||
LogPrintf(LogDEBUG, "Parse: Dst: %s\n", inet_ntoa(filterdata.daddr));
|
||||
LogPrintf(LogDEBUG, "Parse: Dst mask: %s\n", inet_ntoa(filterdata.dmask));
|
||||
LogPrintf(LogDEBUG, "Parse: Proto = %d\n", proto);
|
||||
log_Printf(LogDEBUG, "Parse: Src: %s\n", inet_ntoa(filterdata.saddr));
|
||||
log_Printf(LogDEBUG, "Parse: Src mask: %s\n", inet_ntoa(filterdata.smask));
|
||||
log_Printf(LogDEBUG, "Parse: Dst: %s\n", inet_ntoa(filterdata.daddr));
|
||||
log_Printf(LogDEBUG, "Parse: Dst mask: %s\n", inet_ntoa(filterdata.dmask));
|
||||
log_Printf(LogDEBUG, "Parse: Proto = %d\n", proto);
|
||||
|
||||
LogPrintf(LogDEBUG, "Parse: src: %s (%d)\n",
|
||||
log_Printf(LogDEBUG, "Parse: src: %s (%d)\n",
|
||||
filter_Op2Nam(filterdata.opt.srcop), filterdata.opt.srcport);
|
||||
LogPrintf(LogDEBUG, "Parse: dst: %s (%d)\n",
|
||||
log_Printf(LogDEBUG, "Parse: dst: %s (%d)\n",
|
||||
filter_Op2Nam(filterdata.opt.dstop), filterdata.opt.dstport);
|
||||
LogPrintf(LogDEBUG, "Parse: estab: %u\n", filterdata.opt.estab);
|
||||
LogPrintf(LogDEBUG, "Parse: syn: %u\n", filterdata.opt.syn);
|
||||
LogPrintf(LogDEBUG, "Parse: finrst: %u\n", filterdata.opt.finrst);
|
||||
log_Printf(LogDEBUG, "Parse: estab: %u\n", filterdata.opt.estab);
|
||||
log_Printf(LogDEBUG, "Parse: syn: %u\n", filterdata.opt.syn);
|
||||
log_Printf(LogDEBUG, "Parse: finrst: %u\n", filterdata.opt.finrst);
|
||||
|
||||
if (val)
|
||||
*ofp = filterdata;
|
||||
@ -375,7 +375,7 @@ Parse(struct ipcp *ipcp, int argc, char const *const *argv,
|
||||
}
|
||||
|
||||
int
|
||||
SetFilter(struct cmdargs const *arg)
|
||||
filter_Set(struct cmdargs const *arg)
|
||||
{
|
||||
struct filter *filter;
|
||||
|
||||
@ -391,7 +391,7 @@ SetFilter(struct cmdargs const *arg)
|
||||
else if (!strcmp(arg->argv[arg->argn], "alive"))
|
||||
filter = &arg->bundle->filter.alive;
|
||||
else {
|
||||
LogPrintf(LogWARN, "SetFilter: %s: Invalid filter name.\n",
|
||||
log_Printf(LogWARN, "filter_Set: %s: Invalid filter name.\n",
|
||||
arg->argv[arg->argn]);
|
||||
return -1;
|
||||
}
|
||||
@ -446,7 +446,7 @@ doShowFilter(struct filterent *fp, struct prompt *prompt)
|
||||
}
|
||||
|
||||
int
|
||||
ShowFilter(struct cmdargs const *arg)
|
||||
filter_Show(struct cmdargs const *arg)
|
||||
{
|
||||
if (arg->argc > arg->argn+1)
|
||||
return -1;
|
||||
|
@ -15,7 +15,7 @@
|
||||
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* $Id: filter.h,v 1.11.2.5 1998/04/16 18:30:52 brian Exp $
|
||||
* $Id: filter.h,v 1.11.2.6 1998/04/18 01:01:20 brian Exp $
|
||||
*
|
||||
* TODO:
|
||||
*/
|
||||
@ -85,8 +85,8 @@ struct cmdargs;
|
||||
|
||||
extern int ParseAddr(struct ipcp *, int, char const *const *, struct in_addr *,
|
||||
struct in_addr *, int *);
|
||||
extern int ShowFilter(struct cmdargs const *);
|
||||
extern int SetFilter(struct cmdargs const *);
|
||||
extern int filter_Show(struct cmdargs const *);
|
||||
extern int filter_Set(struct cmdargs const *);
|
||||
extern const char * filter_Action2Nam(int);
|
||||
extern const char *filter_Proto2Nam(int);
|
||||
extern const char *filter_Op2Nam(int);
|
||||
|
@ -17,7 +17,7 @@
|
||||
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* $Id: fsm.c,v 1.27.2.33 1998/04/28 01:25:15 brian Exp $
|
||||
* $Id: fsm.c,v 1.27.2.34 1998/04/30 23:53:38 brian Exp $
|
||||
*
|
||||
* TODO:
|
||||
*/
|
||||
@ -113,16 +113,16 @@ StoppedTimeout(void *v)
|
||||
{
|
||||
struct fsm *fp = (struct fsm *)v;
|
||||
|
||||
LogPrintf(fp->LogLevel, "%s: Stopped timer expired\n", fp->link->name);
|
||||
log_Printf(fp->LogLevel, "%s: Stopped timer expired\n", fp->link->name);
|
||||
if (fp->OpenTimer.state == TIMER_RUNNING) {
|
||||
LogPrintf(LogWARN, "%s: %s: aborting open delay due to stopped timer\n",
|
||||
log_Printf(LogWARN, "%s: %s: aborting open delay due to stopped timer\n",
|
||||
fp->link->name, fp->name);
|
||||
StopTimer(&fp->OpenTimer);
|
||||
timer_Stop(&fp->OpenTimer);
|
||||
}
|
||||
if (fp->state == ST_STOPPED) {
|
||||
/* Force ourselves back to initial */
|
||||
FsmDown(fp);
|
||||
FsmClose(fp);
|
||||
fsm_Down(fp);
|
||||
fsm_Close(fp);
|
||||
}
|
||||
}
|
||||
|
||||
@ -156,31 +156,31 @@ fsm_Init(struct fsm *fp, const char *name, u_short proto, int mincode,
|
||||
static void
|
||||
NewState(struct fsm * fp, int new)
|
||||
{
|
||||
LogPrintf(fp->LogLevel, "%s: State change %s --> %s\n",
|
||||
log_Printf(fp->LogLevel, "%s: State change %s --> %s\n",
|
||||
fp->link->name, State2Nam(fp->state), State2Nam(new));
|
||||
if (fp->state == ST_STOPPED && fp->StoppedTimer.state == TIMER_RUNNING)
|
||||
StopTimer(&fp->StoppedTimer);
|
||||
timer_Stop(&fp->StoppedTimer);
|
||||
fp->state = new;
|
||||
if ((new >= ST_INITIAL && new <= ST_STOPPED) || (new == ST_OPENED)) {
|
||||
StopTimer(&fp->FsmTimer);
|
||||
timer_Stop(&fp->FsmTimer);
|
||||
if (new == ST_STOPPED && fp->StoppedTimer.load) {
|
||||
StopTimer(&fp->StoppedTimer);
|
||||
timer_Stop(&fp->StoppedTimer);
|
||||
fp->StoppedTimer.func = StoppedTimeout;
|
||||
fp->StoppedTimer.arg = (void *) fp;
|
||||
StartTimer(&fp->StoppedTimer);
|
||||
timer_Start(&fp->StoppedTimer);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
FsmOutput(struct fsm *fp, u_int code, u_int id, u_char *ptr, int count)
|
||||
fsm_Output(struct fsm *fp, u_int code, u_int id, u_char *ptr, int count)
|
||||
{
|
||||
int plen;
|
||||
struct fsmheader lh;
|
||||
struct mbuf *bp;
|
||||
|
||||
if (LogIsKept(fp->LogLevel)) {
|
||||
LogPrintf(fp->LogLevel, "%s: Send%s(%d) state = %s\n",
|
||||
if (log_IsKept(fp->LogLevel)) {
|
||||
log_Printf(fp->LogLevel, "%s: Send%s(%d) state = %s\n",
|
||||
fp->link->name, Code2Nam(code), id, State2Nam(fp->state));
|
||||
switch (code) {
|
||||
case CODE_CONFIGREQ:
|
||||
@ -189,7 +189,7 @@ FsmOutput(struct fsm *fp, u_int code, u_int id, u_char *ptr, int count)
|
||||
case CODE_CONFIGNAK:
|
||||
(*fp->fn->DecodeConfig)(fp, ptr, count, MODE_NOP, NULL);
|
||||
if (count < sizeof(struct fsmconfig))
|
||||
LogPrintf(fp->LogLevel, " [EMPTY]\n");
|
||||
log_Printf(fp->LogLevel, " [EMPTY]\n");
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -198,12 +198,12 @@ FsmOutput(struct fsm *fp, u_int code, u_int id, u_char *ptr, int count)
|
||||
lh.code = code;
|
||||
lh.id = id;
|
||||
lh.length = htons(plen);
|
||||
bp = mballoc(plen, MB_FSM);
|
||||
bp = mbuf_Alloc(plen, MB_FSM);
|
||||
memcpy(MBUF_CTOP(bp), &lh, sizeof(struct fsmheader));
|
||||
if (count)
|
||||
memcpy(MBUF_CTOP(bp) + sizeof(struct fsmheader), ptr, count);
|
||||
LogDumpBp(LogDEBUG, "FsmOutput", bp);
|
||||
HdlcOutput(fp->link, PRI_LINK, fp->proto, bp);
|
||||
log_DumpBp(LogDEBUG, "fsm_Output", bp);
|
||||
hdlc_Output(fp->link, PRI_LINK, fp->proto, bp);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -211,7 +211,7 @@ FsmOpenNow(void *v)
|
||||
{
|
||||
struct fsm *fp = (struct fsm *)v;
|
||||
|
||||
StopTimer(&fp->OpenTimer);
|
||||
timer_Stop(&fp->OpenTimer);
|
||||
if (fp->state <= ST_STOPPED) {
|
||||
FsmInitRestartCounter(fp);
|
||||
FsmSendConfigReq(fp);
|
||||
@ -220,7 +220,7 @@ FsmOpenNow(void *v)
|
||||
}
|
||||
|
||||
void
|
||||
FsmOpen(struct fsm * fp)
|
||||
fsm_Open(struct fsm * fp)
|
||||
{
|
||||
switch (fp->state) {
|
||||
case ST_INITIAL:
|
||||
@ -233,14 +233,14 @@ FsmOpen(struct fsm * fp)
|
||||
NewState(fp, ST_STOPPED);
|
||||
} else if (fp->open_mode > 0) {
|
||||
if (fp->open_mode > 1)
|
||||
LogPrintf(LogPHASE, "%s: Entering STOPPED state for %d seconds\n",
|
||||
log_Printf(LogPHASE, "%s: Entering STOPPED state for %d seconds\n",
|
||||
fp->link->name, fp->open_mode);
|
||||
NewState(fp, ST_STOPPED);
|
||||
StopTimer(&fp->OpenTimer);
|
||||
timer_Stop(&fp->OpenTimer);
|
||||
fp->OpenTimer.load = fp->open_mode * SECTICKS;
|
||||
fp->OpenTimer.func = FsmOpenNow;
|
||||
fp->OpenTimer.arg = (void *)fp;
|
||||
StartTimer(&fp->OpenTimer);
|
||||
timer_Start(&fp->OpenTimer);
|
||||
} else
|
||||
FsmOpenNow(fp);
|
||||
break;
|
||||
@ -258,11 +258,11 @@ FsmOpen(struct fsm * fp)
|
||||
}
|
||||
|
||||
void
|
||||
FsmUp(struct fsm * fp)
|
||||
fsm_Up(struct fsm * fp)
|
||||
{
|
||||
switch (fp->state) {
|
||||
case ST_INITIAL:
|
||||
LogPrintf(fp->LogLevel, "FSM: Using \"%s\" as a transport\n",
|
||||
log_Printf(fp->LogLevel, "FSM: Using \"%s\" as a transport\n",
|
||||
fp->link->name);
|
||||
NewState(fp, ST_CLOSED);
|
||||
break;
|
||||
@ -272,14 +272,14 @@ FsmUp(struct fsm * fp)
|
||||
NewState(fp, ST_REQSENT);
|
||||
break;
|
||||
default:
|
||||
LogPrintf(fp->LogLevel, "%s: Oops, Up at %s\n",
|
||||
log_Printf(fp->LogLevel, "%s: Oops, Up at %s\n",
|
||||
fp->link->name, State2Nam(fp->state));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
FsmDown(struct fsm *fp)
|
||||
fsm_Down(struct fsm *fp)
|
||||
{
|
||||
switch (fp->state) {
|
||||
case ST_CLOSED:
|
||||
@ -310,7 +310,7 @@ FsmDown(struct fsm *fp)
|
||||
}
|
||||
|
||||
void
|
||||
FsmClose(struct fsm *fp)
|
||||
fsm_Close(struct fsm *fp)
|
||||
{
|
||||
switch (fp->state) {
|
||||
case ST_STARTING:
|
||||
@ -349,19 +349,19 @@ FsmSendConfigReq(struct fsm * fp)
|
||||
{
|
||||
if (--fp->maxconfig > 0) {
|
||||
(*fp->fn->SendConfigReq)(fp);
|
||||
StartTimer(&fp->FsmTimer); /* Start restart timer */
|
||||
timer_Start(&fp->FsmTimer); /* Start restart timer */
|
||||
fp->restart--; /* Decrement restart counter */
|
||||
} else {
|
||||
FsmClose(fp);
|
||||
fsm_Close(fp);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
FsmSendTerminateReq(struct fsm *fp)
|
||||
{
|
||||
FsmOutput(fp, CODE_TERMREQ, fp->reqid, NULL, 0);
|
||||
fsm_Output(fp, CODE_TERMREQ, fp->reqid, NULL, 0);
|
||||
(*fp->fn->SentTerminateReq)(fp);
|
||||
StartTimer(&fp->FsmTimer); /* Start restart timer */
|
||||
timer_Start(&fp->FsmTimer); /* Start restart timer */
|
||||
fp->restart--; /* Decrement restart counter */
|
||||
}
|
||||
|
||||
@ -388,7 +388,7 @@ FsmTimeout(void *v)
|
||||
NewState(fp, ST_REQSENT);
|
||||
break;
|
||||
}
|
||||
StartTimer(&fp->FsmTimer);
|
||||
timer_Start(&fp->FsmTimer);
|
||||
} else {
|
||||
switch (fp->state) {
|
||||
case ST_CLOSING:
|
||||
@ -415,7 +415,7 @@ FsmTimeout(void *v)
|
||||
static void
|
||||
FsmInitRestartCounter(struct fsm * fp)
|
||||
{
|
||||
StopTimer(&fp->FsmTimer);
|
||||
timer_Stop(&fp->FsmTimer);
|
||||
fp->FsmTimer.func = FsmTimeout;
|
||||
fp->FsmTimer.arg = (void *) fp;
|
||||
(*fp->fn->InitRestartCounter)(fp);
|
||||
@ -432,12 +432,12 @@ FsmRecvConfigReq(struct fsm *fp, struct fsmheader *lhp, struct mbuf *bp)
|
||||
int plen, flen;
|
||||
int ackaction = 0;
|
||||
|
||||
plen = plength(bp);
|
||||
plen = mbuf_Length(bp);
|
||||
flen = ntohs(lhp->length) - sizeof *lhp;
|
||||
if (plen < flen) {
|
||||
LogPrintf(LogERROR, "%s: FsmRecvConfigReq: plen (%d) < flen (%d)\n",
|
||||
log_Printf(LogERROR, "%s: FsmRecvConfigReq: plen (%d) < flen (%d)\n",
|
||||
fp->link->name, plen, flen);
|
||||
pfree(bp);
|
||||
mbuf_Free(bp);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -447,19 +447,19 @@ FsmRecvConfigReq(struct fsm *fp, struct fsmheader *lhp, struct mbuf *bp)
|
||||
switch (fp->state) {
|
||||
case ST_INITIAL:
|
||||
case ST_STARTING:
|
||||
LogPrintf(fp->LogLevel, "%s: Oops, RCR in %s.\n",
|
||||
log_Printf(fp->LogLevel, "%s: Oops, RCR in %s.\n",
|
||||
fp->link->name, State2Nam(fp->state));
|
||||
pfree(bp);
|
||||
mbuf_Free(bp);
|
||||
return;
|
||||
case ST_CLOSED:
|
||||
(*fp->fn->SendTerminateAck)(fp, lhp->id);
|
||||
pfree(bp);
|
||||
mbuf_Free(bp);
|
||||
return;
|
||||
case ST_CLOSING:
|
||||
LogPrintf(fp->LogLevel, "%s: Error: Got ConfigReq while state = %s\n",
|
||||
log_Printf(fp->LogLevel, "%s: Error: Got ConfigReq while state = %s\n",
|
||||
fp->link->name, State2Nam(fp->state));
|
||||
case ST_STOPPING:
|
||||
pfree(bp);
|
||||
mbuf_Free(bp);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -468,7 +468,7 @@ FsmRecvConfigReq(struct fsm *fp, struct fsmheader *lhp, struct mbuf *bp)
|
||||
dec.rejend = dec.rej;
|
||||
(*fp->fn->DecodeConfig)(fp, MBUF_CTOP(bp), flen, MODE_REQ, &dec);
|
||||
if (flen < sizeof(struct fsmconfig))
|
||||
LogPrintf(fp->LogLevel, " [EMPTY]\n");
|
||||
log_Printf(fp->LogLevel, " [EMPTY]\n");
|
||||
|
||||
if (dec.nakend == dec.nak && dec.rejend == dec.rej)
|
||||
ackaction = 1;
|
||||
@ -486,11 +486,11 @@ FsmRecvConfigReq(struct fsm *fp, struct fsmheader *lhp, struct mbuf *bp)
|
||||
}
|
||||
|
||||
if (dec.rejend != dec.rej)
|
||||
FsmOutput(fp, CODE_CONFIGREJ, lhp->id, dec.rej, dec.rejend - dec.rej);
|
||||
fsm_Output(fp, CODE_CONFIGREJ, lhp->id, dec.rej, dec.rejend - dec.rej);
|
||||
if (dec.nakend != dec.nak)
|
||||
FsmOutput(fp, CODE_CONFIGNAK, lhp->id, dec.nak, dec.nakend - dec.nak);
|
||||
fsm_Output(fp, CODE_CONFIGNAK, lhp->id, dec.nak, dec.nakend - dec.nak);
|
||||
if (ackaction)
|
||||
FsmOutput(fp, CODE_CONFIGACK, lhp->id, dec.ack, dec.ackend - dec.ack);
|
||||
fsm_Output(fp, CODE_CONFIGACK, lhp->id, dec.ack, dec.ackend - dec.ack);
|
||||
|
||||
switch (fp->state) {
|
||||
case ST_OPENED:
|
||||
@ -522,7 +522,7 @@ FsmRecvConfigReq(struct fsm *fp, struct fsmheader *lhp, struct mbuf *bp)
|
||||
NewState(fp, ST_REQSENT);
|
||||
break;
|
||||
}
|
||||
pfree(bp);
|
||||
mbuf_Free(bp);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -564,7 +564,7 @@ FsmRecvConfigAck(struct fsm *fp, struct fsmheader *lhp, struct mbuf *bp)
|
||||
(*fp->parent->LayerDown)(fp->parent->object, fp);
|
||||
break;
|
||||
}
|
||||
pfree(bp);
|
||||
mbuf_Free(bp);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -574,10 +574,10 @@ FsmRecvConfigNak(struct fsm *fp, struct fsmheader *lhp, struct mbuf *bp)
|
||||
struct fsm_decode dec;
|
||||
int plen, flen;
|
||||
|
||||
plen = plength(bp);
|
||||
plen = mbuf_Length(bp);
|
||||
flen = ntohs(lhp->length) - sizeof *lhp;
|
||||
if (plen < flen) {
|
||||
pfree(bp);
|
||||
mbuf_Free(bp);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -587,18 +587,18 @@ FsmRecvConfigNak(struct fsm *fp, struct fsmheader *lhp, struct mbuf *bp)
|
||||
switch (fp->state) {
|
||||
case ST_INITIAL:
|
||||
case ST_STARTING:
|
||||
LogPrintf(fp->LogLevel, "%s: Oops, RCN in %s.\n",
|
||||
log_Printf(fp->LogLevel, "%s: Oops, RCN in %s.\n",
|
||||
fp->link->name, State2Nam(fp->state));
|
||||
pfree(bp);
|
||||
mbuf_Free(bp);
|
||||
return;
|
||||
case ST_CLOSED:
|
||||
case ST_STOPPED:
|
||||
(*fp->fn->SendTerminateAck)(fp, lhp->id);
|
||||
pfree(bp);
|
||||
mbuf_Free(bp);
|
||||
return;
|
||||
case ST_CLOSING:
|
||||
case ST_STOPPING:
|
||||
pfree(bp);
|
||||
mbuf_Free(bp);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -607,7 +607,7 @@ FsmRecvConfigNak(struct fsm *fp, struct fsmheader *lhp, struct mbuf *bp)
|
||||
dec.rejend = dec.rej;
|
||||
(*fp->fn->DecodeConfig)(fp, MBUF_CTOP(bp), flen, MODE_NAK, &dec);
|
||||
if (flen < sizeof(struct fsmconfig))
|
||||
LogPrintf(fp->LogLevel, " [EMPTY]\n");
|
||||
log_Printf(fp->LogLevel, " [EMPTY]\n");
|
||||
|
||||
switch (fp->state) {
|
||||
case ST_REQSENT:
|
||||
@ -627,7 +627,7 @@ FsmRecvConfigNak(struct fsm *fp, struct fsmheader *lhp, struct mbuf *bp)
|
||||
break;
|
||||
}
|
||||
|
||||
pfree(bp);
|
||||
mbuf_Free(bp);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -637,7 +637,7 @@ FsmRecvTermReq(struct fsm *fp, struct fsmheader *lhp, struct mbuf *bp)
|
||||
switch (fp->state) {
|
||||
case ST_INITIAL:
|
||||
case ST_STARTING:
|
||||
LogPrintf(fp->LogLevel, "%s: Oops, RTR in %s\n",
|
||||
log_Printf(fp->LogLevel, "%s: Oops, RTR in %s\n",
|
||||
fp->link->name, State2Nam(fp->state));
|
||||
break;
|
||||
case ST_CLOSED:
|
||||
@ -655,13 +655,13 @@ FsmRecvTermReq(struct fsm *fp, struct fsmheader *lhp, struct mbuf *bp)
|
||||
case ST_OPENED:
|
||||
(*fp->fn->LayerDown)(fp);
|
||||
(*fp->fn->SendTerminateAck)(fp, lhp->id);
|
||||
StartTimer(&fp->FsmTimer); /* Start restart timer */
|
||||
timer_Start(&fp->FsmTimer); /* Start restart timer */
|
||||
fp->restart = 0;
|
||||
NewState(fp, ST_STOPPING);
|
||||
(*fp->parent->LayerDown)(fp->parent->object, fp);
|
||||
break;
|
||||
}
|
||||
pfree(bp);
|
||||
mbuf_Free(bp);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -689,7 +689,7 @@ FsmRecvTermAck(struct fsm * fp, struct fsmheader * lhp, struct mbuf * bp)
|
||||
(*fp->parent->LayerDown)(fp->parent->object, fp);
|
||||
break;
|
||||
}
|
||||
pfree(bp);
|
||||
mbuf_Free(bp);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -699,10 +699,10 @@ FsmRecvConfigRej(struct fsm *fp, struct fsmheader *lhp, struct mbuf *bp)
|
||||
struct fsm_decode dec;
|
||||
int plen, flen;
|
||||
|
||||
plen = plength(bp);
|
||||
plen = mbuf_Length(bp);
|
||||
flen = ntohs(lhp->length) - sizeof *lhp;
|
||||
if (plen < flen) {
|
||||
pfree(bp);
|
||||
mbuf_Free(bp);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -712,18 +712,18 @@ FsmRecvConfigRej(struct fsm *fp, struct fsmheader *lhp, struct mbuf *bp)
|
||||
switch (fp->state) {
|
||||
case ST_INITIAL:
|
||||
case ST_STARTING:
|
||||
LogPrintf(fp->LogLevel, "%s: Oops, RCJ in %s.\n",
|
||||
log_Printf(fp->LogLevel, "%s: Oops, RCJ in %s.\n",
|
||||
fp->link->name, State2Nam(fp->state));
|
||||
pfree(bp);
|
||||
mbuf_Free(bp);
|
||||
return;
|
||||
case ST_CLOSED:
|
||||
case ST_STOPPED:
|
||||
(*fp->fn->SendTerminateAck)(fp, lhp->id);
|
||||
pfree(bp);
|
||||
mbuf_Free(bp);
|
||||
return;
|
||||
case ST_CLOSING:
|
||||
case ST_STOPPING:
|
||||
pfree(bp);
|
||||
mbuf_Free(bp);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -732,7 +732,7 @@ FsmRecvConfigRej(struct fsm *fp, struct fsmheader *lhp, struct mbuf *bp)
|
||||
dec.rejend = dec.rej;
|
||||
(*fp->fn->DecodeConfig)(fp, MBUF_CTOP(bp), flen, MODE_REJ, &dec);
|
||||
if (flen < sizeof(struct fsmconfig))
|
||||
LogPrintf(fp->LogLevel, " [EMPTY]\n");
|
||||
log_Printf(fp->LogLevel, " [EMPTY]\n");
|
||||
|
||||
switch (fp->state) {
|
||||
case ST_REQSENT:
|
||||
@ -751,13 +751,13 @@ FsmRecvConfigRej(struct fsm *fp, struct fsmheader *lhp, struct mbuf *bp)
|
||||
NewState(fp, ST_REQSENT);
|
||||
break;
|
||||
}
|
||||
pfree(bp);
|
||||
mbuf_Free(bp);
|
||||
}
|
||||
|
||||
static void
|
||||
FsmRecvCodeRej(struct fsm *fp, struct fsmheader *lhp, struct mbuf *bp)
|
||||
{
|
||||
pfree(bp);
|
||||
mbuf_Free(bp);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -768,15 +768,15 @@ FsmRecvProtoRej(struct fsm *fp, struct fsmheader *lhp, struct mbuf *bp)
|
||||
|
||||
sp = (u_short *) MBUF_CTOP(bp);
|
||||
proto = ntohs(*sp);
|
||||
LogPrintf(fp->LogLevel, "%s: -- Protocol 0x%04x (%s) was rejected!\n",
|
||||
log_Printf(fp->LogLevel, "%s: -- Protocol 0x%04x (%s) was rejected!\n",
|
||||
fp->link->name, proto, hdlc_Protocol2Nam(proto));
|
||||
|
||||
switch (proto) {
|
||||
case PROTO_LQR:
|
||||
if (p)
|
||||
StopLqr(p, LQM_LQR);
|
||||
lqr_Stop(p, LQM_LQR);
|
||||
else
|
||||
LogPrintf(LogERROR, "%s: FsmRecvProtoRej: Not a physical link !\n",
|
||||
log_Printf(LogERROR, "%s: FsmRecvProtoRej: Not a physical link !\n",
|
||||
fp->link->name);
|
||||
break;
|
||||
case PROTO_CCP:
|
||||
@ -799,14 +799,14 @@ FsmRecvProtoRej(struct fsm *fp, struct fsmheader *lhp, struct mbuf *bp)
|
||||
struct lcp *lcp = fsm2lcp(fp);
|
||||
|
||||
if (lcp->want_mrru && lcp->his_mrru) {
|
||||
LogPrintf(LogPHASE, "%s: MP protocol reject is fatal !\n",
|
||||
log_Printf(LogPHASE, "%s: MP protocol reject is fatal !\n",
|
||||
fp->link->name);
|
||||
FsmClose(fp);
|
||||
fsm_Close(fp);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
pfree(bp);
|
||||
mbuf_Free(bp);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -820,16 +820,16 @@ FsmRecvEchoReq(struct fsm *fp, struct fsmheader *lhp, struct mbuf *bp)
|
||||
cp = MBUF_CTOP(bp);
|
||||
magic = ntohl(*(u_int32_t *)cp);
|
||||
if (magic != lcp->his_magic) {
|
||||
LogPrintf(fp->LogLevel, "%s: RecvEchoReq: Error: His magic is bad!!\n",
|
||||
log_Printf(fp->LogLevel, "%s: RecvEchoReq: Error: His magic is bad!!\n",
|
||||
fp->link->name);
|
||||
/* XXX: We should send terminate request */
|
||||
}
|
||||
if (fp->state == ST_OPENED) {
|
||||
*(u_int32_t *)cp = htonl(lcp->want_magic); /* local magic */
|
||||
FsmOutput(fp, CODE_ECHOREP, lhp->id, cp, plength(bp));
|
||||
fsm_Output(fp, CODE_ECHOREP, lhp->id, cp, mbuf_Length(bp));
|
||||
}
|
||||
}
|
||||
pfree(bp);
|
||||
mbuf_Free(bp);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -842,7 +842,7 @@ FsmRecvEchoRep(struct fsm *fp, struct fsmheader *lhp, struct mbuf *bp)
|
||||
magic = ntohl(*(u_int32_t *)MBUF_CTOP(bp));
|
||||
/* Tolerate echo replies with either magic number */
|
||||
if (magic != 0 && magic != lcp->his_magic && magic != lcp->want_magic) {
|
||||
LogPrintf(LogWARN,
|
||||
log_Printf(LogWARN,
|
||||
"%s: RecvEchoRep: Bad magic: expected 0x%08x, got: 0x%08x\n",
|
||||
fp->link->name, lcp->his_magic, magic);
|
||||
/*
|
||||
@ -850,27 +850,27 @@ FsmRecvEchoRep(struct fsm *fp, struct fsmheader *lhp, struct mbuf *bp)
|
||||
* die as a result.
|
||||
*/
|
||||
}
|
||||
RecvEchoLqr(fp, bp);
|
||||
lqr_RecvEcho(fp, bp);
|
||||
}
|
||||
pfree(bp);
|
||||
mbuf_Free(bp);
|
||||
}
|
||||
|
||||
static void
|
||||
FsmRecvDiscReq(struct fsm * fp, struct fsmheader * lhp, struct mbuf * bp)
|
||||
{
|
||||
pfree(bp);
|
||||
mbuf_Free(bp);
|
||||
}
|
||||
|
||||
static void
|
||||
FsmRecvIdent(struct fsm * fp, struct fsmheader * lhp, struct mbuf * bp)
|
||||
{
|
||||
pfree(bp);
|
||||
mbuf_Free(bp);
|
||||
}
|
||||
|
||||
static void
|
||||
FsmRecvTimeRemain(struct fsm * fp, struct fsmheader * lhp, struct mbuf * bp)
|
||||
{
|
||||
pfree(bp);
|
||||
mbuf_Free(bp);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -883,27 +883,27 @@ FsmRecvResetReq(struct fsm *fp, struct fsmheader *lhp, struct mbuf *bp)
|
||||
* at the peer before our ResetAck.
|
||||
*/
|
||||
link_SequenceQueue(fp->link);
|
||||
FsmOutput(fp, CODE_RESETACK, lhp->id, NULL, 0);
|
||||
pfree(bp);
|
||||
fsm_Output(fp, CODE_RESETACK, lhp->id, NULL, 0);
|
||||
mbuf_Free(bp);
|
||||
}
|
||||
|
||||
static void
|
||||
FsmRecvResetAck(struct fsm *fp, struct fsmheader *lhp, struct mbuf *bp)
|
||||
{
|
||||
(*fp->fn->RecvResetAck)(fp, lhp->id);
|
||||
pfree(bp);
|
||||
mbuf_Free(bp);
|
||||
}
|
||||
|
||||
void
|
||||
FsmInput(struct fsm *fp, struct mbuf *bp)
|
||||
fsm_Input(struct fsm *fp, struct mbuf *bp)
|
||||
{
|
||||
int len;
|
||||
struct fsmheader *lhp;
|
||||
const struct fsmcodedesc *codep;
|
||||
|
||||
len = plength(bp);
|
||||
len = mbuf_Length(bp);
|
||||
if (len < sizeof(struct fsmheader)) {
|
||||
pfree(bp);
|
||||
mbuf_Free(bp);
|
||||
return;
|
||||
}
|
||||
lhp = (struct fsmheader *) MBUF_CTOP(bp);
|
||||
@ -914,8 +914,8 @@ FsmInput(struct fsm *fp, struct mbuf *bp)
|
||||
* MUST send a unique id for each REQ....
|
||||
*/
|
||||
static u_char id;
|
||||
FsmOutput(fp, CODE_CODEREJ, id++, MBUF_CTOP(bp), bp->cnt);
|
||||
pfree(bp);
|
||||
fsm_Output(fp, CODE_CODEREJ, id++, MBUF_CTOP(bp), bp->cnt);
|
||||
mbuf_Free(bp);
|
||||
return;
|
||||
}
|
||||
bp->offset += sizeof(struct fsmheader);
|
||||
@ -924,16 +924,16 @@ FsmInput(struct fsm *fp, struct mbuf *bp)
|
||||
codep = FsmCodes + lhp->code - 1;
|
||||
if (lhp->id != fp->reqid && codep->check_reqid &&
|
||||
Enabled(fp->bundle, OPT_IDCHECK)) {
|
||||
LogPrintf(fp->LogLevel, "%s: Recv%s(%d), dropped (expected %d)\n",
|
||||
log_Printf(fp->LogLevel, "%s: Recv%s(%d), dropped (expected %d)\n",
|
||||
fp->link->name, codep->name, lhp->id, fp->reqid);
|
||||
return;
|
||||
}
|
||||
|
||||
LogPrintf(fp->LogLevel, "%s: Recv%s(%d) state = %s\n",
|
||||
log_Printf(fp->LogLevel, "%s: Recv%s(%d) state = %s\n",
|
||||
fp->link->name, codep->name, lhp->id, State2Nam(fp->state));
|
||||
|
||||
if (LogIsKept(LogDEBUG))
|
||||
LogMemory();
|
||||
if (log_IsKept(LogDEBUG))
|
||||
mbuf_Log();
|
||||
|
||||
if (codep->inc_reqid && (lhp->id == fp->reqid ||
|
||||
(!Enabled(fp->bundle, OPT_IDCHECK) && codep->check_reqid)))
|
||||
@ -941,20 +941,20 @@ FsmInput(struct fsm *fp, struct mbuf *bp)
|
||||
|
||||
(*codep->recv)(fp, lhp, bp);
|
||||
|
||||
if (LogIsKept(LogDEBUG))
|
||||
LogMemory();
|
||||
if (log_IsKept(LogDEBUG))
|
||||
mbuf_Log();
|
||||
}
|
||||
|
||||
void
|
||||
NullRecvResetReq(struct fsm *fp)
|
||||
fsm_NullRecvResetReq(struct fsm *fp)
|
||||
{
|
||||
LogPrintf(fp->LogLevel, "%s: Oops - received unexpected reset req\n",
|
||||
log_Printf(fp->LogLevel, "%s: Oops - received unexpected reset req\n",
|
||||
fp->link->name);
|
||||
}
|
||||
|
||||
void
|
||||
NullRecvResetAck(struct fsm *fp, u_char id)
|
||||
fsm_NullRecvResetAck(struct fsm *fp, u_char id)
|
||||
{
|
||||
LogPrintf(fp->LogLevel, "%s: Oops - received unexpected reset ack\n",
|
||||
log_Printf(fp->LogLevel, "%s: Oops - received unexpected reset ack\n",
|
||||
fp->link->name);
|
||||
}
|
||||
|
@ -15,7 +15,7 @@
|
||||
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* $Id: fsm.h,v 1.16.2.14 1998/04/07 00:53:42 brian Exp $
|
||||
* $Id: fsm.h,v 1.16.2.15 1998/04/30 23:53:39 brian Exp $
|
||||
*
|
||||
* TODO:
|
||||
*/
|
||||
@ -146,12 +146,12 @@ struct fsmconfig {
|
||||
extern void fsm_Init(struct fsm *, const char *, u_short, int, int, int, int,
|
||||
struct bundle *, struct link *, const struct fsm_parent *,
|
||||
struct fsm_callbacks *, const char *[3]);
|
||||
extern void FsmOutput(struct fsm *, u_int, u_int, u_char *, int);
|
||||
extern void FsmOpen(struct fsm *);
|
||||
extern void FsmUp(struct fsm *);
|
||||
extern void FsmDown(struct fsm *);
|
||||
extern void FsmInput(struct fsm *, struct mbuf *);
|
||||
extern void FsmClose(struct fsm *);
|
||||
extern void NullRecvResetReq(struct fsm *fp);
|
||||
extern void NullRecvResetAck(struct fsm *fp, u_char);
|
||||
extern void fsm_Output(struct fsm *, u_int, u_int, u_char *, int);
|
||||
extern void fsm_Open(struct fsm *);
|
||||
extern void fsm_Up(struct fsm *);
|
||||
extern void fsm_Down(struct fsm *);
|
||||
extern void fsm_Input(struct fsm *, struct mbuf *);
|
||||
extern void fsm_Close(struct fsm *);
|
||||
extern void fsm_NullRecvResetReq(struct fsm *fp);
|
||||
extern void fsm_NullRecvResetAck(struct fsm *fp, u_char);
|
||||
extern const char *State2Nam(u_int);
|
||||
|
@ -17,7 +17,7 @@
|
||||
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* $Id: hdlc.c,v 1.28.2.29 1998/04/24 19:16:03 brian Exp $
|
||||
* $Id: hdlc.c,v 1.28.2.30 1998/04/28 01:25:18 brian Exp $
|
||||
*
|
||||
* TODO:
|
||||
*/
|
||||
@ -109,7 +109,7 @@ hdlc_Init(struct hdlc *hdlc, struct lcp *lcp)
|
||||
* 2.27 for further details.
|
||||
*/
|
||||
inline u_short
|
||||
HdlcFcs(u_short fcs, u_char * cp, int len)
|
||||
hdlc_Fcs(u_short fcs, u_char * cp, int len)
|
||||
{
|
||||
while (len--)
|
||||
fcs = (fcs >> 8) ^ fcstab[(fcs ^ *cp++) & 0xff];
|
||||
@ -122,7 +122,7 @@ HdlcFcsBuf(u_short fcs, struct mbuf *m)
|
||||
int len;
|
||||
u_char *pos, *end;
|
||||
|
||||
len = plength(m);
|
||||
len = mbuf_Length(m);
|
||||
pos = MBUF_CTOP(m);
|
||||
end = pos + m->cnt;
|
||||
while (len--) {
|
||||
@ -137,19 +137,19 @@ HdlcFcsBuf(u_short fcs, struct mbuf *m)
|
||||
}
|
||||
|
||||
void
|
||||
HdlcOutput(struct link *l, int pri, u_short proto, struct mbuf *bp)
|
||||
hdlc_Output(struct link *l, int pri, u_short proto, struct mbuf *bp)
|
||||
{
|
||||
struct physical *p = link2physical(l);
|
||||
struct mbuf *mhp, *mfcs;
|
||||
u_char *cp;
|
||||
u_short fcs;
|
||||
|
||||
if (!p || Physical_IsSync(p))
|
||||
if (!p || physical_IsSync(p))
|
||||
mfcs = NULL;
|
||||
else
|
||||
mfcs = mballoc(2, MB_HDLCOUT);
|
||||
mfcs = mbuf_Alloc(2, MB_HDLCOUT);
|
||||
|
||||
mhp = mballoc(4, MB_HDLCOUT);
|
||||
mhp = mbuf_Alloc(4, MB_HDLCOUT);
|
||||
mhp->cnt = 0;
|
||||
cp = MBUF_CTOP(mhp);
|
||||
if (p && (proto == PROTO_LCP || l->lcp.his_acfcomp == 0)) {
|
||||
@ -190,7 +190,7 @@ HdlcOutput(struct link *l, int pri, u_short proto, struct mbuf *bp)
|
||||
bp->next = mfcs;
|
||||
bp = mhp->next;
|
||||
|
||||
p->hdlc.lqm.OutOctets += plength(mhp) + 1;
|
||||
p->hdlc.lqm.OutOctets += mbuf_Length(mhp) + 1;
|
||||
p->hdlc.lqm.OutPackets++;
|
||||
|
||||
if (proto == PROTO_LQR) {
|
||||
@ -214,12 +214,12 @@ HdlcOutput(struct link *l, int pri, u_short proto, struct mbuf *bp)
|
||||
* from the last one
|
||||
*/
|
||||
lqr.PeerOutLQRs = ++p->hdlc.lqm.lqr.OutLQRs;
|
||||
LqrDump(l->name, "Output", &lqr);
|
||||
lqr_Dump(l->name, "Output", &lqr);
|
||||
} else {
|
||||
lqr.PeerOutLQRs = p->hdlc.lqm.lqr.OutLQRs;
|
||||
LqrDump(l->name, "Output (again)", &lqr);
|
||||
lqr_Dump(l->name, "Output (again)", &lqr);
|
||||
}
|
||||
LqrChangeOrder(&lqr, (struct lqrdata *)MBUF_CTOP(bp));
|
||||
lqr_ChangeOrder(&lqr, (struct lqrdata *)MBUF_CTOP(bp));
|
||||
}
|
||||
|
||||
if (mfcs) {
|
||||
@ -232,12 +232,12 @@ HdlcOutput(struct link *l, int pri, u_short proto, struct mbuf *bp)
|
||||
mfcs->cnt = 2;
|
||||
}
|
||||
|
||||
LogDumpBp(LogHDLC, "HdlcOutput", mhp);
|
||||
log_DumpBp(LogHDLC, "hdlc_Output", mhp);
|
||||
|
||||
link_ProtocolRecord(l, proto, PROTO_OUT);
|
||||
LogPrintf(LogDEBUG, "HdlcOutput: proto = 0x%04x\n", proto);
|
||||
log_Printf(LogDEBUG, "hdlc_Output: proto = 0x%04x\n", proto);
|
||||
|
||||
if (Physical_IsSync(p))
|
||||
if (physical_IsSync(p))
|
||||
link_Output(l, pri, mhp); /* Send it raw */
|
||||
else
|
||||
async_Output(pri, mhp, proto, p);
|
||||
@ -376,7 +376,7 @@ hdlc_DecodePacket(struct bundle *bundle, u_short proto, struct mbuf * bp,
|
||||
struct physical *p = link2physical(l);
|
||||
u_char *cp;
|
||||
|
||||
LogPrintf(LogDEBUG, "DecodePacket: proto = 0x%04x\n", proto);
|
||||
log_Printf(LogDEBUG, "DecodePacket: proto = 0x%04x\n", proto);
|
||||
|
||||
/* decompress everything. CCP needs uncompressed data too */
|
||||
if ((bp = ccp_Decompress(&l->ccp, &proto, bp)) == NULL)
|
||||
@ -384,61 +384,61 @@ hdlc_DecodePacket(struct bundle *bundle, u_short proto, struct mbuf * bp,
|
||||
|
||||
switch (proto) {
|
||||
case PROTO_LCP:
|
||||
LcpInput(&l->lcp, bp);
|
||||
lcp_Input(&l->lcp, bp);
|
||||
break;
|
||||
case PROTO_PAP:
|
||||
if (p)
|
||||
PapInput(bundle, bp, p);
|
||||
pap_Input(bundle, bp, p);
|
||||
else {
|
||||
LogPrintf(LogERROR, "DecodePacket: PAP: Not a physical link !\n");
|
||||
pfree(bp);
|
||||
log_Printf(LogERROR, "DecodePacket: PAP: Not a physical link !\n");
|
||||
mbuf_Free(bp);
|
||||
}
|
||||
break;
|
||||
case PROTO_LQR:
|
||||
if (p) {
|
||||
p->hdlc.lqm.lqr.SaveInLQRs++;
|
||||
LqrInput(p, bp);
|
||||
lqr_Input(p, bp);
|
||||
} else {
|
||||
LogPrintf(LogERROR, "DecodePacket: LQR: Not a physical link !\n");
|
||||
pfree(bp);
|
||||
log_Printf(LogERROR, "DecodePacket: LQR: Not a physical link !\n");
|
||||
mbuf_Free(bp);
|
||||
}
|
||||
break;
|
||||
case PROTO_CHAP:
|
||||
if (p)
|
||||
ChapInput(bundle, bp, p);
|
||||
chap_Input(bundle, bp, p);
|
||||
else {
|
||||
LogPrintf(LogERROR, "DecodePacket: CHAP: Not a physical link !\n");
|
||||
pfree(bp);
|
||||
log_Printf(LogERROR, "DecodePacket: CHAP: Not a physical link !\n");
|
||||
mbuf_Free(bp);
|
||||
}
|
||||
break;
|
||||
case PROTO_VJUNCOMP:
|
||||
case PROTO_VJCOMP:
|
||||
bp = VjCompInput(&bundle->ncp.ipcp, bp, proto);
|
||||
bp = vj_Input(&bundle->ncp.ipcp, bp, proto);
|
||||
if (bp == NULL)
|
||||
break;
|
||||
/* fall down */
|
||||
case PROTO_IP:
|
||||
IpInput(bundle, bp);
|
||||
ip_Input(bundle, bp);
|
||||
break;
|
||||
case PROTO_IPCP:
|
||||
IpcpInput(&bundle->ncp.ipcp, bp);
|
||||
ipcp_Input(&bundle->ncp.ipcp, bp);
|
||||
break;
|
||||
case PROTO_CCP:
|
||||
CcpInput(&l->ccp, bundle, bp);
|
||||
ccp_Input(&l->ccp, bundle, bp);
|
||||
break;
|
||||
case PROTO_MP:
|
||||
if (bundle->ncp.mp.active) {
|
||||
if (p)
|
||||
mp_Input(&bundle->ncp.mp, bp, p);
|
||||
else {
|
||||
LogPrintf(LogERROR, "DecodePacket: MP inside MP ?!\n");
|
||||
pfree(bp);
|
||||
log_Printf(LogERROR, "DecodePacket: MP inside MP ?!\n");
|
||||
mbuf_Free(bp);
|
||||
}
|
||||
break;
|
||||
}
|
||||
/* Fall through */
|
||||
default:
|
||||
LogPrintf(LogPHASE, "%s protocol 0x%04x (%s)\n",
|
||||
log_Printf(LogPHASE, "%s protocol 0x%04x (%s)\n",
|
||||
proto == PROTO_MP ? "Unexpected" : "Unknown",
|
||||
proto, hdlc_Protocol2Nam(proto));
|
||||
bp->offset -= 2;
|
||||
@ -449,38 +449,38 @@ hdlc_DecodePacket(struct bundle *bundle, u_short proto, struct mbuf * bp,
|
||||
p->hdlc.lqm.SaveInDiscards++;
|
||||
p->hdlc.stats.unknownproto++;
|
||||
}
|
||||
pfree(bp);
|
||||
mbuf_Free(bp);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
HdlcInput(struct bundle *bundle, struct mbuf * bp, struct physical *physical)
|
||||
hdlc_Input(struct bundle *bundle, struct mbuf * bp, struct physical *physical)
|
||||
{
|
||||
u_short fcs, proto;
|
||||
u_char *cp, addr, ctrl;
|
||||
|
||||
LogDumpBp(LogHDLC, "HdlcInput:", bp);
|
||||
if (Physical_IsSync(physical))
|
||||
log_DumpBp(LogHDLC, "hdlc_Input:", bp);
|
||||
if (physical_IsSync(physical))
|
||||
fcs = GOODFCS;
|
||||
else
|
||||
fcs = HdlcFcs(INITFCS, MBUF_CTOP(bp), bp->cnt);
|
||||
fcs = hdlc_Fcs(INITFCS, MBUF_CTOP(bp), bp->cnt);
|
||||
physical->hdlc.lqm.SaveInOctets += bp->cnt + 1;
|
||||
|
||||
LogPrintf(LogDEBUG, "HdlcInput: fcs = %04x (%s)\n",
|
||||
log_Printf(LogDEBUG, "hdlc_Input: fcs = %04x (%s)\n",
|
||||
fcs, (fcs == GOODFCS) ? "good" : "bad");
|
||||
if (fcs != GOODFCS) {
|
||||
physical->hdlc.lqm.SaveInErrors++;
|
||||
LogPrintf(LogDEBUG, "HdlcInput: Bad FCS\n");
|
||||
log_Printf(LogDEBUG, "hdlc_Input: Bad FCS\n");
|
||||
physical->hdlc.stats.badfcs++;
|
||||
pfree(bp);
|
||||
mbuf_Free(bp);
|
||||
return;
|
||||
}
|
||||
if (!Physical_IsSync(physical))
|
||||
if (!physical_IsSync(physical))
|
||||
bp->cnt -= 2; /* discard FCS part */
|
||||
|
||||
if (bp->cnt < 2) { /* XXX: raise this bar ? */
|
||||
pfree(bp);
|
||||
mbuf_Free(bp);
|
||||
return;
|
||||
}
|
||||
cp = MBUF_CTOP(bp);
|
||||
@ -493,16 +493,16 @@ HdlcInput(struct bundle *bundle, struct mbuf * bp, struct physical *physical)
|
||||
if (addr != HDLC_ADDR) {
|
||||
physical->hdlc.lqm.SaveInErrors++;
|
||||
physical->hdlc.stats.badaddr++;
|
||||
LogPrintf(LogDEBUG, "HdlcInput: addr %02x\n", *cp);
|
||||
pfree(bp);
|
||||
log_Printf(LogDEBUG, "hdlc_Input: addr %02x\n", *cp);
|
||||
mbuf_Free(bp);
|
||||
return;
|
||||
}
|
||||
ctrl = *cp++;
|
||||
if (ctrl != HDLC_UI) {
|
||||
physical->hdlc.lqm.SaveInErrors++;
|
||||
physical->hdlc.stats.badcommand++;
|
||||
LogPrintf(LogDEBUG, "HdlcInput: %02x\n", *cp);
|
||||
pfree(bp);
|
||||
log_Printf(LogDEBUG, "hdlc_Input: %02x\n", *cp);
|
||||
mbuf_Free(bp);
|
||||
return;
|
||||
}
|
||||
bp->offset += 2;
|
||||
@ -534,10 +534,10 @@ HdlcInput(struct bundle *bundle, struct mbuf * bp, struct physical *physical)
|
||||
bp->cnt -= 2;
|
||||
}
|
||||
|
||||
link_ProtocolRecord(physical2link(physical), proto, PROTO_IN);
|
||||
link_ProtocolRecord(&physical->link, proto, PROTO_IN);
|
||||
physical->hdlc.lqm.SaveInPackets++;
|
||||
|
||||
hdlc_DecodePacket(bundle, proto, bp, physical2link(physical));
|
||||
hdlc_DecodePacket(bundle, proto, bp, &physical->link);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -554,7 +554,7 @@ static const char *FrameHeaders[] = {
|
||||
};
|
||||
|
||||
u_char *
|
||||
HdlcDetect(struct physical *physical, u_char *cp, int n)
|
||||
hdlc_Detect(struct physical *physical, u_char *cp, int n)
|
||||
{
|
||||
const char *fp, **hp;
|
||||
char *ptr;
|
||||
@ -563,7 +563,7 @@ HdlcDetect(struct physical *physical, u_char *cp, int n)
|
||||
ptr = NULL;
|
||||
for (hp = FrameHeaders; *hp; hp++) {
|
||||
fp = *hp;
|
||||
if (Physical_IsSync(physical))
|
||||
if (physical_IsSync(physical))
|
||||
fp++;
|
||||
ptr = strstr((char *) cp, fp);
|
||||
if (ptr)
|
||||
@ -595,10 +595,10 @@ hdlc_ReportTime(void *v)
|
||||
/* Moan about HDLC errors */
|
||||
struct hdlc *hdlc = (struct hdlc *)v;
|
||||
|
||||
StopTimer(&hdlc->ReportTimer);
|
||||
timer_Stop(&hdlc->ReportTimer);
|
||||
|
||||
if (memcmp(&hdlc->laststats, &hdlc->stats, sizeof hdlc->stats)) {
|
||||
LogPrintf(LogPHASE,
|
||||
log_Printf(LogPHASE,
|
||||
"HDLC errors -> FCS: %u, ADDR: %u, COMD: %u, PROTO: %u\n",
|
||||
hdlc->stats.badfcs - hdlc->laststats.badfcs,
|
||||
hdlc->stats.badaddr - hdlc->laststats.badaddr,
|
||||
@ -607,22 +607,22 @@ hdlc_ReportTime(void *v)
|
||||
hdlc->laststats = hdlc->stats;
|
||||
}
|
||||
|
||||
StartTimer(&hdlc->ReportTimer);
|
||||
timer_Start(&hdlc->ReportTimer);
|
||||
}
|
||||
|
||||
void
|
||||
hdlc_StartTimer(struct hdlc *hdlc)
|
||||
{
|
||||
StopTimer(&hdlc->ReportTimer);
|
||||
timer_Stop(&hdlc->ReportTimer);
|
||||
hdlc->ReportTimer.load = 60 * SECTICKS;
|
||||
hdlc->ReportTimer.arg = hdlc;
|
||||
hdlc->ReportTimer.func = hdlc_ReportTime;
|
||||
hdlc->ReportTimer.name = "hdlc";
|
||||
StartTimer(&hdlc->ReportTimer);
|
||||
timer_Start(&hdlc->ReportTimer);
|
||||
}
|
||||
|
||||
void
|
||||
hdlc_StopTimer(struct hdlc *hdlc)
|
||||
{
|
||||
StopTimer(&hdlc->ReportTimer);
|
||||
timer_Stop(&hdlc->ReportTimer);
|
||||
}
|
||||
|
@ -15,7 +15,7 @@
|
||||
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* $Id: hdlc.h,v 1.14.2.10 1998/04/07 00:53:44 brian Exp $
|
||||
* $Id: hdlc.h,v 1.14.2.11 1998/04/24 19:16:04 brian Exp $
|
||||
*
|
||||
* TODO:
|
||||
*/
|
||||
@ -109,7 +109,7 @@ extern const char *hdlc_Protocol2Nam(u_short);
|
||||
extern void hdlc_DecodePacket(struct bundle *, u_short, struct mbuf *,
|
||||
struct link *);
|
||||
|
||||
extern void HdlcInput(struct bundle *, struct mbuf *, struct physical *);
|
||||
extern void HdlcOutput(struct link *, int, u_short, struct mbuf *bp);
|
||||
extern u_short HdlcFcs(u_short, u_char *, int);
|
||||
extern u_char *HdlcDetect(struct physical *, u_char *, int);
|
||||
extern void hdlc_Input(struct bundle *, struct mbuf *, struct physical *);
|
||||
extern void hdlc_Output(struct link *, int, u_short, struct mbuf *bp);
|
||||
extern u_short hdlc_Fcs(u_short, u_char *, int);
|
||||
extern u_char *hdlc_Detect(struct physical *, u_char *, int);
|
||||
|
@ -23,7 +23,7 @@
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $Id: id.c,v 1.6.4.8 1998/04/28 01:25:19 brian Exp $
|
||||
* $Id: id.c,v 1.6.4.9 1998/04/30 23:53:39 brian Exp $
|
||||
*/
|
||||
|
||||
#include <sys/types.h>
|
||||
@ -62,7 +62,7 @@ static void
|
||||
ID0setuser(void)
|
||||
{
|
||||
if (seteuid(uid) == -1) {
|
||||
LogPrintf(LogERROR, "ID0setuser: Unable to seteuid!\n");
|
||||
log_Printf(LogERROR, "ID0setuser: Unable to seteuid!\n");
|
||||
AbortProgram(EX_NOPERM);
|
||||
}
|
||||
}
|
||||
@ -77,7 +77,7 @@ static void
|
||||
ID0set0(void)
|
||||
{
|
||||
if (seteuid(euid) == -1) {
|
||||
LogPrintf(LogERROR, "ID0set0: Unable to seteuid!\n");
|
||||
log_Printf(LogERROR, "ID0set0: Unable to seteuid!\n");
|
||||
AbortProgram(EX_NOPERM);
|
||||
}
|
||||
}
|
||||
@ -89,7 +89,7 @@ ID0ioctl(int fd, unsigned long req, void *arg)
|
||||
|
||||
ID0set0();
|
||||
ret = ioctl(fd, req, arg);
|
||||
LogPrintf(LogID0, "%d = ioctl(%d, %lu, %p)\n", ret, fd, req, arg);
|
||||
log_Printf(LogID0, "%d = ioctl(%d, %lu, %p)\n", ret, fd, req, arg);
|
||||
ID0setuser();
|
||||
return ret;
|
||||
}
|
||||
@ -101,7 +101,7 @@ ID0unlink(const char *name)
|
||||
|
||||
ID0set0();
|
||||
ret = unlink(name);
|
||||
LogPrintf(LogID0, "%d = unlink(\"%s\")\n", ret, name);
|
||||
log_Printf(LogID0, "%d = unlink(\"%s\")\n", ret, name);
|
||||
ID0setuser();
|
||||
return ret;
|
||||
}
|
||||
@ -113,7 +113,7 @@ ID0socket(int domain, int type, int protocol)
|
||||
|
||||
ID0set0();
|
||||
ret = socket(domain, type, protocol);
|
||||
LogPrintf(LogID0, "%d = socket(%d, %d, %d)\n", ret, domain, type, protocol);
|
||||
log_Printf(LogID0, "%d = socket(%d, %d, %d)\n", ret, domain, type, protocol);
|
||||
ID0setuser();
|
||||
return ret;
|
||||
}
|
||||
@ -125,7 +125,7 @@ ID0fopen(const char *path, const char *mode)
|
||||
|
||||
ID0set0();
|
||||
ret = fopen(path, mode);
|
||||
LogPrintf(LogID0, "%p = fopen(\"%s\", \"%s\")\n", ret, path, mode);
|
||||
log_Printf(LogID0, "%p = fopen(\"%s\", \"%s\")\n", ret, path, mode);
|
||||
ID0setuser();
|
||||
return ret;
|
||||
}
|
||||
@ -139,7 +139,7 @@ ID0open(const char *path, int flags, ...)
|
||||
va_start(ap, flags);
|
||||
ID0set0();
|
||||
ret = open(path, flags, va_arg(ap, int));
|
||||
LogPrintf(LogID0, "%d = open(\"%s\", %d)\n", ret, path, flags);
|
||||
log_Printf(LogID0, "%d = open(\"%s\", %d)\n", ret, path, flags);
|
||||
ID0setuser();
|
||||
va_end(ap);
|
||||
return ret;
|
||||
@ -152,7 +152,7 @@ ID0write(int fd, const void *data, size_t len)
|
||||
|
||||
ID0set0();
|
||||
ret = write(fd, data, len);
|
||||
LogPrintf(LogID0, "%d = write(%d, data, %d)\n", ret, fd, len);
|
||||
log_Printf(LogID0, "%d = write(%d, data, %d)\n", ret, fd, len);
|
||||
ID0setuser();
|
||||
return ret;
|
||||
}
|
||||
@ -164,7 +164,7 @@ ID0uu_lock(const char *basettyname)
|
||||
|
||||
ID0set0();
|
||||
ret = uu_lock(basettyname);
|
||||
LogPrintf(LogID0, "%d = uu_lock(\"%s\")\n", ret, basettyname);
|
||||
log_Printf(LogID0, "%d = uu_lock(\"%s\")\n", ret, basettyname);
|
||||
ID0setuser();
|
||||
return ret;
|
||||
}
|
||||
@ -176,7 +176,7 @@ ID0uu_unlock(const char *basettyname)
|
||||
|
||||
ID0set0();
|
||||
ret = uu_unlock(basettyname);
|
||||
LogPrintf(LogID0, "%d = uu_unlock(\"%s\")\n", ret, basettyname);
|
||||
log_Printf(LogID0, "%d = uu_unlock(\"%s\")\n", ret, basettyname);
|
||||
ID0setuser();
|
||||
return ret;
|
||||
}
|
||||
@ -186,12 +186,12 @@ ID0login(struct utmp *ut)
|
||||
{
|
||||
ID0set0();
|
||||
if (logout(ut->ut_line)) {
|
||||
LogPrintf(LogID0, "logout(\"%s\")\n", ut->ut_line);
|
||||
log_Printf(LogID0, "logout(\"%s\")\n", ut->ut_line);
|
||||
logwtmp(ut->ut_line, "", "");
|
||||
LogPrintf(LogID0, "logwtmp(\"%s\", \"\", \"\")\n", ut->ut_line);
|
||||
log_Printf(LogID0, "logwtmp(\"%s\", \"\", \"\")\n", ut->ut_line);
|
||||
}
|
||||
login(ut);
|
||||
LogPrintf(LogID0, "login(\"%s\", \"%.*s\")\n",
|
||||
log_Printf(LogID0, "login(\"%s\", \"%.*s\")\n",
|
||||
ut->ut_line, (int)(sizeof ut->ut_name), ut->ut_name);
|
||||
ID0setuser();
|
||||
}
|
||||
@ -206,11 +206,11 @@ ID0logout(const char *device)
|
||||
|
||||
ID0set0();
|
||||
if (logout(ut.ut_line)) {
|
||||
LogPrintf(LogID0, "logout(\"%s\")\n", ut.ut_line);
|
||||
log_Printf(LogID0, "logout(\"%s\")\n", ut.ut_line);
|
||||
logwtmp(ut.ut_line, "", "");
|
||||
LogPrintf(LogID0, "logwtmp(\"%s\", \"\", \"\")\n", ut.ut_line);
|
||||
log_Printf(LogID0, "logwtmp(\"%s\", \"\", \"\")\n", ut.ut_line);
|
||||
} else
|
||||
LogPrintf(LogERROR, "ID0logout: No longer logged in on %s\n", ut.ut_line);
|
||||
log_Printf(LogERROR, "ID0logout: No longer logged in on %s\n", ut.ut_line);
|
||||
ID0setuser();
|
||||
}
|
||||
|
||||
@ -221,7 +221,7 @@ ID0bind_un(int s, const struct sockaddr_un *name)
|
||||
|
||||
ID0set0();
|
||||
result = bind(s, (const struct sockaddr *)name, sizeof *name);
|
||||
LogPrintf(LogID0, "%d = bind(%d, \"%s\", %d)\n",
|
||||
log_Printf(LogID0, "%d = bind(%d, \"%s\", %d)\n",
|
||||
result, s, name->sun_path, sizeof *name);
|
||||
ID0setuser();
|
||||
return result;
|
||||
@ -234,7 +234,7 @@ ID0connect_un(int s, const struct sockaddr_un *name)
|
||||
|
||||
ID0set0();
|
||||
result = connect(s, (const struct sockaddr *)name, sizeof *name);
|
||||
LogPrintf(LogID0, "%d = connect(%d, \"%s\", %d)\n",
|
||||
log_Printf(LogID0, "%d = connect(%d, \"%s\", %d)\n",
|
||||
result, s, name->sun_path, sizeof *name);
|
||||
ID0setuser();
|
||||
return result;
|
||||
|
@ -17,7 +17,7 @@
|
||||
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* $Id: ip.c,v 1.38.2.23 1998/04/25 10:49:04 brian Exp $
|
||||
* $Id: ip.c,v 1.38.2.24 1998/04/28 01:25:25 brian Exp $
|
||||
*
|
||||
* TODO:
|
||||
* o Return ICMP message for filterd packet
|
||||
@ -116,7 +116,7 @@ FilterCheck(struct ip *pip, struct filter *filter)
|
||||
return (A_PERMIT);
|
||||
|
||||
if (!didname)
|
||||
LogPrintf(LogDEBUG, "%s filter:\n", filter->name);
|
||||
log_Printf(LogDEBUG, "%s filter:\n", filter->name);
|
||||
didname = 1;
|
||||
|
||||
if ((pip->ip_src.s_addr & fp->smask.s_addr) ==
|
||||
@ -133,7 +133,7 @@ FilterCheck(struct ip *pip, struct filter *filter)
|
||||
ih = (struct icmp *) ptop;
|
||||
sport = ih->icmp_type;
|
||||
estab = syn = finrst = -1;
|
||||
if (LogIsKept(LogDEBUG))
|
||||
if (log_IsKept(LogDEBUG))
|
||||
snprintf(dbuff, sizeof dbuff, "sport = %d", sport);
|
||||
break;
|
||||
case IPPROTO_UDP:
|
||||
@ -142,7 +142,7 @@ FilterCheck(struct ip *pip, struct filter *filter)
|
||||
sport = ntohs(uh->uh_sport);
|
||||
dport = ntohs(uh->uh_dport);
|
||||
estab = syn = finrst = -1;
|
||||
if (LogIsKept(LogDEBUG))
|
||||
if (log_IsKept(LogDEBUG))
|
||||
snprintf(dbuff, sizeof dbuff, "sport = %d, dport = %d",
|
||||
sport, dport);
|
||||
break;
|
||||
@ -154,7 +154,7 @@ FilterCheck(struct ip *pip, struct filter *filter)
|
||||
estab = (th->th_flags & TH_ACK);
|
||||
syn = (th->th_flags & TH_SYN);
|
||||
finrst = (th->th_flags & (TH_FIN|TH_RST));
|
||||
if (LogIsKept(LogDEBUG) && !estab)
|
||||
if (log_IsKept(LogDEBUG) && !estab)
|
||||
snprintf(dbuff, sizeof dbuff,
|
||||
"flags = %02x, sport = %d, dport = %d",
|
||||
th->th_flags, sport, dport);
|
||||
@ -162,19 +162,19 @@ FilterCheck(struct ip *pip, struct filter *filter)
|
||||
default:
|
||||
return (A_DENY); /* We'll block unknown type of packet */
|
||||
}
|
||||
if (LogIsKept(LogDEBUG)) {
|
||||
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);
|
||||
}
|
||||
LogPrintf(LogDEBUG, " Filter: proto = %s, %s\n",
|
||||
log_Printf(LogDEBUG, " Filter: proto = %s, %s\n",
|
||||
filter_Proto2Nam(cproto), dbuff);
|
||||
}
|
||||
gotinfo = 1;
|
||||
}
|
||||
if (LogIsKept(LogDEBUG)) {
|
||||
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);
|
||||
@ -188,7 +188,7 @@ FilterCheck(struct ip *pip, struct filter *filter)
|
||||
} else if (!len)
|
||||
*dbuff = '\0';
|
||||
|
||||
LogPrintf(LogDEBUG, " rule = %d: Address match, "
|
||||
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));
|
||||
@ -207,12 +207,12 @@ FilterCheck(struct ip *pip, struct filter *filter)
|
||||
}
|
||||
} else {
|
||||
/* Address is mached. Make a decision. */
|
||||
LogPrintf(LogDEBUG, " rule = %d: Address match, action = %s\n", n,
|
||||
log_Printf(LogDEBUG, " rule = %d: Address match, action = %s\n", n,
|
||||
filter_Action2Nam(fp->action));
|
||||
return (fp->action);
|
||||
}
|
||||
} else
|
||||
LogPrintf(LogDEBUG, " rule = %d: Address mismatch\n", n);
|
||||
log_Printf(LogDEBUG, " rule = %d: Address mismatch\n", n);
|
||||
}
|
||||
fp++;
|
||||
}
|
||||
@ -228,9 +228,9 @@ IcmpError(struct ip * pip, int code)
|
||||
struct mbuf *bp;
|
||||
|
||||
if (pip->ip_p != IPPROTO_ICMP) {
|
||||
bp = mballoc(cnt, MB_IPIN);
|
||||
bp = mbuf_Alloc(cnt, MB_IPIN);
|
||||
memcpy(MBUF_CTOP(bp), ptr, cnt);
|
||||
SendPppFrame(bp);
|
||||
vj_SendFrame(bp);
|
||||
ipcp_AddOutOctets(cnt);
|
||||
}
|
||||
}
|
||||
@ -252,7 +252,7 @@ PacketCheck(struct bundle *bundle, char *cp, int nb, struct filter *filter)
|
||||
int logit, loglen;
|
||||
static char logbuf[200];
|
||||
|
||||
logit = LogIsKept(LogTCPIP) && filter->logok;
|
||||
logit = log_IsKept(LogTCPIP) && filter->logok;
|
||||
loglen = 0;
|
||||
|
||||
pip = (struct ip *) cp;
|
||||
@ -331,7 +331,7 @@ PacketCheck(struct bundle *bundle, char *cp, int nb, struct filter *filter)
|
||||
|
||||
if ((FilterCheck(pip, filter) & A_DENY)) {
|
||||
if (logit)
|
||||
LogPrintf(LogTCPIP, "%s - BLOCKED\n", logbuf);
|
||||
log_Printf(LogTCPIP, "%s - BLOCKED\n", logbuf);
|
||||
#ifdef notdef
|
||||
if (direction == 0)
|
||||
IcmpError(pip, pri);
|
||||
@ -341,16 +341,16 @@ PacketCheck(struct bundle *bundle, char *cp, int nb, struct filter *filter)
|
||||
/* Check Keep Alive filter */
|
||||
if (logit) {
|
||||
if (FilterCheck(pip, &bundle->filter.alive) & A_DENY)
|
||||
LogPrintf(LogTCPIP, "%s - NO KEEPALIVE\n", logbuf);
|
||||
log_Printf(LogTCPIP, "%s - NO KEEPALIVE\n", logbuf);
|
||||
else
|
||||
LogPrintf(LogTCPIP, "%s\n", logbuf);
|
||||
log_Printf(LogTCPIP, "%s\n", logbuf);
|
||||
}
|
||||
return (pri);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
IpInput(struct bundle *bundle, struct mbuf * bp)
|
||||
ip_Input(struct bundle *bundle, struct mbuf * bp)
|
||||
{
|
||||
u_char *cp;
|
||||
struct mbuf *wp;
|
||||
@ -363,9 +363,9 @@ IpInput(struct bundle *bundle, struct mbuf * bp)
|
||||
nb = 0;
|
||||
for (wp = bp; wp; wp = wp->next) { /* Copy to contiguous region */
|
||||
if (sizeof tun.data - (cp - tun.data) < wp->cnt) {
|
||||
LogPrintf(LogERROR, "IpInput: Packet too large (%d) - dropped\n",
|
||||
plength(bp));
|
||||
pfree(bp);
|
||||
log_Printf(LogERROR, "ip_Input: Packet too large (%d) - dropped\n",
|
||||
mbuf_Length(bp));
|
||||
mbuf_Free(bp);
|
||||
return;
|
||||
}
|
||||
memcpy(cp, MBUF_CTOP(wp), wp->cnt);
|
||||
@ -374,7 +374,7 @@ IpInput(struct bundle *bundle, struct mbuf * bp)
|
||||
}
|
||||
|
||||
#ifndef NOALIAS
|
||||
if (AliasEnabled()) {
|
||||
if (alias_IsEnabled()) {
|
||||
struct tun_data *frag;
|
||||
int iresult;
|
||||
char *fptr;
|
||||
@ -383,14 +383,14 @@ IpInput(struct bundle *bundle, struct mbuf * bp)
|
||||
nb = ntohs(((struct ip *) tun.data)->ip_len);
|
||||
|
||||
if (nb > MAX_MRU) {
|
||||
LogPrintf(LogERROR, "IpInput: Problem with IP header length\n");
|
||||
pfree(bp);
|
||||
log_Printf(LogERROR, "ip_Input: Problem with IP header length\n");
|
||||
mbuf_Free(bp);
|
||||
return;
|
||||
}
|
||||
if (iresult == PKT_ALIAS_OK
|
||||
|| iresult == PKT_ALIAS_FOUND_HEADER_FRAGMENT) {
|
||||
if (PacketCheck(bundle, tun.data, nb, &bundle->filter.in) < 0) {
|
||||
pfree(bp);
|
||||
mbuf_Free(bp);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -404,10 +404,10 @@ IpInput(struct bundle *bundle, struct mbuf * bp)
|
||||
nw = write(bundle->tun_fd, &tun, nb);
|
||||
if (nw != nb) {
|
||||
if (nw == -1)
|
||||
LogPrintf(LogERROR, "IpInput: wrote %d, got %s\n", nb,
|
||||
log_Printf(LogERROR, "ip_Input: wrote %d, got %s\n", nb,
|
||||
strerror(errno));
|
||||
else
|
||||
LogPrintf(LogERROR, "IpInput: wrote %d, got %d\n", nb, nw);
|
||||
log_Printf(LogERROR, "ip_Input: wrote %d, got %d\n", nb, nw);
|
||||
}
|
||||
|
||||
if (iresult == PKT_ALIAS_FOUND_HEADER_FRAGMENT) {
|
||||
@ -420,10 +420,10 @@ IpInput(struct bundle *bundle, struct mbuf * bp)
|
||||
nw = write(bundle->tun_fd, frag, nb);
|
||||
if (nw != nb) {
|
||||
if (nw == -1)
|
||||
LogPrintf(LogERROR, "IpInput: wrote %d, got %s\n", nb,
|
||||
log_Printf(LogERROR, "ip_Input: wrote %d, got %s\n", nb,
|
||||
strerror(errno));
|
||||
else
|
||||
LogPrintf(LogERROR, "IpInput: wrote %d, got %d\n", nb, nw);
|
||||
log_Printf(LogERROR, "ip_Input: wrote %d, got %d\n", nb, nw);
|
||||
}
|
||||
free(frag);
|
||||
}
|
||||
@ -433,7 +433,7 @@ IpInput(struct bundle *bundle, struct mbuf * bp)
|
||||
nb += sizeof tun - sizeof tun.data;
|
||||
frag = (struct tun_data *)malloc(nb);
|
||||
if (frag == NULL)
|
||||
LogPrintf(LogALERT, "IpInput: Cannot allocate memory for fragment\n");
|
||||
log_Printf(LogALERT, "ip_Input: Cannot allocate memory for fragment\n");
|
||||
else {
|
||||
tun_fill_header(*frag, AF_INET);
|
||||
memcpy(frag->data, tun.data, nb - sizeof tun + sizeof tun.data);
|
||||
@ -444,7 +444,7 @@ IpInput(struct bundle *bundle, struct mbuf * bp)
|
||||
#endif /* #ifndef NOALIAS */
|
||||
{ /* no aliasing */
|
||||
if (PacketCheck(bundle, tun.data, nb, &bundle->filter.in) < 0) {
|
||||
pfree(bp);
|
||||
mbuf_Free(bp);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -457,24 +457,24 @@ IpInput(struct bundle *bundle, struct mbuf * bp)
|
||||
nw = write(bundle->tun_fd, &tun, nb);
|
||||
if (nw != nb) {
|
||||
if (nw == -1)
|
||||
LogPrintf(LogERROR, "IpInput: wrote %d, got %s\n", nb, strerror(errno));
|
||||
log_Printf(LogERROR, "ip_Input: wrote %d, got %s\n", nb, strerror(errno));
|
||||
else
|
||||
LogPrintf(LogERROR, "IpInput: wrote %d, got %d\n", nb, nw);
|
||||
log_Printf(LogERROR, "ip_Input: wrote %d, got %d\n", nb, nw);
|
||||
}
|
||||
}
|
||||
pfree(bp);
|
||||
mbuf_Free(bp);
|
||||
}
|
||||
|
||||
static struct mqueue IpOutputQueues[PRI_FAST + 1];
|
||||
|
||||
void
|
||||
IpEnqueue(int pri, char *ptr, int count)
|
||||
ip_Enqueue(int pri, char *ptr, int count)
|
||||
{
|
||||
struct mbuf *bp;
|
||||
|
||||
bp = mballoc(count, MB_IPQ);
|
||||
bp = mbuf_Alloc(count, MB_IPQ);
|
||||
memcpy(MBUF_CTOP(bp), ptr, count);
|
||||
Enqueue(&IpOutputQueues[pri], bp);
|
||||
mbuf_Enqueue(&IpOutputQueues[pri], bp);
|
||||
}
|
||||
|
||||
int
|
||||
@ -490,7 +490,7 @@ ip_QueueLen()
|
||||
}
|
||||
|
||||
int
|
||||
IpFlushPacket(struct link *l, struct bundle *bundle)
|
||||
ip_FlushPacket(struct link *l, struct bundle *bundle)
|
||||
{
|
||||
struct mqueue *queue;
|
||||
struct mbuf *bp;
|
||||
@ -501,12 +501,12 @@ IpFlushPacket(struct link *l, struct bundle *bundle)
|
||||
|
||||
for (queue = &IpOutputQueues[PRI_FAST]; queue >= IpOutputQueues; queue--)
|
||||
if (queue->top) {
|
||||
bp = Dequeue(queue);
|
||||
bp = mbuf_Dequeue(queue);
|
||||
if (bp) {
|
||||
struct ip *pip = (struct ip *)MBUF_CTOP(bp);
|
||||
|
||||
cnt = plength(bp);
|
||||
SendPppFrame(l, bp, bundle);
|
||||
cnt = mbuf_Length(bp);
|
||||
vj_SendFrame(l, bp, bundle);
|
||||
if (!(FilterCheck(pip, &bundle->filter.alive) & A_DENY))
|
||||
bundle_StartIdleTimer(bundle);
|
||||
ipcp_AddOutOctets(&bundle->ncp.ipcp, cnt);
|
||||
|
@ -17,7 +17,7 @@
|
||||
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* $Id: ip.h,v 1.8.2.7 1998/04/03 19:21:26 brian Exp $
|
||||
* $Id: ip.h,v 1.8.2.8 1998/04/07 00:53:50 brian Exp $
|
||||
*
|
||||
*/
|
||||
|
||||
@ -26,8 +26,8 @@ struct filter;
|
||||
struct link;
|
||||
struct bundle;
|
||||
|
||||
extern int IpFlushPacket(struct link *, struct bundle *);
|
||||
extern int ip_FlushPacket(struct link *, struct bundle *);
|
||||
extern int PacketCheck(struct bundle *, char *, int, struct filter *);
|
||||
extern void IpEnqueue(int, char *, int);
|
||||
extern void IpInput(struct bundle *, struct mbuf *);
|
||||
extern void ip_Enqueue(int, char *, int);
|
||||
extern void ip_Input(struct bundle *, struct mbuf *);
|
||||
extern int ip_QueueLen(void);
|
||||
|
@ -17,7 +17,7 @@
|
||||
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* $Id: ipcp.c,v 1.50.2.47 1998/04/28 01:25:26 brian Exp $
|
||||
* $Id: ipcp.c,v 1.50.2.48 1998/04/30 23:53:40 brian Exp $
|
||||
*
|
||||
* TODO:
|
||||
* o More RFC1772 backwoard compatibility
|
||||
@ -102,8 +102,8 @@ static struct fsm_callbacks ipcp_Callbacks = {
|
||||
IpcpSentTerminateReq,
|
||||
IpcpSendTerminateAck,
|
||||
IpcpDecodeConfig,
|
||||
NullRecvResetReq,
|
||||
NullRecvResetAck
|
||||
fsm_NullRecvResetReq,
|
||||
fsm_NullRecvResetAck
|
||||
};
|
||||
|
||||
static const char *cftypes[] = {
|
||||
@ -186,7 +186,7 @@ setdns(struct ipcp *ipcp, struct in_addr addr[2])
|
||||
}
|
||||
|
||||
if (addr[0].s_addr == INADDR_ANY && addr[1].s_addr == INADDR_ANY) {
|
||||
LogPrintf(LogWARN, "%s not modified: All nameservers NAKd\n",
|
||||
log_Printf(LogWARN, "%s not modified: All nameservers NAKd\n",
|
||||
_PATH_RESCONF);
|
||||
return 0;
|
||||
}
|
||||
@ -201,7 +201,7 @@ setdns(struct ipcp *ipcp, struct in_addr addr[2])
|
||||
if (strncmp(buf, "nameserver", 10) || !issep(buf[10])) {
|
||||
len = strlen(buf);
|
||||
if (len > sizeof wbuf - wlen) {
|
||||
LogPrintf(LogWARN, "%s: Can only cope with max file size %d\n",
|
||||
log_Printf(LogWARN, "%s: Can only cope with max file size %d\n",
|
||||
_PATH_RESCONF, LINE_LEN);
|
||||
fclose(fp);
|
||||
return 0;
|
||||
@ -216,14 +216,14 @@ setdns(struct ipcp *ipcp, struct in_addr addr[2])
|
||||
if (addr[0].s_addr != INADDR_ANY) {
|
||||
snprintf(wbuf + wlen, sizeof wbuf - wlen, "nameserver %s\n",
|
||||
inet_ntoa(addr[0]));
|
||||
LogPrintf(LogIPCP, "Primary nameserver set to %s", wbuf + wlen + 11);
|
||||
log_Printf(LogIPCP, "Primary nameserver set to %s", wbuf + wlen + 11);
|
||||
wlen += strlen(wbuf + wlen);
|
||||
}
|
||||
|
||||
if (addr[1].s_addr != INADDR_ANY && addr[1].s_addr != addr[0].s_addr) {
|
||||
snprintf(wbuf + wlen, sizeof wbuf - wlen, "nameserver %s\n",
|
||||
inet_ntoa(addr[1]));
|
||||
LogPrintf(LogIPCP, "Secondary nameserver set to %s", wbuf + wlen + 11);
|
||||
log_Printf(LogIPCP, "Secondary nameserver set to %s", wbuf + wlen + 11);
|
||||
wlen += strlen(wbuf + wlen);
|
||||
}
|
||||
|
||||
@ -232,18 +232,18 @@ setdns(struct ipcp *ipcp, struct in_addr addr[2])
|
||||
|
||||
if ((fd = ID0open(_PATH_RESCONF, O_WRONLY|O_CREAT, 0644)) != -1) {
|
||||
if (write(fd, wbuf, wlen) != wlen) {
|
||||
LogPrintf(LogERROR, "setdns: write(): %s\n", strerror(errno));
|
||||
log_Printf(LogERROR, "setdns: write(): %s\n", strerror(errno));
|
||||
close(fd);
|
||||
return 0;
|
||||
}
|
||||
if (ftruncate(fd, wlen) == -1) {
|
||||
LogPrintf(LogERROR, "setdns: truncate(): %s\n", strerror(errno));
|
||||
log_Printf(LogERROR, "setdns: truncate(): %s\n", strerror(errno));
|
||||
close(fd);
|
||||
return 0;
|
||||
}
|
||||
close(fd);
|
||||
} else {
|
||||
LogPrintf(LogERROR, "setdns: open(): %s\n", strerror(errno));
|
||||
log_Printf(LogERROR, "setdns: open(): %s\n", strerror(errno));
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@ -252,7 +252,7 @@ setdns(struct ipcp *ipcp, struct in_addr addr[2])
|
||||
}
|
||||
|
||||
int
|
||||
ReportIpcpStatus(struct cmdargs const *arg)
|
||||
ipcp_Show(struct cmdargs const *arg)
|
||||
{
|
||||
prompt_Printf(arg->prompt, "%s [%s]\n", arg->bundle->ncp.ipcp.fsm.name,
|
||||
State2Nam(arg->bundle->ncp.ipcp.fsm.state));
|
||||
@ -304,7 +304,7 @@ ReportIpcpStatus(struct cmdargs const *arg)
|
||||
}
|
||||
|
||||
int
|
||||
SetInitVJ(struct cmdargs const *arg)
|
||||
ipcp_vjset(struct cmdargs const *arg)
|
||||
{
|
||||
if (arg->argc != arg->argn+2)
|
||||
return -1;
|
||||
@ -410,7 +410,7 @@ ipcp_Setup(struct ipcp *ipcp)
|
||||
* full negotiation (e.g. "0.0.0.0" or Not "0.0.0.0").
|
||||
*/
|
||||
ipcp->my_ip = ipcp->cfg.TriggerAddress;
|
||||
LogPrintf(LogIPCP, "Using trigger address %s\n",
|
||||
log_Printf(LogIPCP, "Using trigger address %s\n",
|
||||
inet_ntoa(ipcp->cfg.TriggerAddress));
|
||||
} else if ((ipcp->my_ifip.s_addr & ipcp->cfg.my_range.mask.s_addr) ==
|
||||
(ipcp->cfg.my_range.ipaddr.s_addr &
|
||||
@ -453,11 +453,11 @@ ipcp_SetIPaddress(struct bundle *bundle, struct in_addr myaddr,
|
||||
bundle->ncp.ipcp.peer_ifip.s_addr == hisaddr.s_addr)
|
||||
return 0;
|
||||
|
||||
IpcpCleanInterface(&bundle->ncp.ipcp);
|
||||
ipcp_CleanInterface(&bundle->ncp.ipcp);
|
||||
|
||||
s = ID0socket(AF_INET, SOCK_DGRAM, 0);
|
||||
if (s < 0) {
|
||||
LogPrintf(LogERROR, "SetIpDevice: socket(): %s\n", strerror(errno));
|
||||
log_Printf(LogERROR, "SetIpDevice: socket(): %s\n", strerror(errno));
|
||||
return (-1);
|
||||
}
|
||||
|
||||
@ -497,7 +497,7 @@ ipcp_SetIPaddress(struct bundle *bundle, struct in_addr myaddr,
|
||||
|
||||
if (ID0ioctl(s, SIOCAIFADDR, &ifra) < 0) {
|
||||
if (!silent)
|
||||
LogPrintf(LogERROR, "SetIpDevice: ioctl(SIOCAIFADDR): %s\n",
|
||||
log_Printf(LogERROR, "SetIpDevice: ioctl(SIOCAIFADDR): %s\n",
|
||||
strerror(errno));
|
||||
close(s);
|
||||
return (-1);
|
||||
@ -507,7 +507,7 @@ ipcp_SetIPaddress(struct bundle *bundle, struct in_addr myaddr,
|
||||
bundle->ncp.ipcp.my_ifip.s_addr = myaddr.s_addr;
|
||||
|
||||
if (Enabled(bundle, OPT_PROXY))
|
||||
sifproxyarp(bundle, bundle->ncp.ipcp.peer_ifip, s);
|
||||
arp_SetProxy(bundle, bundle->ncp.ipcp.peer_ifip, s);
|
||||
|
||||
close(s);
|
||||
return (0);
|
||||
@ -521,16 +521,16 @@ ChooseHisAddr(struct bundle *bundle, const struct in_addr gw)
|
||||
|
||||
for (f = 0; f < bundle->ncp.ipcp.cfg.peer_list.nItems; f++) {
|
||||
try = iplist_next(&bundle->ncp.ipcp.cfg.peer_list);
|
||||
LogPrintf(LogDEBUG, "ChooseHisAddr: Check item %d (%s)\n",
|
||||
log_Printf(LogDEBUG, "ChooseHisAddr: Check item %d (%s)\n",
|
||||
f, inet_ntoa(try));
|
||||
if (ipcp_SetIPaddress(bundle, gw, try, 1) == 0) {
|
||||
LogPrintf(LogIPCP, "Selected IP address %s\n", inet_ntoa(try));
|
||||
log_Printf(LogIPCP, "Selected IP address %s\n", inet_ntoa(try));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (f == bundle->ncp.ipcp.cfg.peer_list.nItems) {
|
||||
LogPrintf(LogDEBUG, "ChooseHisAddr: All addresses in use !\n");
|
||||
log_Printf(LogDEBUG, "ChooseHisAddr: All addresses in use !\n");
|
||||
try.s_addr = INADDR_ANY;
|
||||
}
|
||||
|
||||
@ -558,7 +558,7 @@ IpcpSendConfigReq(struct fsm *fp)
|
||||
|
||||
o = (struct lcp_opt *)buff;
|
||||
|
||||
if ((p && !Physical_IsSync(p)) || !REJECTED(ipcp, TY_IPADDR)) {
|
||||
if ((p && !physical_IsSync(p)) || !REJECTED(ipcp, TY_IPADDR)) {
|
||||
*(u_int32_t *)o->data = ipcp->my_ip.s_addr;
|
||||
INC_LCP_OPT(TY_IPADDR, 6, o);
|
||||
}
|
||||
@ -584,7 +584,7 @@ IpcpSendConfigReq(struct fsm *fp)
|
||||
INC_LCP_OPT(TY_SECONDARY_DNS, 6, o);
|
||||
}
|
||||
|
||||
FsmOutput(fp, CODE_CONFIGREQ, fp->reqid, buff, (u_char *)o - buff);
|
||||
fsm_Output(fp, CODE_CONFIGREQ, fp->reqid, buff, (u_char *)o - buff);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -597,14 +597,14 @@ static void
|
||||
IpcpSendTerminateAck(struct fsm *fp, u_char id)
|
||||
{
|
||||
/* Send Term ACK please */
|
||||
FsmOutput(fp, CODE_TERMACK, id, NULL, 0);
|
||||
fsm_Output(fp, CODE_TERMACK, id, NULL, 0);
|
||||
}
|
||||
|
||||
static void
|
||||
IpcpLayerStart(struct fsm * fp)
|
||||
{
|
||||
/* We're about to start up ! */
|
||||
LogPrintf(LogIPCP, "%s: IpcpLayerStart.\n", fp->link->name);
|
||||
log_Printf(LogIPCP, "%s: IpcpLayerStart.\n", fp->link->name);
|
||||
|
||||
/* This is where we should be setting up the interface in DEMAND mode */
|
||||
}
|
||||
@ -613,11 +613,11 @@ static void
|
||||
IpcpLayerFinish(struct fsm *fp)
|
||||
{
|
||||
/* We're now down */
|
||||
LogPrintf(LogIPCP, "%s: IpcpLayerFinish.\n", fp->link->name);
|
||||
log_Printf(LogIPCP, "%s: IpcpLayerFinish.\n", fp->link->name);
|
||||
}
|
||||
|
||||
void
|
||||
IpcpCleanInterface(struct ipcp *ipcp)
|
||||
ipcp_CleanInterface(struct ipcp *ipcp)
|
||||
{
|
||||
struct ifaliasreq ifra;
|
||||
struct sockaddr_in *me, *peer;
|
||||
@ -625,12 +625,12 @@ IpcpCleanInterface(struct ipcp *ipcp)
|
||||
|
||||
s = ID0socket(AF_INET, SOCK_DGRAM, 0);
|
||||
if (s < 0) {
|
||||
LogPrintf(LogERROR, "IpcpCleanInterface: socket: %s\n", strerror(errno));
|
||||
log_Printf(LogERROR, "ipcp_CleanInterface: socket: %s\n", strerror(errno));
|
||||
return;
|
||||
}
|
||||
|
||||
if (Enabled(ipcp->fsm.bundle, OPT_PROXY))
|
||||
cifproxyarp(ipcp->fsm.bundle, ipcp->peer_ifip, s);
|
||||
arp_ClearProxy(ipcp->fsm.bundle, ipcp->peer_ifip, s);
|
||||
|
||||
if (ipcp->my_ifip.s_addr != INADDR_ANY ||
|
||||
ipcp->peer_ifip.s_addr != INADDR_ANY) {
|
||||
@ -645,7 +645,7 @@ IpcpCleanInterface(struct ipcp *ipcp)
|
||||
me->sin_addr = ipcp->my_ifip;
|
||||
peer->sin_addr = ipcp->peer_ifip;
|
||||
if (ID0ioctl(s, SIOCDIFADDR, &ifra) < 0) {
|
||||
LogPrintf(LogERROR, "IpcpCleanInterface: ioctl(SIOCDIFADDR): %s\n",
|
||||
log_Printf(LogERROR, "ipcp_CleanInterface: ioctl(SIOCDIFADDR): %s\n",
|
||||
strerror(errno));
|
||||
close(s);
|
||||
}
|
||||
@ -663,7 +663,7 @@ IpcpLayerDown(struct fsm *fp)
|
||||
const char *s;
|
||||
|
||||
s = inet_ntoa(ipcp->peer_ifip);
|
||||
LogPrintf(LogIPCP, "%s: IpcpLayerDown: %s\n", fp->link->name, s);
|
||||
log_Printf(LogIPCP, "%s: IpcpLayerDown: %s\n", fp->link->name, s);
|
||||
|
||||
throughput_stop(&ipcp->throughput);
|
||||
throughput_log(&ipcp->throughput, LogIPCP, NULL);
|
||||
@ -671,17 +671,17 @@ IpcpLayerDown(struct fsm *fp)
|
||||
* XXX this stuff should really live in the FSM. Our config should
|
||||
* associate executable sections in files with events.
|
||||
*/
|
||||
if (SelectSystem(fp->bundle, s, LINKDOWNFILE, NULL) < 0) {
|
||||
if (system_Select(fp->bundle, s, LINKDOWNFILE, NULL) < 0) {
|
||||
if (bundle_GetLabel(fp->bundle)) {
|
||||
if (SelectSystem(fp->bundle, bundle_GetLabel(fp->bundle),
|
||||
if (system_Select(fp->bundle, bundle_GetLabel(fp->bundle),
|
||||
LINKDOWNFILE, NULL) < 0)
|
||||
SelectSystem(fp->bundle, "MYADDR", LINKDOWNFILE, NULL);
|
||||
system_Select(fp->bundle, "MYADDR", LINKDOWNFILE, NULL);
|
||||
} else
|
||||
SelectSystem(fp->bundle, "MYADDR", LINKDOWNFILE, NULL);
|
||||
system_Select(fp->bundle, "MYADDR", LINKDOWNFILE, NULL);
|
||||
}
|
||||
|
||||
if (!(ipcp->fsm.bundle->phys_type & PHYS_DEMAND))
|
||||
IpcpCleanInterface(ipcp);
|
||||
ipcp_CleanInterface(ipcp);
|
||||
}
|
||||
|
||||
static int
|
||||
@ -691,20 +691,20 @@ IpcpLayerUp(struct fsm *fp)
|
||||
struct ipcp *ipcp = fsm2ipcp(fp);
|
||||
char tbuff[100];
|
||||
|
||||
LogPrintf(LogIPCP, "%s: IpcpLayerUp.\n", fp->link->name);
|
||||
log_Printf(LogIPCP, "%s: IpcpLayerUp.\n", fp->link->name);
|
||||
snprintf(tbuff, sizeof tbuff, "myaddr = %s ", inet_ntoa(ipcp->my_ip));
|
||||
LogPrintf(LogIPCP, " %s hisaddr = %s\n", tbuff, inet_ntoa(ipcp->peer_ip));
|
||||
log_Printf(LogIPCP, " %s hisaddr = %s\n", tbuff, inet_ntoa(ipcp->peer_ip));
|
||||
|
||||
if (ipcp->peer_compproto >> 16 == PROTO_VJCOMP)
|
||||
sl_compress_init(&ipcp->vj.cslc, (ipcp->peer_compproto >> 8) & 255);
|
||||
|
||||
if (ipcp_SetIPaddress(fp->bundle, ipcp->my_ip, ipcp->peer_ip, 0) < 0) {
|
||||
LogPrintf(LogERROR, "IpcpLayerUp: unable to set ip address\n");
|
||||
log_Printf(LogERROR, "IpcpLayerUp: unable to set ip address\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifndef NOALIAS
|
||||
if (AliasEnabled())
|
||||
if (alias_IsEnabled())
|
||||
(*PacketAlias.SetAddress)(ipcp->my_ip);
|
||||
#endif
|
||||
|
||||
@ -712,14 +712,14 @@ IpcpLayerUp(struct fsm *fp)
|
||||
* XXX this stuff should really live in the FSM. Our config should
|
||||
* associate executable sections in files with events.
|
||||
*/
|
||||
if (SelectSystem(fp->bundle, inet_ntoa(ipcp->my_ifip), LINKUPFILE, NULL)
|
||||
if (system_Select(fp->bundle, inet_ntoa(ipcp->my_ifip), LINKUPFILE, NULL)
|
||||
< 0) {
|
||||
if (bundle_GetLabel(fp->bundle)) {
|
||||
if (SelectSystem(fp->bundle, bundle_GetLabel(fp->bundle),
|
||||
if (system_Select(fp->bundle, bundle_GetLabel(fp->bundle),
|
||||
LINKUPFILE, NULL) < 0)
|
||||
SelectSystem(fp->bundle, "MYADDR", LINKUPFILE, NULL);
|
||||
system_Select(fp->bundle, "MYADDR", LINKUPFILE, NULL);
|
||||
} else
|
||||
SelectSystem(fp->bundle, "MYADDR", LINKUPFILE, NULL);
|
||||
system_Select(fp->bundle, "MYADDR", LINKUPFILE, NULL);
|
||||
}
|
||||
|
||||
throughput_start(&ipcp->throughput, "IPCP throughput",
|
||||
@ -758,7 +758,7 @@ IpcpDecodeConfig(struct fsm *fp, u_char * cp, int plen, int mode_type,
|
||||
length = cp[1];
|
||||
|
||||
if (length == 0) {
|
||||
LogPrintf(LogIPCP, "%s: IPCP size zero\n", fp->link->name);
|
||||
log_Printf(LogIPCP, "%s: IPCP size zero\n", fp->link->name);
|
||||
break;
|
||||
}
|
||||
|
||||
@ -772,7 +772,7 @@ IpcpDecodeConfig(struct fsm *fp, u_char * cp, int plen, int mode_type,
|
||||
switch (type) {
|
||||
case TY_IPADDR: /* RFC1332 */
|
||||
ipaddr.s_addr = *(u_int32_t *)(cp + 2);
|
||||
LogPrintf(LogIPCP, "%s %s\n", tbuff, inet_ntoa(ipaddr));
|
||||
log_Printf(LogIPCP, "%s %s\n", tbuff, inet_ntoa(ipaddr));
|
||||
|
||||
switch (mode_type) {
|
||||
case MODE_REQ:
|
||||
@ -781,7 +781,7 @@ IpcpDecodeConfig(struct fsm *fp, u_char * cp, int plen, int mode_type,
|
||||
iplist_ip2pos(&ipcp->cfg.peer_list, ipaddr) < 0 ||
|
||||
ipcp_SetIPaddress(fp->bundle, ipcp->cfg.my_range.ipaddr,
|
||||
ipaddr, 1)) {
|
||||
LogPrintf(LogIPCP, "%s: Address invalid or already in use\n",
|
||||
log_Printf(LogIPCP, "%s: Address invalid or already in use\n",
|
||||
inet_ntoa(ipaddr));
|
||||
if (iplist_ip2pos(&ipcp->cfg.peer_list, ipcp->peer_ifip) >= 0)
|
||||
/*
|
||||
@ -830,12 +830,12 @@ IpcpDecodeConfig(struct fsm *fp, u_char * cp, int plen, int mode_type,
|
||||
/* Use address suggested by peer */
|
||||
snprintf(tbuff2, sizeof tbuff2, "%s changing address: %s ", tbuff,
|
||||
inet_ntoa(ipcp->my_ip));
|
||||
LogPrintf(LogIPCP, "%s --> %s\n", tbuff2, inet_ntoa(ipaddr));
|
||||
log_Printf(LogIPCP, "%s --> %s\n", tbuff2, inet_ntoa(ipaddr));
|
||||
ipcp->my_ip = ipaddr;
|
||||
} else {
|
||||
LogPrintf(LogIsKept(LogIPCP) ? LogIPCP : LogPHASE,
|
||||
log_Printf(log_IsKept(LogIPCP) ? LogIPCP : LogPHASE,
|
||||
"%s: Unacceptable address!\n", inet_ntoa(ipaddr));
|
||||
FsmClose(&ipcp->fsm);
|
||||
fsm_Close(&ipcp->fsm);
|
||||
}
|
||||
break;
|
||||
case MODE_REJ:
|
||||
@ -845,7 +845,7 @@ IpcpDecodeConfig(struct fsm *fp, u_char * cp, int plen, int mode_type,
|
||||
break;
|
||||
case TY_COMPPROTO:
|
||||
compproto = htonl(*(u_int32_t *)(cp + 2));
|
||||
LogPrintf(LogIPCP, "%s %s\n", tbuff, vj2asc(compproto));
|
||||
log_Printf(LogIPCP, "%s %s\n", tbuff, vj2asc(compproto));
|
||||
|
||||
switch (mode_type) {
|
||||
case MODE_REQ:
|
||||
@ -857,7 +857,7 @@ IpcpDecodeConfig(struct fsm *fp, u_char * cp, int plen, int mode_type,
|
||||
switch (length) {
|
||||
case 4: /* RFC1172 */
|
||||
if (ntohs(pcomp->proto) == PROTO_VJCOMP) {
|
||||
LogPrintf(LogWARN, "Peer is speaking RFC1172 compression protocol !\n");
|
||||
log_Printf(LogWARN, "Peer is speaking RFC1172 compression protocol !\n");
|
||||
ipcp->heis1172 = 1;
|
||||
ipcp->peer_compproto = compproto;
|
||||
memcpy(dec->ackend, cp, length);
|
||||
@ -894,7 +894,7 @@ IpcpDecodeConfig(struct fsm *fp, u_char * cp, int plen, int mode_type,
|
||||
}
|
||||
break;
|
||||
case MODE_NAK:
|
||||
LogPrintf(LogIPCP, "%s changing compproto: %08x --> %08x\n",
|
||||
log_Printf(LogIPCP, "%s changing compproto: %08x --> %08x\n",
|
||||
tbuff, ipcp->my_compproto, compproto);
|
||||
ipcp->my_compproto = compproto;
|
||||
break;
|
||||
@ -907,7 +907,7 @@ IpcpDecodeConfig(struct fsm *fp, u_char * cp, int plen, int mode_type,
|
||||
ipaddr.s_addr = *(u_int32_t *)(cp + 2);
|
||||
dstipaddr.s_addr = *(u_int32_t *)(cp + 6);
|
||||
snprintf(tbuff2, sizeof tbuff2, "%s %s,", tbuff, inet_ntoa(ipaddr));
|
||||
LogPrintf(LogIPCP, "%s %s\n", tbuff2, inet_ntoa(dstipaddr));
|
||||
log_Printf(LogIPCP, "%s %s\n", tbuff2, inet_ntoa(dstipaddr));
|
||||
|
||||
switch (mode_type) {
|
||||
case MODE_REQ:
|
||||
@ -919,7 +919,7 @@ IpcpDecodeConfig(struct fsm *fp, u_char * cp, int plen, int mode_type,
|
||||
case MODE_NAK:
|
||||
snprintf(tbuff2, sizeof tbuff2, "%s changing address: %s", tbuff,
|
||||
inet_ntoa(ipcp->my_ip));
|
||||
LogPrintf(LogIPCP, "%s --> %s\n", tbuff2, inet_ntoa(ipaddr));
|
||||
log_Printf(LogIPCP, "%s --> %s\n", tbuff2, inet_ntoa(ipaddr));
|
||||
ipcp->my_ip = ipaddr;
|
||||
ipcp->peer_ip = dstipaddr;
|
||||
break;
|
||||
@ -932,7 +932,7 @@ IpcpDecodeConfig(struct fsm *fp, u_char * cp, int plen, int mode_type,
|
||||
case TY_PRIMARY_DNS: /* DNS negotiation (rfc1877) */
|
||||
case TY_SECONDARY_DNS:
|
||||
ipaddr.s_addr = *(u_int32_t *)(cp + 2);
|
||||
LogPrintf(LogIPCP, "%s %s\n", tbuff, inet_ntoa(ipaddr));
|
||||
log_Printf(LogIPCP, "%s %s\n", tbuff, inet_ntoa(ipaddr));
|
||||
|
||||
switch (mode_type) {
|
||||
case MODE_REQ:
|
||||
@ -984,7 +984,7 @@ IpcpDecodeConfig(struct fsm *fp, u_char * cp, int plen, int mode_type,
|
||||
case TY_PRIMARY_NBNS: /* M$ NetBIOS nameserver hack (rfc1877) */
|
||||
case TY_SECONDARY_NBNS:
|
||||
ipaddr.s_addr = *(u_int32_t *)(cp + 2);
|
||||
LogPrintf(LogIPCP, "%s %s\n", tbuff, inet_ntoa(ipaddr));
|
||||
log_Printf(LogIPCP, "%s %s\n", tbuff, inet_ntoa(ipaddr));
|
||||
|
||||
switch (mode_type) {
|
||||
case MODE_REQ:
|
||||
@ -992,7 +992,7 @@ IpcpDecodeConfig(struct fsm *fp, u_char * cp, int plen, int mode_type,
|
||||
ipcp->cfg.ns.nbns[type == TY_PRIMARY_NBNS ? 0 : 1].s_addr;
|
||||
|
||||
if (have_ip.s_addr == INADDR_ANY) {
|
||||
LogPrintf(LogIPCP, "NBNS REQ - rejected - nbns not set\n");
|
||||
log_Printf(LogIPCP, "NBNS REQ - rejected - nbns not set\n");
|
||||
ipcp->my_reject |= (1 << (type - TY_ADJUST_NS));
|
||||
memcpy(dec->rejend, cp, length);
|
||||
dec->rejend += length;
|
||||
@ -1009,10 +1009,10 @@ IpcpDecodeConfig(struct fsm *fp, u_char * cp, int plen, int mode_type,
|
||||
}
|
||||
break;
|
||||
case MODE_NAK:
|
||||
LogPrintf(LogIPCP, "MS NBNS req %d - NAK??\n", type);
|
||||
log_Printf(LogIPCP, "MS NBNS req %d - NAK??\n", type);
|
||||
break;
|
||||
case MODE_REJ:
|
||||
LogPrintf(LogIPCP, "MS NBNS req %d - REJ??\n", type);
|
||||
log_Printf(LogIPCP, "MS NBNS req %d - REJ??\n", type);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
@ -1047,14 +1047,14 @@ IpcpDecodeConfig(struct fsm *fp, u_char * cp, int plen, int mode_type,
|
||||
}
|
||||
|
||||
void
|
||||
IpcpInput(struct ipcp *ipcp, struct mbuf * bp)
|
||||
ipcp_Input(struct ipcp *ipcp, struct mbuf * bp)
|
||||
{
|
||||
/* Got PROTO_IPCP from link */
|
||||
FsmInput(&ipcp->fsm, bp);
|
||||
fsm_Input(&ipcp->fsm, bp);
|
||||
}
|
||||
|
||||
int
|
||||
UseHisaddr(struct bundle *bundle, const char *hisaddr, int setaddr)
|
||||
ipcp_UseHisaddr(struct bundle *bundle, const char *hisaddr, int setaddr)
|
||||
{
|
||||
struct ipcp *ipcp = &bundle->ncp.ipcp;
|
||||
|
||||
@ -1067,14 +1067,14 @@ UseHisaddr(struct bundle *bundle, const char *hisaddr, int setaddr)
|
||||
iplist_setrandpos(&ipcp->cfg.peer_list);
|
||||
ipcp->peer_ip = ChooseHisAddr(bundle, ipcp->my_ip);
|
||||
if (ipcp->peer_ip.s_addr == INADDR_ANY) {
|
||||
LogPrintf(LogWARN, "%s: None available !\n", ipcp->cfg.peer_list.src);
|
||||
log_Printf(LogWARN, "%s: None available !\n", ipcp->cfg.peer_list.src);
|
||||
return(0);
|
||||
}
|
||||
ipcp->cfg.peer_range.ipaddr.s_addr = ipcp->peer_ip.s_addr;
|
||||
ipcp->cfg.peer_range.mask.s_addr = INADDR_BROADCAST;
|
||||
ipcp->cfg.peer_range.width = 32;
|
||||
} else {
|
||||
LogPrintf(LogWARN, "%s: Invalid range !\n", hisaddr);
|
||||
log_Printf(LogWARN, "%s: Invalid range !\n", hisaddr);
|
||||
return 0;
|
||||
}
|
||||
} else if (ParseAddr(ipcp, 1, &hisaddr, &ipcp->cfg.peer_range.ipaddr,
|
||||
|
@ -15,7 +15,7 @@
|
||||
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* $Id: ipcp.h,v 1.18.2.23 1998/04/17 22:05:29 brian Exp $
|
||||
* $Id: ipcp.h,v 1.18.2.24 1998/04/23 18:56:18 brian Exp $
|
||||
*
|
||||
* TODO:
|
||||
*/
|
||||
@ -101,10 +101,10 @@ extern void ipcp_Init(struct ipcp *, struct bundle *, struct link *,
|
||||
extern void ipcp_Setup(struct ipcp *);
|
||||
extern void ipcp_SetLink(struct ipcp *, struct link *);
|
||||
|
||||
extern int ReportIpcpStatus(struct cmdargs const *);
|
||||
extern void IpcpInput(struct ipcp *, struct mbuf *);
|
||||
extern int ipcp_Show(struct cmdargs const *);
|
||||
extern void ipcp_Input(struct ipcp *, struct mbuf *);
|
||||
extern void ipcp_AddInOctets(struct ipcp *, int);
|
||||
extern void ipcp_AddOutOctets(struct ipcp *, int);
|
||||
extern int UseHisaddr(struct bundle *, const char *, int);
|
||||
extern int SetInitVJ(struct cmdargs const *);
|
||||
extern void IpcpCleanInterface(struct ipcp *);
|
||||
extern int ipcp_UseHisaddr(struct bundle *, const char *, int);
|
||||
extern int ipcp_vjset(struct cmdargs const *);
|
||||
extern void ipcp_CleanInterface(struct ipcp *);
|
||||
|
@ -23,7 +23,7 @@
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $Id: iplist.c,v 1.4.4.1 1998/04/06 09:12:30 brian Exp $
|
||||
* $Id: iplist.c,v 1.4.4.2 1998/04/07 00:53:53 brian Exp $
|
||||
*/
|
||||
|
||||
#include <sys/types.h>
|
||||
@ -43,7 +43,7 @@ do_inet_aton(const char *start, const char *end, struct in_addr *ip)
|
||||
static char ipstr[16];
|
||||
|
||||
if (end - start > 15) {
|
||||
LogPrintf(LogWARN, "%.*s: Invalid IP address\n", end-start, start);
|
||||
log_Printf(LogWARN, "%.*s: Invalid IP address\n", end-start, start);
|
||||
return 0;
|
||||
}
|
||||
strncpy(ipstr, start, end-start);
|
||||
@ -110,7 +110,7 @@ iplist_nextrange(struct iplist *list)
|
||||
end = ptr + strlen(ptr);
|
||||
if (end == ptr)
|
||||
return 0;
|
||||
LogPrintf(LogWARN, "%.*s: Invalid IP range (skipping)\n", end - ptr, ptr);
|
||||
log_Printf(LogWARN, "%.*s: Invalid IP range (skipping)\n", end - ptr, ptr);
|
||||
to = ptr;
|
||||
do
|
||||
*to = *end++;
|
||||
|
@ -17,7 +17,7 @@
|
||||
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* $Id: lcp.c,v 1.55.2.50 1998/04/28 01:25:27 brian Exp $
|
||||
* $Id: lcp.c,v 1.55.2.51 1998/04/30 23:53:42 brian Exp $
|
||||
*
|
||||
* TODO:
|
||||
* o Limit data field length by MRU
|
||||
@ -92,8 +92,8 @@ static struct fsm_callbacks lcp_Callbacks = {
|
||||
LcpSentTerminateReq,
|
||||
LcpSendTerminateAck,
|
||||
LcpDecodeConfig,
|
||||
NullRecvResetReq,
|
||||
NullRecvResetAck
|
||||
fsm_NullRecvResetReq,
|
||||
fsm_NullRecvResetAck
|
||||
};
|
||||
|
||||
static const char *lcp_TimerNames[] =
|
||||
@ -132,7 +132,7 @@ static const char *cftypes[] = {
|
||||
int
|
||||
lcp_ReportStatus(struct cmdargs const *arg)
|
||||
{
|
||||
struct link *l = ChooseLink(arg);
|
||||
struct link *l = command_ChooseLink(arg);
|
||||
struct lcp *lcp = &l->lcp;
|
||||
|
||||
prompt_Printf(arg->prompt, "%s: %s [%s]\n", l->name, lcp->fsm.name,
|
||||
@ -284,13 +284,13 @@ LcpSendConfigReq(struct fsm *fp)
|
||||
struct mp *mp;
|
||||
|
||||
if (!p) {
|
||||
LogPrintf(LogERROR, "%s: LcpSendConfigReq: Not a physical link !\n",
|
||||
log_Printf(LogERROR, "%s: LcpSendConfigReq: Not a physical link !\n",
|
||||
fp->link->name);
|
||||
return;
|
||||
}
|
||||
|
||||
o = (struct lcp_opt *)buff;
|
||||
if (!Physical_IsSync(p)) {
|
||||
if (!physical_IsSync(p)) {
|
||||
if (lcp->want_acfcomp && !REJECTED(lcp, TY_ACFCOMP))
|
||||
INC_LCP_OPT(TY_ACFCOMP, 2, o);
|
||||
|
||||
@ -347,14 +347,14 @@ LcpSendConfigReq(struct fsm *fp)
|
||||
INC_LCP_OPT(TY_ENDDISC, mp->cfg.enddisc.len + 3, o);
|
||||
}
|
||||
|
||||
FsmOutput(fp, CODE_CONFIGREQ, fp->reqid, buff, (u_char *)o - buff);
|
||||
fsm_Output(fp, CODE_CONFIGREQ, fp->reqid, buff, (u_char *)o - buff);
|
||||
}
|
||||
|
||||
void
|
||||
lcp_SendProtoRej(struct lcp *lcp, u_char *option, int count)
|
||||
{
|
||||
/* Don't understand `option' */
|
||||
FsmOutput(&lcp->fsm, CODE_PROTOREJ, lcp->fsm.reqid, option, count);
|
||||
fsm_Output(&lcp->fsm, CODE_PROTOREJ, lcp->fsm.reqid, option, count);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -367,7 +367,7 @@ static void
|
||||
LcpSendTerminateAck(struct fsm *fp, u_char id)
|
||||
{
|
||||
/* Send Term ACK please */
|
||||
FsmOutput(fp, CODE_TERMACK, id, NULL, 0);
|
||||
fsm_Output(fp, CODE_TERMACK, id, NULL, 0);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -376,7 +376,7 @@ LcpLayerStart(struct fsm *fp)
|
||||
/* We're about to start up ! */
|
||||
struct lcp *lcp = fsm2lcp(fp);
|
||||
|
||||
LogPrintf(LogLCP, "%s: LcpLayerStart\n", fp->link->name);
|
||||
log_Printf(LogLCP, "%s: LcpLayerStart\n", fp->link->name);
|
||||
lcp->LcpFailedMagic = 0;
|
||||
}
|
||||
|
||||
@ -384,7 +384,7 @@ static void
|
||||
LcpLayerFinish(struct fsm *fp)
|
||||
{
|
||||
/* We're now down */
|
||||
LogPrintf(LogLCP, "%s: LcpLayerFinish\n", fp->link->name);
|
||||
log_Printf(LogLCP, "%s: LcpLayerFinish\n", fp->link->name);
|
||||
}
|
||||
|
||||
static int
|
||||
@ -394,9 +394,9 @@ LcpLayerUp(struct fsm *fp)
|
||||
struct physical *p = link2physical(fp->link);
|
||||
struct lcp *lcp = fsm2lcp(fp);
|
||||
|
||||
LogPrintf(LogLCP, "%s: LcpLayerUp\n", fp->link->name);
|
||||
log_Printf(LogLCP, "%s: LcpLayerUp\n", fp->link->name);
|
||||
async_SetLinkParams(&p->async, lcp);
|
||||
StartLqm(lcp);
|
||||
lqr_Start(lcp);
|
||||
hdlc_StartTimer(&p->hdlc);
|
||||
return 1;
|
||||
}
|
||||
@ -407,9 +407,9 @@ LcpLayerDown(struct fsm *fp)
|
||||
/* About to come down */
|
||||
struct physical *p = link2physical(fp->link);
|
||||
|
||||
LogPrintf(LogLCP, "%s: LcpLayerDown\n", fp->link->name);
|
||||
log_Printf(LogLCP, "%s: LcpLayerDown\n", fp->link->name);
|
||||
hdlc_StopTimer(&p->hdlc);
|
||||
StopLqrTimer(p);
|
||||
lqr_StopTimer(p);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -431,7 +431,7 @@ LcpDecodeConfig(struct fsm *fp, u_char *cp, int plen, int mode_type,
|
||||
length = cp[1];
|
||||
|
||||
if (length == 0) {
|
||||
LogPrintf(LogLCP, "%s: LCP size zero\n", fp->link->name);
|
||||
log_Printf(LogLCP, "%s: LCP size zero\n", fp->link->name);
|
||||
break;
|
||||
}
|
||||
|
||||
@ -445,7 +445,7 @@ LcpDecodeConfig(struct fsm *fp, u_char *cp, int plen, int mode_type,
|
||||
mp = &lcp->fsm.bundle->ncp.mp;
|
||||
sp = (u_short *)(cp + 2);
|
||||
mru = htons(*sp);
|
||||
LogPrintf(LogLCP, "%s %u\n", request, mru);
|
||||
log_Printf(LogLCP, "%s %u\n", request, mru);
|
||||
|
||||
switch (mode_type) {
|
||||
case MODE_REQ:
|
||||
@ -495,7 +495,7 @@ LcpDecodeConfig(struct fsm *fp, u_char *cp, int plen, int mode_type,
|
||||
case TY_MRU:
|
||||
sp = (u_short *) (cp + 2);
|
||||
mru = htons(*sp);
|
||||
LogPrintf(LogLCP, "%s %d\n", request, mru);
|
||||
log_Printf(LogLCP, "%s %d\n", request, mru);
|
||||
|
||||
switch (mode_type) {
|
||||
case MODE_REQ:
|
||||
@ -528,7 +528,7 @@ LcpDecodeConfig(struct fsm *fp, u_char *cp, int plen, int mode_type,
|
||||
|
||||
case TY_ACCMAP:
|
||||
accmap = htonl(*(u_int32_t *)(cp + 2));
|
||||
LogPrintf(LogLCP, "%s 0x%08lx\n", request, (u_long)accmap);
|
||||
log_Printf(LogLCP, "%s 0x%08lx\n", request, (u_long)accmap);
|
||||
|
||||
switch (mode_type) {
|
||||
case MODE_REQ:
|
||||
@ -550,13 +550,13 @@ LcpDecodeConfig(struct fsm *fp, u_char *cp, int plen, int mode_type,
|
||||
proto = ntohs(*sp);
|
||||
switch (proto) {
|
||||
case PROTO_PAP:
|
||||
LogPrintf(LogLCP, "%s 0x%04x (PAP)\n", request, proto);
|
||||
log_Printf(LogLCP, "%s 0x%04x (PAP)\n", request, proto);
|
||||
break;
|
||||
case PROTO_CHAP:
|
||||
LogPrintf(LogLCP, "%s 0x%04x (CHAP 0x%02x)\n", request, proto, cp[4]);
|
||||
log_Printf(LogLCP, "%s 0x%04x (CHAP 0x%02x)\n", request, proto, cp[4]);
|
||||
break;
|
||||
default:
|
||||
LogPrintf(LogLCP, "%s 0x%04x\n", request, proto);
|
||||
log_Printf(LogLCP, "%s 0x%04x\n", request, proto);
|
||||
break;
|
||||
}
|
||||
|
||||
@ -565,7 +565,7 @@ LcpDecodeConfig(struct fsm *fp, u_char *cp, int plen, int mode_type,
|
||||
switch (proto) {
|
||||
case PROTO_PAP:
|
||||
if (length != 4) {
|
||||
LogPrintf(LogLCP, " Bad length!\n");
|
||||
log_Printf(LogLCP, " Bad length!\n");
|
||||
goto reqreject;
|
||||
}
|
||||
if (IsAccepted(lcp->cfg.pap)) {
|
||||
@ -584,7 +584,7 @@ LcpDecodeConfig(struct fsm *fp, u_char *cp, int plen, int mode_type,
|
||||
|
||||
case PROTO_CHAP:
|
||||
if (length < 5) {
|
||||
LogPrintf(LogLCP, " Bad length!\n");
|
||||
log_Printf(LogLCP, " Bad length!\n");
|
||||
goto reqreject;
|
||||
}
|
||||
#ifdef HAVE_DES
|
||||
@ -609,7 +609,7 @@ LcpDecodeConfig(struct fsm *fp, u_char *cp, int plen, int mode_type,
|
||||
break;
|
||||
|
||||
default:
|
||||
LogPrintf(LogLCP, "%s 0x%04x - not recognised, NAK\n",
|
||||
log_Printf(LogLCP, "%s 0x%04x - not recognised, NAK\n",
|
||||
request, proto);
|
||||
memcpy(dec->nakend, cp, length);
|
||||
dec->nakend += length;
|
||||
@ -622,7 +622,7 @@ LcpDecodeConfig(struct fsm *fp, u_char *cp, int plen, int mode_type,
|
||||
if (IsEnabled(lcp->cfg.pap))
|
||||
lcp->want_auth = PROTO_PAP;
|
||||
else {
|
||||
LogPrintf(LogLCP, "Peer will only send PAP (not enabled)\n");
|
||||
log_Printf(LogLCP, "Peer will only send PAP (not enabled)\n");
|
||||
lcp->his_reject |= (1 << type);
|
||||
}
|
||||
break;
|
||||
@ -630,7 +630,7 @@ LcpDecodeConfig(struct fsm *fp, u_char *cp, int plen, int mode_type,
|
||||
if (IsEnabled(lcp->cfg.chap))
|
||||
lcp->want_auth = PROTO_CHAP;
|
||||
else {
|
||||
LogPrintf(LogLCP, "Peer will only send CHAP (not enabled)\n");
|
||||
log_Printf(LogLCP, "Peer will only send CHAP (not enabled)\n");
|
||||
lcp->his_reject |= (1 << type);
|
||||
}
|
||||
break;
|
||||
@ -648,7 +648,7 @@ LcpDecodeConfig(struct fsm *fp, u_char *cp, int plen, int mode_type,
|
||||
|
||||
case TY_QUALPROTO:
|
||||
req = (struct lqrreq *)cp;
|
||||
LogPrintf(LogLCP, "%s proto %x, interval %ldms\n",
|
||||
log_Printf(LogLCP, "%s proto %x, interval %ldms\n",
|
||||
request, ntohs(req->proto), (long)ntohl(req->period) * 10);
|
||||
switch (mode_type) {
|
||||
case MODE_REQ:
|
||||
@ -673,14 +673,14 @@ LcpDecodeConfig(struct fsm *fp, u_char *cp, int plen, int mode_type,
|
||||
|
||||
case TY_MAGICNUM:
|
||||
magic = ntohl(*(u_int32_t *)(cp + 2));
|
||||
LogPrintf(LogLCP, "%s 0x%08lx\n", request, (u_long)magic);
|
||||
log_Printf(LogLCP, "%s 0x%08lx\n", request, (u_long)magic);
|
||||
|
||||
switch (mode_type) {
|
||||
case MODE_REQ:
|
||||
if (lcp->want_magic) {
|
||||
/* Validate magic number */
|
||||
if (magic == lcp->want_magic) {
|
||||
LogPrintf(LogLCP, "Magic is same (%08lx) - %d times\n",
|
||||
log_Printf(LogLCP, "Magic is same (%08lx) - %d times\n",
|
||||
(u_long)magic, ++lcp->LcpFailedMagic);
|
||||
lcp->want_magic = GenerateMagic();
|
||||
memcpy(dec->nakend, cp, 6);
|
||||
@ -698,11 +698,11 @@ LcpDecodeConfig(struct fsm *fp, u_char *cp, int plen, int mode_type,
|
||||
}
|
||||
break;
|
||||
case MODE_NAK:
|
||||
LogPrintf(LogLCP, " Magic 0x%08lx is NAKed!\n", (u_long)magic);
|
||||
log_Printf(LogLCP, " Magic 0x%08lx is NAKed!\n", (u_long)magic);
|
||||
lcp->want_magic = GenerateMagic();
|
||||
break;
|
||||
case MODE_REJ:
|
||||
LogPrintf(LogLCP, " Magic 0x%08x is REJected!\n", magic);
|
||||
log_Printf(LogLCP, " Magic 0x%08x is REJected!\n", magic);
|
||||
lcp->want_magic = 0;
|
||||
lcp->his_reject |= (1 << type);
|
||||
break;
|
||||
@ -710,7 +710,7 @@ LcpDecodeConfig(struct fsm *fp, u_char *cp, int plen, int mode_type,
|
||||
break;
|
||||
|
||||
case TY_PROTOCOMP:
|
||||
LogPrintf(LogLCP, "%s\n", request);
|
||||
log_Printf(LogLCP, "%s\n", request);
|
||||
|
||||
switch (mode_type) {
|
||||
case MODE_REQ:
|
||||
@ -739,7 +739,7 @@ LcpDecodeConfig(struct fsm *fp, u_char *cp, int plen, int mode_type,
|
||||
break;
|
||||
|
||||
case TY_ACFCOMP:
|
||||
LogPrintf(LogLCP, "%s\n", request);
|
||||
log_Printf(LogLCP, "%s\n", request);
|
||||
switch (mode_type) {
|
||||
case MODE_REQ:
|
||||
if (IsAccepted(lcp->cfg.acfcomp)) {
|
||||
@ -767,7 +767,7 @@ LcpDecodeConfig(struct fsm *fp, u_char *cp, int plen, int mode_type,
|
||||
break;
|
||||
|
||||
case TY_SDP:
|
||||
LogPrintf(LogLCP, "%s\n", request);
|
||||
log_Printf(LogLCP, "%s\n", request);
|
||||
switch (mode_type) {
|
||||
case MODE_REQ:
|
||||
case MODE_NAK:
|
||||
@ -778,7 +778,7 @@ LcpDecodeConfig(struct fsm *fp, u_char *cp, int plen, int mode_type,
|
||||
|
||||
case TY_SHORTSEQ:
|
||||
mp = &lcp->fsm.bundle->ncp.mp;
|
||||
LogPrintf(LogLCP, "%s\n", request);
|
||||
log_Printf(LogLCP, "%s\n", request);
|
||||
|
||||
switch (mode_type) {
|
||||
case MODE_REQ:
|
||||
@ -802,12 +802,12 @@ LcpDecodeConfig(struct fsm *fp, u_char *cp, int plen, int mode_type,
|
||||
break;
|
||||
|
||||
case TY_ENDDISC:
|
||||
LogPrintf(LogLCP, "%s %s\n", request,
|
||||
log_Printf(LogLCP, "%s %s\n", request,
|
||||
mp_Enddisc(cp[2], cp + 3, length - 3));
|
||||
switch (mode_type) {
|
||||
case MODE_REQ:
|
||||
if (!p) {
|
||||
LogPrintf(LogLCP, " ENDDISC rejected - not a physical link\n");
|
||||
log_Printf(LogLCP, " ENDDISC rejected - not a physical link\n");
|
||||
goto reqreject;
|
||||
} else if (length-3 < sizeof p->dl->peer.enddisc.address &&
|
||||
cp[2] <= MAX_ENDDISC_CLASS) {
|
||||
@ -820,10 +820,10 @@ LcpDecodeConfig(struct fsm *fp, u_char *cp, int plen, int mode_type,
|
||||
dec->ackend += length;
|
||||
} else {
|
||||
if (cp[2] > MAX_ENDDISC_CLASS)
|
||||
LogPrintf(LogLCP, " ENDDISC rejected - unrecognised class %d\n",
|
||||
log_Printf(LogLCP, " ENDDISC rejected - unrecognised class %d\n",
|
||||
cp[2]);
|
||||
else
|
||||
LogPrintf(LogLCP, " ENDDISC rejected - local max length is %d\n",
|
||||
log_Printf(LogLCP, " ENDDISC rejected - local max length is %d\n",
|
||||
sizeof p->dl->peer.enddisc.address - 1);
|
||||
goto reqreject;
|
||||
}
|
||||
@ -845,13 +845,13 @@ LcpDecodeConfig(struct fsm *fp, u_char *cp, int plen, int mode_type,
|
||||
for (pos = 0; sz--; pos++)
|
||||
sprintf(desc+(pos<<1)+1, "%02x", cp[pos+2]);
|
||||
|
||||
LogPrintf(LogLCP, "%s%s\n", request, desc);
|
||||
log_Printf(LogLCP, "%s%s\n", request, desc);
|
||||
|
||||
if (mode_type == MODE_REQ) {
|
||||
reqreject:
|
||||
if (length > sizeof dec->rej - (dec->rejend - dec->rej)) {
|
||||
length = sizeof dec->rej - (dec->rejend - dec->rej);
|
||||
LogPrintf(LogLCP, "Can't REJ length %d - trunating to %d\n",
|
||||
log_Printf(LogLCP, "Can't REJ length %d - trunating to %d\n",
|
||||
cp[1], length);
|
||||
}
|
||||
memcpy(dec->rejend, cp, length);
|
||||
@ -878,8 +878,8 @@ LcpDecodeConfig(struct fsm *fp, u_char *cp, int plen, int mode_type,
|
||||
}
|
||||
|
||||
void
|
||||
LcpInput(struct lcp *lcp, struct mbuf * bp)
|
||||
lcp_Input(struct lcp *lcp, struct mbuf * bp)
|
||||
{
|
||||
/* Got PROTO_LCP from link */
|
||||
FsmInput(&lcp->fsm, bp);
|
||||
fsm_Input(&lcp->fsm, bp);
|
||||
}
|
||||
|
@ -15,7 +15,7 @@
|
||||
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* $Id: lcp.h,v 1.16.2.21 1998/04/23 03:22:56 brian Exp $
|
||||
* $Id: lcp.h,v 1.16.2.22 1998/04/30 23:53:44 brian Exp $
|
||||
*
|
||||
* TODO:
|
||||
*/
|
||||
@ -112,5 +112,5 @@ extern void lcp_Setup(struct lcp *, int);
|
||||
|
||||
extern void lcp_SendProtoRej(struct lcp *, u_char *, int);
|
||||
extern int lcp_ReportStatus(struct cmdargs const *);
|
||||
extern void LcpInput(struct lcp *, struct mbuf *);
|
||||
extern void lcp_Input(struct lcp *, struct mbuf *);
|
||||
extern void lcp_SetupCallbacks(struct lcp *);
|
||||
|
@ -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.1.2.18 1998/04/07 00:53:57 brian Exp $
|
||||
* $Id: link.c,v 1.1.2.19 1998/04/24 19:15:25 brian Exp $
|
||||
*
|
||||
*/
|
||||
|
||||
@ -61,9 +61,9 @@ link_AddOutOctets(struct link *l, int n)
|
||||
void
|
||||
link_SequenceQueue(struct link *l)
|
||||
{
|
||||
LogPrintf(LogDEBUG, "link_SequenceQueue\n");
|
||||
log_Printf(LogDEBUG, "link_SequenceQueue\n");
|
||||
while (l->Queue[PRI_NORMAL].qlen)
|
||||
Enqueue(l->Queue + PRI_LINK, Dequeue(l->Queue + PRI_NORMAL));
|
||||
mbuf_Enqueue(l->Queue + PRI_LINK, mbuf_Dequeue(l->Queue + PRI_NORMAL));
|
||||
}
|
||||
|
||||
int
|
||||
@ -88,7 +88,7 @@ link_QueueBytes(struct link *l)
|
||||
len = l->Queue[i].qlen;
|
||||
m = l->Queue[i].top;
|
||||
while (len--) {
|
||||
bytes += plength(m);
|
||||
bytes += mbuf_Length(m);
|
||||
m = m->pnext;
|
||||
}
|
||||
}
|
||||
@ -104,8 +104,8 @@ link_Dequeue(struct link *l)
|
||||
|
||||
for (bp = (struct mbuf *)0, pri = LINK_QUEUES - 1; pri >= 0; pri--)
|
||||
if (l->Queue[pri].qlen) {
|
||||
bp = Dequeue(l->Queue + pri);
|
||||
LogPrintf(LogDEBUG, "link_Dequeue: Dequeued from queue %d,"
|
||||
bp = mbuf_Dequeue(l->Queue + pri);
|
||||
log_Printf(LogDEBUG, "link_Dequeue: Dequeued from queue %d,"
|
||||
" containing %d more packets\n", pri, l->Queue[pri].qlen);
|
||||
break;
|
||||
}
|
||||
@ -125,10 +125,10 @@ link_Write(struct link *l, int pri, const char *ptr, int count)
|
||||
if(pri < 0 || pri >= LINK_QUEUES)
|
||||
pri = 0;
|
||||
|
||||
bp = mballoc(count, MB_LINK);
|
||||
bp = mbuf_Alloc(count, MB_LINK);
|
||||
memcpy(MBUF_CTOP(bp), ptr, count);
|
||||
|
||||
Enqueue(l->Queue + pri, bp);
|
||||
mbuf_Enqueue(l->Queue + pri, bp);
|
||||
}
|
||||
|
||||
void
|
||||
@ -140,10 +140,10 @@ link_Output(struct link *l, int pri, struct mbuf *bp)
|
||||
if(pri < 0 || pri >= LINK_QUEUES)
|
||||
pri = 0;
|
||||
|
||||
len = plength(bp);
|
||||
wp = mballoc(len, MB_LINK);
|
||||
mbread(bp, MBUF_CTOP(wp), len);
|
||||
Enqueue(l->Queue + pri, wp);
|
||||
len = mbuf_Length(bp);
|
||||
wp = mbuf_Alloc(len, MB_LINK);
|
||||
mbuf_Read(bp, MBUF_CTOP(wp), len);
|
||||
mbuf_Enqueue(l->Queue + pri, wp);
|
||||
}
|
||||
|
||||
static struct protostatheader {
|
||||
|
@ -23,7 +23,7 @@
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $Id: loadalias.c,v 1.14.2.3 1998/04/18 01:01:23 brian Exp $
|
||||
* $Id: loadalias.c,v 1.14.2.4 1998/04/25 10:49:16 brian Exp $
|
||||
*/
|
||||
|
||||
#include <sys/param.h>
|
||||
@ -69,7 +69,7 @@ static struct {
|
||||
struct aliasHandlers PacketAlias;
|
||||
|
||||
int
|
||||
loadAliasHandlers()
|
||||
alias_Load()
|
||||
{
|
||||
const char *path;
|
||||
const char *env;
|
||||
@ -84,7 +84,7 @@ loadAliasHandlers()
|
||||
if (ID0realuid() == 0)
|
||||
path = env;
|
||||
else
|
||||
LogPrintf(LogALERT, "Ignoring environment _PATH_ALIAS_PREFIX"
|
||||
log_Printf(LogALERT, "Ignoring environment _PATH_ALIAS_PREFIX"
|
||||
" value (%s)\n", env);
|
||||
}
|
||||
|
||||
@ -136,7 +136,7 @@ loadAliasHandlers()
|
||||
}
|
||||
}
|
||||
if (PacketAlias.dl == (void *) 0) {
|
||||
LogPrintf(LogWARN, "_PATH_ALIAS_PREFIX (%s*): Invalid lib: %s\n",
|
||||
log_Printf(LogWARN, "_PATH_ALIAS_PREFIX (%s*): Invalid lib: %s\n",
|
||||
path, dlerror());
|
||||
return -1;
|
||||
}
|
||||
@ -145,9 +145,9 @@ loadAliasHandlers()
|
||||
*(void **)((char *)&PacketAlias + map[i].offset) =
|
||||
dlsym(PacketAlias.dl, map[i].name);
|
||||
if (*(void **)((char *)&PacketAlias + map[i].offset) == (void *)0) {
|
||||
LogPrintf(LogWARN, "_PATH_ALIAS (%s*): %s: %s\n", path,
|
||||
log_Printf(LogWARN, "_PATH_ALIAS (%s*): %s: %s\n", path,
|
||||
map[i].name, dlerror());
|
||||
unloadAliasHandlers();
|
||||
alias_Unload();
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
@ -158,7 +158,7 @@ loadAliasHandlers()
|
||||
}
|
||||
|
||||
void
|
||||
unloadAliasHandlers()
|
||||
alias_Unload()
|
||||
{
|
||||
if (PacketAlias.dl) {
|
||||
dlclose(PacketAlias.dl);
|
||||
|
@ -23,7 +23,7 @@
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $Id: loadalias.h,v 1.4.2.1 1998/04/07 00:53:59 brian Exp $
|
||||
* $Id: loadalias.h,v 1.4.2.2 1998/04/07 23:45:58 brian Exp $
|
||||
*/
|
||||
|
||||
struct aliasHandlers {
|
||||
@ -44,6 +44,6 @@ struct aliasHandlers {
|
||||
|
||||
extern struct aliasHandlers PacketAlias;
|
||||
|
||||
#define AliasEnabled() (PacketAlias.dl ? 1 : 0)
|
||||
extern int loadAliasHandlers(void);
|
||||
extern void unloadAliasHandlers(void);
|
||||
#define alias_IsEnabled() (PacketAlias.dl ? 1 : 0)
|
||||
extern int alias_Load(void);
|
||||
extern void alias_Unload(void);
|
||||
|
@ -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.25.2.11 1998/04/25 10:49:20 brian Exp $
|
||||
* $Id: log.c,v 1.25.2.12 1998/04/30 23:53:45 brian Exp $
|
||||
*/
|
||||
|
||||
#include <sys/types.h>
|
||||
@ -122,20 +122,20 @@ syslogLevel(int lev)
|
||||
}
|
||||
|
||||
const char *
|
||||
LogName(int id)
|
||||
log_Name(int id)
|
||||
{
|
||||
return id < LogMIN || id > LogMAX ? "Unknown" : LogNames[id - 1];
|
||||
}
|
||||
|
||||
void
|
||||
LogKeep(int id)
|
||||
log_Keep(int id)
|
||||
{
|
||||
if (id >= LogMIN && id <= LogMAXCONF)
|
||||
LogMask |= MSK(id);
|
||||
}
|
||||
|
||||
void
|
||||
LogKeepLocal(int id, u_long *mask)
|
||||
log_KeepLocal(int id, u_long *mask)
|
||||
{
|
||||
if (id >= LogMIN && id <= LogMAXCONF) {
|
||||
LogMaskLocal |= MSK(id);
|
||||
@ -144,14 +144,14 @@ LogKeepLocal(int id, u_long *mask)
|
||||
}
|
||||
|
||||
void
|
||||
LogDiscard(int id)
|
||||
log_Discard(int id)
|
||||
{
|
||||
if (id >= LogMIN && id <= LogMAXCONF)
|
||||
LogMask &= ~MSK(id);
|
||||
}
|
||||
|
||||
void
|
||||
LogDiscardLocal(int id, u_long *mask)
|
||||
log_DiscardLocal(int id, u_long *mask)
|
||||
{
|
||||
if (id >= LogMIN && id <= LogMAXCONF) {
|
||||
*mask &= ~MSK(id);
|
||||
@ -160,20 +160,20 @@ LogDiscardLocal(int id, u_long *mask)
|
||||
}
|
||||
|
||||
void
|
||||
LogDiscardAll()
|
||||
log_DiscardAll()
|
||||
{
|
||||
LogMask = 0;
|
||||
}
|
||||
|
||||
void
|
||||
LogDiscardAllLocal(u_long *mask)
|
||||
log_DiscardAllLocal(u_long *mask)
|
||||
{
|
||||
*mask = MSK(LogERROR) | MSK(LogALERT) | MSK(LogWARN);
|
||||
LogSetMaskLocal();
|
||||
}
|
||||
|
||||
int
|
||||
LogIsKept(int id)
|
||||
log_IsKept(int id)
|
||||
{
|
||||
if (id < LogMIN || id > LogMAX)
|
||||
return 0;
|
||||
@ -185,7 +185,7 @@ LogIsKept(int id)
|
||||
}
|
||||
|
||||
int
|
||||
LogIsKeptLocal(int id, u_long mask)
|
||||
log_IsKeptLocal(int id, u_long mask)
|
||||
{
|
||||
if (id < LogMIN || id > LogMAX)
|
||||
return 0;
|
||||
@ -197,52 +197,52 @@ LogIsKeptLocal(int id, u_long mask)
|
||||
}
|
||||
|
||||
void
|
||||
LogOpen(const char *Name)
|
||||
log_Open(const char *Name)
|
||||
{
|
||||
openlog(Name, LOG_PID, LOG_DAEMON);
|
||||
}
|
||||
|
||||
void
|
||||
LogSetTun(int tunno)
|
||||
log_SetTun(int tunno)
|
||||
{
|
||||
LogTunno = tunno;
|
||||
}
|
||||
|
||||
void
|
||||
LogClose()
|
||||
log_Close()
|
||||
{
|
||||
closelog();
|
||||
LogTunno = -1;
|
||||
}
|
||||
|
||||
void
|
||||
LogPrintf(int lev, const char *fmt,...)
|
||||
log_Printf(int lev, const char *fmt,...)
|
||||
{
|
||||
va_list ap;
|
||||
struct prompt *prompt;
|
||||
|
||||
va_start(ap, fmt);
|
||||
if (LogIsKept(lev)) {
|
||||
if (log_IsKept(lev)) {
|
||||
static char nfmt[200];
|
||||
|
||||
if ((LogIsKept(lev) & LOG_KEPT_LOCAL) && logprompt) {
|
||||
if ((LogIsKept(LogTUN) & LOG_KEPT_LOCAL) && LogTunno != -1)
|
||||
if ((log_IsKept(lev) & LOG_KEPT_LOCAL) && logprompt) {
|
||||
if ((log_IsKept(LogTUN) & LOG_KEPT_LOCAL) && LogTunno != -1)
|
||||
snprintf(nfmt, sizeof nfmt, "tun%d: %s: %s",
|
||||
LogTunno, LogName(lev), fmt);
|
||||
LogTunno, log_Name(lev), fmt);
|
||||
else
|
||||
snprintf(nfmt, sizeof nfmt, "%s: %s", LogName(lev), fmt);
|
||||
snprintf(nfmt, sizeof nfmt, "%s: %s", log_Name(lev), fmt);
|
||||
|
||||
for (prompt = logprompt; prompt; prompt = prompt->lognext)
|
||||
if (lev > LogMAXCONF || (prompt->logmask & MSK(lev)))
|
||||
prompt_vPrintf(prompt, nfmt, ap);
|
||||
}
|
||||
|
||||
if ((LogIsKept(lev) & LOG_KEPT_SYSLOG) && (lev != LogWARN || !logprompt)) {
|
||||
if ((LogIsKept(LogTUN) & LOG_KEPT_SYSLOG) && LogTunno != -1)
|
||||
if ((log_IsKept(lev) & LOG_KEPT_SYSLOG) && (lev != LogWARN || !logprompt)) {
|
||||
if ((log_IsKept(LogTUN) & LOG_KEPT_SYSLOG) && LogTunno != -1)
|
||||
snprintf(nfmt, sizeof nfmt, "tun%d: %s: %s",
|
||||
LogTunno, LogName(lev), fmt);
|
||||
LogTunno, log_Name(lev), fmt);
|
||||
else
|
||||
snprintf(nfmt, sizeof nfmt, "%s: %s", LogName(lev), fmt);
|
||||
snprintf(nfmt, sizeof nfmt, "%s: %s", log_Name(lev), fmt);
|
||||
vsyslog(syslogLevel(lev), nfmt, ap);
|
||||
}
|
||||
}
|
||||
@ -250,16 +250,16 @@ LogPrintf(int lev, const char *fmt,...)
|
||||
}
|
||||
|
||||
void
|
||||
LogDumpBp(int lev, const char *hdr, const struct mbuf * bp)
|
||||
log_DumpBp(int lev, const char *hdr, const struct mbuf * bp)
|
||||
{
|
||||
if (LogIsKept(lev)) {
|
||||
if (log_IsKept(lev)) {
|
||||
char buf[50];
|
||||
char *b;
|
||||
u_char *ptr;
|
||||
int f;
|
||||
|
||||
if (hdr && *hdr)
|
||||
LogPrintf(lev, "%s\n", hdr);
|
||||
log_Printf(lev, "%s\n", hdr);
|
||||
|
||||
b = buf;
|
||||
do {
|
||||
@ -270,7 +270,7 @@ LogDumpBp(int lev, const char *hdr, const struct mbuf * bp)
|
||||
b += 3;
|
||||
if (b == buf + sizeof buf - 2) {
|
||||
strcpy(b, "\n");
|
||||
LogPrintf(lev, buf);
|
||||
log_Printf(lev, buf);
|
||||
b = buf;
|
||||
}
|
||||
}
|
||||
@ -278,26 +278,26 @@ LogDumpBp(int lev, const char *hdr, const struct mbuf * bp)
|
||||
|
||||
if (b > buf) {
|
||||
strcpy(b, "\n");
|
||||
LogPrintf(lev, buf);
|
||||
log_Printf(lev, buf);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
LogDumpBuff(int lev, const char *hdr, const u_char * ptr, int n)
|
||||
log_DumpBuff(int lev, const char *hdr, const u_char * ptr, int n)
|
||||
{
|
||||
if (LogIsKept(lev)) {
|
||||
if (log_IsKept(lev)) {
|
||||
char buf[50];
|
||||
char *b;
|
||||
|
||||
if (hdr && *hdr)
|
||||
LogPrintf(lev, "%s\n", hdr);
|
||||
log_Printf(lev, "%s\n", hdr);
|
||||
while (n > 0) {
|
||||
b = buf;
|
||||
for (b = buf; b != buf + sizeof buf - 2 && n--; b += 3)
|
||||
sprintf(b, " %02x", (int) *ptr++);
|
||||
strcpy(b, "\n");
|
||||
LogPrintf(lev, buf);
|
||||
log_Printf(lev, buf);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -309,13 +309,13 @@ log_ShowLevel(struct cmdargs const *arg)
|
||||
|
||||
prompt_Printf(arg->prompt, "Log: ");
|
||||
for (i = LogMIN; i <= LogMAX; i++)
|
||||
if (LogIsKept(i) & LOG_KEPT_SYSLOG)
|
||||
prompt_Printf(arg->prompt, " %s", LogName(i));
|
||||
if (log_IsKept(i) & LOG_KEPT_SYSLOG)
|
||||
prompt_Printf(arg->prompt, " %s", log_Name(i));
|
||||
|
||||
prompt_Printf(arg->prompt, "\nLocal:");
|
||||
for (i = LogMIN; i <= LogMAX; i++)
|
||||
if (LogIsKeptLocal(i, arg->prompt->logmask) & LOG_KEPT_LOCAL)
|
||||
prompt_Printf(arg->prompt, " %s", LogName(i));
|
||||
if (log_IsKeptLocal(i, arg->prompt->logmask) & LOG_KEPT_LOCAL)
|
||||
prompt_Printf(arg->prompt, " %s", log_Name(i));
|
||||
|
||||
prompt_Printf(arg->prompt, "\n");
|
||||
|
||||
@ -336,7 +336,7 @@ log_SetLevel(struct cmdargs const *arg)
|
||||
local = 0;
|
||||
else {
|
||||
if (arg->prompt == NULL) {
|
||||
LogPrintf(LogWARN, "set log local: Only available on the command line\n");
|
||||
log_Printf(LogWARN, "set log local: Only available on the command line\n");
|
||||
return 1;
|
||||
}
|
||||
argc--;
|
||||
@ -346,28 +346,28 @@ log_SetLevel(struct cmdargs const *arg)
|
||||
|
||||
if (argc == 0 || (argv[0][0] != '+' && argv[0][0] != '-')) {
|
||||
if (local)
|
||||
LogDiscardAllLocal(&arg->prompt->logmask);
|
||||
log_DiscardAllLocal(&arg->prompt->logmask);
|
||||
else
|
||||
LogDiscardAll();
|
||||
log_DiscardAll();
|
||||
}
|
||||
|
||||
while (argc--) {
|
||||
argp = **argv == '+' || **argv == '-' ? *argv + 1 : *argv;
|
||||
for (i = LogMIN; i <= LogMAX; i++)
|
||||
if (strcasecmp(argp, LogName(i)) == 0) {
|
||||
if (strcasecmp(argp, log_Name(i)) == 0) {
|
||||
if (**argv == '-') {
|
||||
if (local)
|
||||
LogDiscardLocal(i, &arg->prompt->logmask);
|
||||
log_DiscardLocal(i, &arg->prompt->logmask);
|
||||
else
|
||||
LogDiscard(i);
|
||||
log_Discard(i);
|
||||
} else if (local)
|
||||
LogKeepLocal(i, &arg->prompt->logmask);
|
||||
log_KeepLocal(i, &arg->prompt->logmask);
|
||||
else
|
||||
LogKeep(i);
|
||||
log_Keep(i);
|
||||
break;
|
||||
}
|
||||
if (i > LogMAX) {
|
||||
LogPrintf(LogWARN, "%s: Invalid log value\n", argp);
|
||||
log_Printf(LogWARN, "%s: Invalid log value\n", argp);
|
||||
res = -1;
|
||||
}
|
||||
argv++;
|
||||
|
@ -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.18.2.5 1998/04/24 19:15:44 brian Exp $
|
||||
* $Id: log.h,v 1.18.2.6 1998/04/30 23:53:47 brian Exp $
|
||||
*/
|
||||
|
||||
#define LogMIN (1)
|
||||
@ -53,28 +53,28 @@ struct cmdargs;
|
||||
struct prompt;
|
||||
|
||||
/* The first int arg for all of the following is one of the above values */
|
||||
extern const char *LogName(int);
|
||||
extern void LogKeep(int);
|
||||
extern void LogKeepLocal(int, u_long *);
|
||||
extern void LogDiscard(int);
|
||||
extern void LogDiscardLocal(int, u_long *);
|
||||
extern void LogDiscardAll(void);
|
||||
extern void LogDiscardAllLocal(u_long *);
|
||||
#define LOG_KEPT_SYSLOG (1) /* Results of LogIsKept() */
|
||||
#define LOG_KEPT_LOCAL (2) /* Results of LogIsKept() */
|
||||
extern int LogIsKept(int);
|
||||
extern int LogIsKeptLocal(int, u_long);
|
||||
extern void LogOpen(const char *);
|
||||
extern void LogSetTun(int);
|
||||
extern void LogClose(void);
|
||||
extern const char *log_Name(int);
|
||||
extern void log_Keep(int);
|
||||
extern void log_KeepLocal(int, u_long *);
|
||||
extern void log_Discard(int);
|
||||
extern void log_DiscardLocal(int, u_long *);
|
||||
extern void log_DiscardAll(void);
|
||||
extern void log_DiscardAllLocal(u_long *);
|
||||
#define LOG_KEPT_SYSLOG (1) /* Results of log_IsKept() */
|
||||
#define LOG_KEPT_LOCAL (2) /* Results of log_IsKept() */
|
||||
extern int log_IsKept(int);
|
||||
extern int log_IsKeptLocal(int, u_long);
|
||||
extern void log_Open(const char *);
|
||||
extern void log_SetTun(int);
|
||||
extern void log_Close(void);
|
||||
#ifdef __GNUC__
|
||||
extern void LogPrintf(int, const char *,...)
|
||||
extern void log_Printf(int, const char *,...)
|
||||
__attribute__ ((format (printf, 2, 3)));
|
||||
#else
|
||||
extern void LogPrintf(int, const char *,...);
|
||||
extern void log_Printf(int, const char *,...);
|
||||
#endif
|
||||
extern void LogDumpBp(int, const char *, const struct mbuf *);
|
||||
extern void LogDumpBuff(int, const char *, const u_char *, int);
|
||||
extern void log_DumpBp(int, const char *, const struct mbuf *);
|
||||
extern void log_DumpBuff(int, const char *, const u_char *, int);
|
||||
extern void log_RegisterPrompt(struct prompt *);
|
||||
extern void log_UnRegisterPrompt(struct prompt *);
|
||||
extern int log_ShowLevel(struct cmdargs const *);
|
||||
|
@ -17,7 +17,7 @@
|
||||
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* $Id: lqr.c,v 1.22.2.27 1998/04/24 19:16:06 brian Exp $
|
||||
* $Id: lqr.c,v 1.22.2.28 1998/04/28 01:25:28 brian Exp $
|
||||
*
|
||||
* o LQR based on RFC1333
|
||||
*
|
||||
@ -71,18 +71,18 @@ SendEchoReq(struct lcp *lcp)
|
||||
echo.magic = htonl(lcp->want_magic);
|
||||
echo.signature = htonl(SIGNATURE);
|
||||
echo.sequence = htonl(hdlc->lqm.echo.seq_sent);
|
||||
FsmOutput(&lcp->fsm, CODE_ECHOREQ, hdlc->lqm.echo.seq_sent++,
|
||||
fsm_Output(&lcp->fsm, CODE_ECHOREQ, hdlc->lqm.echo.seq_sent++,
|
||||
(u_char *)&echo, sizeof echo);
|
||||
}
|
||||
|
||||
void
|
||||
RecvEchoLqr(struct fsm *fp, struct mbuf * bp)
|
||||
lqr_RecvEcho(struct fsm *fp, struct mbuf * bp)
|
||||
{
|
||||
struct hdlc *hdlc = &link2physical(fp->link)->hdlc;
|
||||
struct echolqr *lqr;
|
||||
u_int32_t seq;
|
||||
|
||||
if (plength(bp) == sizeof(struct echolqr)) {
|
||||
if (mbuf_Length(bp) == sizeof(struct echolqr)) {
|
||||
lqr = (struct echolqr *) MBUF_CTOP(bp);
|
||||
if (ntohl(lqr->signature) == SIGNATURE) {
|
||||
seq = ntohl(lqr->sequence);
|
||||
@ -92,15 +92,15 @@ RecvEchoLqr(struct fsm *fp, struct mbuf * bp)
|
||||
seq > hdlc->lqm.echo.seq_recv))
|
||||
hdlc->lqm.echo.seq_recv = seq;
|
||||
} else
|
||||
LogPrintf(LogERROR, "RecvEchoLqr: Got sig 0x%08x, expecting 0x%08x !\n",
|
||||
log_Printf(LogERROR, "lqr_RecvEcho: Got sig 0x%08x, expecting 0x%08x !\n",
|
||||
(unsigned)ntohl(lqr->signature), (unsigned)SIGNATURE);
|
||||
} else
|
||||
LogPrintf(LogERROR, "RecvEchoLqr: Got packet size %d, expecting %d !\n",
|
||||
plength(bp), sizeof(struct echolqr));
|
||||
log_Printf(LogERROR, "lqr_RecvEcho: Got packet size %d, expecting %d !\n",
|
||||
mbuf_Length(bp), sizeof(struct echolqr));
|
||||
}
|
||||
|
||||
void
|
||||
LqrChangeOrder(struct lqrdata * src, struct lqrdata * dst)
|
||||
lqr_ChangeOrder(struct lqrdata * src, struct lqrdata * dst)
|
||||
{
|
||||
u_long *sp, *dp;
|
||||
int n;
|
||||
@ -116,8 +116,8 @@ SendLqrData(struct lcp *lcp)
|
||||
{
|
||||
struct mbuf *bp;
|
||||
|
||||
bp = mballoc(sizeof(struct lqrdata), MB_LQR);
|
||||
HdlcOutput(lcp->fsm.link, PRI_LINK, PROTO_LQR, bp);
|
||||
bp = mbuf_Alloc(sizeof(struct lqrdata), MB_LQR);
|
||||
hdlc_Output(lcp->fsm.link, PRI_LINK, PROTO_LQR, bp);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -126,14 +126,14 @@ SendLqrReport(void *v)
|
||||
struct lcp *lcp = (struct lcp *)v;
|
||||
struct physical *p = link2physical(lcp->fsm.link);
|
||||
|
||||
StopTimer(&p->hdlc.lqm.timer);
|
||||
timer_Stop(&p->hdlc.lqm.timer);
|
||||
|
||||
if (p->hdlc.lqm.method & LQM_LQR) {
|
||||
if (p->hdlc.lqm.lqr.resent > 5) {
|
||||
/* XXX: Should implement LQM strategy */
|
||||
LogPrintf(LogPHASE, "%s: ** Too many LQR packets lost **\n",
|
||||
log_Printf(LogPHASE, "%s: ** Too many LQR packets lost **\n",
|
||||
lcp->fsm.link->name);
|
||||
LogPrintf(LogLQM, "%s: Too many LQR packets lost\n",
|
||||
log_Printf(LogLQM, "%s: Too many LQR packets lost\n",
|
||||
lcp->fsm.link->name);
|
||||
p->hdlc.lqm.method = 0;
|
||||
datalink_Down(p->dl, 0);
|
||||
@ -146,9 +146,9 @@ SendLqrReport(void *v)
|
||||
p->hdlc.lqm.echo.seq_sent - 5 > p->hdlc.lqm.echo.seq_recv) ||
|
||||
(p->hdlc.lqm.echo.seq_sent <= 5 &&
|
||||
p->hdlc.lqm.echo.seq_sent > p->hdlc.lqm.echo.seq_recv + 5)) {
|
||||
LogPrintf(LogPHASE, "%s: ** Too many ECHO LQR packets lost **\n",
|
||||
log_Printf(LogPHASE, "%s: ** Too many ECHO LQR packets lost **\n",
|
||||
lcp->fsm.link->name);
|
||||
LogPrintf(LogLQM, "%s: Too many ECHO LQR packets lost\n",
|
||||
log_Printf(LogLQM, "%s: Too many ECHO LQR packets lost\n",
|
||||
lcp->fsm.link->name);
|
||||
p->hdlc.lqm.method = 0;
|
||||
datalink_Down(p->dl, 0);
|
||||
@ -156,17 +156,17 @@ SendLqrReport(void *v)
|
||||
SendEchoReq(lcp);
|
||||
}
|
||||
if (p->hdlc.lqm.method && p->hdlc.lqm.timer.load)
|
||||
StartTimer(&p->hdlc.lqm.timer);
|
||||
timer_Start(&p->hdlc.lqm.timer);
|
||||
}
|
||||
|
||||
void
|
||||
LqrInput(struct physical *physical, struct mbuf *bp)
|
||||
lqr_Input(struct physical *physical, struct mbuf *bp)
|
||||
{
|
||||
int len;
|
||||
|
||||
len = plength(bp);
|
||||
len = mbuf_Length(bp);
|
||||
if (len != sizeof(struct lqrdata))
|
||||
LogPrintf(LogERROR, "LqrInput: Got packet size %d, expecting %d !\n",
|
||||
log_Printf(LogERROR, "lqr_Input: Got packet size %d, expecting %d !\n",
|
||||
len, sizeof(struct lqrdata));
|
||||
else if (!IsAccepted(physical->link.lcp.cfg.lqr) &&
|
||||
!(physical->hdlc.lqm.method & LQM_LQR)) {
|
||||
@ -181,7 +181,7 @@ LqrInput(struct physical *physical, struct mbuf *bp)
|
||||
lqr = (struct lqrdata *)MBUF_CTOP(bp);
|
||||
lcp = physical->hdlc.lqm.owner;
|
||||
if (ntohl(lqr->MagicNumber) != physical->hdlc.lqm.owner->his_magic)
|
||||
LogPrintf(LogERROR, "LqrInput: magic %x != expecting %x\n",
|
||||
log_Printf(LogERROR, "lqr_Input: magic %x != expecting %x\n",
|
||||
(unsigned)ntohl(lqr->MagicNumber),
|
||||
physical->hdlc.lqm.owner->his_magic);
|
||||
else {
|
||||
@ -190,8 +190,8 @@ LqrInput(struct physical *physical, struct mbuf *bp)
|
||||
*/
|
||||
lastLQR = physical->hdlc.lqm.lqr.peer.PeerInLQRs;
|
||||
|
||||
LqrChangeOrder(lqr, &physical->hdlc.lqm.lqr.peer);
|
||||
LqrDump(physical->link.name, "Input", &physical->hdlc.lqm.lqr.peer);
|
||||
lqr_ChangeOrder(lqr, &physical->hdlc.lqm.lqr.peer);
|
||||
lqr_Dump(physical->link.name, "Input", &physical->hdlc.lqm.lqr.peer);
|
||||
/* we have received an LQR from peer */
|
||||
physical->hdlc.lqm.lqr.resent = 0;
|
||||
|
||||
@ -209,14 +209,14 @@ LqrInput(struct physical *physical, struct mbuf *bp)
|
||||
SendLqrData(physical->hdlc.lqm.owner);
|
||||
}
|
||||
}
|
||||
pfree(bp);
|
||||
mbuf_Free(bp);
|
||||
}
|
||||
|
||||
/*
|
||||
* When LCP is reached to opened state, We'll start LQM activity.
|
||||
*/
|
||||
void
|
||||
StartLqm(struct lcp *lcp)
|
||||
lqr_Start(struct lcp *lcp)
|
||||
{
|
||||
struct physical *physical = link2physical(lcp->fsm.link);
|
||||
|
||||
@ -229,15 +229,15 @@ StartLqm(struct lcp *lcp)
|
||||
physical->hdlc.lqm.method = LQM_ECHO;
|
||||
if (IsEnabled(physical->link.lcp.cfg.lqr) && !REJECTED(lcp, TY_QUALPROTO))
|
||||
physical->hdlc.lqm.method |= LQM_LQR;
|
||||
StopTimer(&physical->hdlc.lqm.timer);
|
||||
timer_Stop(&physical->hdlc.lqm.timer);
|
||||
|
||||
physical->hdlc.lqm.lqr.peer_timeout = lcp->his_lqrperiod;
|
||||
if (lcp->his_lqrperiod)
|
||||
LogPrintf(LogLQM, "Expecting LQR every %d.%02d secs\n",
|
||||
log_Printf(LogLQM, "Expecting LQR every %d.%02d secs\n",
|
||||
lcp->his_lqrperiod / 100, lcp->his_lqrperiod % 100);
|
||||
|
||||
if (lcp->want_lqrperiod) {
|
||||
LogPrintf(LogLQM, "Will send %s every %d.%02d secs\n",
|
||||
log_Printf(LogLQM, "Will send %s every %d.%02d secs\n",
|
||||
physical->hdlc.lqm.method & LQM_LQR ? "LQR" : "ECHO LQR",
|
||||
lcp->want_lqrperiod / 100, lcp->want_lqrperiod % 100);
|
||||
physical->hdlc.lqm.timer.load = lcp->want_lqrperiod * SECTICKS / 100;
|
||||
@ -248,48 +248,48 @@ StartLqm(struct lcp *lcp)
|
||||
} else {
|
||||
physical->hdlc.lqm.timer.load = 0;
|
||||
if (!lcp->his_lqrperiod)
|
||||
LogPrintf(LogLQM, "LQR/ECHO LQR not negotiated\n");
|
||||
log_Printf(LogLQM, "LQR/ECHO LQR not negotiated\n");
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
StopLqrTimer(struct physical *physical)
|
||||
lqr_StopTimer(struct physical *physical)
|
||||
{
|
||||
StopTimer(&physical->hdlc.lqm.timer);
|
||||
timer_Stop(&physical->hdlc.lqm.timer);
|
||||
}
|
||||
|
||||
void
|
||||
StopLqr(struct physical *physical, int method)
|
||||
lqr_Stop(struct physical *physical, int method)
|
||||
{
|
||||
LogPrintf(LogLQM, "StopLqr method = %x\n", method);
|
||||
log_Printf(LogLQM, "lqr_Stop method = %x\n", method);
|
||||
|
||||
if (method == LQM_LQR)
|
||||
LogPrintf(LogLQM, "Stop sending LQR, Use LCP ECHO instead.\n");
|
||||
log_Printf(LogLQM, "Stop sending LQR, Use LCP ECHO instead.\n");
|
||||
if (method == LQM_ECHO)
|
||||
LogPrintf(LogLQM, "Stop sending LCP ECHO.\n");
|
||||
log_Printf(LogLQM, "Stop sending LCP ECHO.\n");
|
||||
physical->hdlc.lqm.method &= ~method;
|
||||
if (physical->hdlc.lqm.method)
|
||||
SendLqrReport(physical->hdlc.lqm.owner);
|
||||
else
|
||||
StopTimer(&physical->hdlc.lqm.timer);
|
||||
timer_Stop(&physical->hdlc.lqm.timer);
|
||||
}
|
||||
|
||||
void
|
||||
LqrDump(const char *link, const char *message, const struct lqrdata * lqr)
|
||||
lqr_Dump(const char *link, const char *message, const struct lqrdata * lqr)
|
||||
{
|
||||
if (LogIsKept(LogLQM)) {
|
||||
LogPrintf(LogLQM, "%s: %s:\n", link, message);
|
||||
LogPrintf(LogLQM, " Magic: %08x LastOutLQRs: %08x\n",
|
||||
if (log_IsKept(LogLQM)) {
|
||||
log_Printf(LogLQM, "%s: %s:\n", link, message);
|
||||
log_Printf(LogLQM, " Magic: %08x LastOutLQRs: %08x\n",
|
||||
lqr->MagicNumber, lqr->LastOutLQRs);
|
||||
LogPrintf(LogLQM, " LastOutPackets: %08x LastOutOctets: %08x\n",
|
||||
log_Printf(LogLQM, " LastOutPackets: %08x LastOutOctets: %08x\n",
|
||||
lqr->LastOutPackets, lqr->LastOutOctets);
|
||||
LogPrintf(LogLQM, " PeerInLQRs: %08x PeerInPackets: %08x\n",
|
||||
log_Printf(LogLQM, " PeerInLQRs: %08x PeerInPackets: %08x\n",
|
||||
lqr->PeerInLQRs, lqr->PeerInPackets);
|
||||
LogPrintf(LogLQM, " PeerInDiscards: %08x PeerInErrors: %08x\n",
|
||||
log_Printf(LogLQM, " PeerInDiscards: %08x PeerInErrors: %08x\n",
|
||||
lqr->PeerInDiscards, lqr->PeerInErrors);
|
||||
LogPrintf(LogLQM, " PeerInOctets: %08x PeerOutLQRs: %08x\n",
|
||||
log_Printf(LogLQM, " PeerInOctets: %08x PeerOutLQRs: %08x\n",
|
||||
lqr->PeerInOctets, lqr->PeerOutLQRs);
|
||||
LogPrintf(LogLQM, " PeerOutPackets: %08x PeerOutOctets: %08x\n",
|
||||
log_Printf(LogLQM, " PeerOutPackets: %08x PeerOutOctets: %08x\n",
|
||||
lqr->PeerOutPackets, lqr->PeerOutOctets);
|
||||
}
|
||||
}
|
||||
|
@ -15,7 +15,7 @@
|
||||
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* $Id: lqr.h,v 1.12.2.3 1998/04/07 00:54:02 brian Exp $
|
||||
* $Id: lqr.h,v 1.12.2.4 1998/04/24 19:16:07 brian Exp $
|
||||
*
|
||||
* TODO:
|
||||
*/
|
||||
@ -49,10 +49,10 @@ struct physical;
|
||||
struct lcp;
|
||||
struct fsm;
|
||||
|
||||
extern void LqrDump(const char *, const char *, const struct lqrdata *);
|
||||
extern void LqrChangeOrder(struct lqrdata *, struct lqrdata *);
|
||||
extern void StartLqm(struct lcp *);
|
||||
extern void StopLqr(struct physical *, int);
|
||||
extern void StopLqrTimer(struct physical *);
|
||||
extern void RecvEchoLqr(struct fsm *, struct mbuf *);
|
||||
extern void LqrInput(struct physical *, struct mbuf *);
|
||||
extern void lqr_Dump(const char *, const char *, const struct lqrdata *);
|
||||
extern void lqr_ChangeOrder(struct lqrdata *, struct lqrdata *);
|
||||
extern void lqr_Start(struct lcp *);
|
||||
extern void lqr_Stop(struct physical *, int);
|
||||
extern void lqr_StopTimer(struct physical *);
|
||||
extern void lqr_RecvEcho(struct fsm *, struct mbuf *);
|
||||
extern void lqr_Input(struct physical *, struct mbuf *);
|
||||
|
@ -17,7 +17,7 @@
|
||||
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* $Id: main.c,v 1.121.2.52 1998/04/28 01:25:30 brian Exp $
|
||||
* $Id: main.c,v 1.121.2.53 1998/04/30 23:53:48 brian Exp $
|
||||
*
|
||||
* TODO:
|
||||
*/
|
||||
@ -64,7 +64,6 @@
|
||||
#include "ip.h"
|
||||
#include "sig.h"
|
||||
#include "main.h"
|
||||
#include "pathnames.h"
|
||||
#include "tun.h"
|
||||
#include "server.h"
|
||||
#include "prompt.h"
|
||||
@ -98,12 +97,12 @@ Cleanup(int excode)
|
||||
void
|
||||
AbortProgram(int excode)
|
||||
{
|
||||
ServerClose(SignalBundle);
|
||||
server_Close(SignalBundle);
|
||||
ID0unlink(pid_filename);
|
||||
LogPrintf(LogPHASE, "PPP Terminated (%s).\n", ex_desc(excode));
|
||||
log_Printf(LogPHASE, "PPP Terminated (%s).\n", ex_desc(excode));
|
||||
bundle_Close(SignalBundle, NULL, 1);
|
||||
bundle_Destroy(SignalBundle);
|
||||
LogClose();
|
||||
log_Close();
|
||||
exit(excode);
|
||||
}
|
||||
|
||||
@ -113,17 +112,17 @@ CloseConnection(int signo)
|
||||
/* NOTE, these are manual, we've done a setsid() */
|
||||
struct datalink *dl;
|
||||
|
||||
pending_signal(SIGINT, SIG_IGN);
|
||||
LogPrintf(LogPHASE, "Caught signal %d, abort connection(s)\n", signo);
|
||||
sig_signal(SIGINT, SIG_IGN);
|
||||
log_Printf(LogPHASE, "Caught signal %d, abort connection(s)\n", signo);
|
||||
for (dl = SignalBundle->links; dl; dl = dl->next)
|
||||
datalink_Down(dl, 1);
|
||||
pending_signal(SIGINT, CloseConnection);
|
||||
sig_signal(SIGINT, CloseConnection);
|
||||
}
|
||||
|
||||
static void
|
||||
CloseSession(int signo)
|
||||
{
|
||||
LogPrintf(LogPHASE, "Signal %d, terminate.\n", signo);
|
||||
log_Printf(LogPHASE, "Signal %d, terminate.\n", signo);
|
||||
Cleanup(EX_TERM);
|
||||
}
|
||||
|
||||
@ -132,7 +131,7 @@ static pid_t BGPid = 0;
|
||||
static void
|
||||
KillChild(int signo)
|
||||
{
|
||||
LogPrintf(LogPHASE, "Parent: Signal %d\n", signo);
|
||||
log_Printf(LogPHASE, "Parent: Signal %d\n", signo);
|
||||
kill(BGPid, SIGINT);
|
||||
}
|
||||
|
||||
@ -160,7 +159,7 @@ SetUpServer(int signo)
|
||||
VarHaveLocalAuthKey = 0;
|
||||
LocalAuthInit();
|
||||
if ((res = ServerTcpOpen(SERVER_PORT + SignalBundle->unit)) != 0)
|
||||
LogPrintf(LogERROR, "SIGUSR1: Failed %d to open port %d\n",
|
||||
log_Printf(LogERROR, "SIGUSR1: Failed %d to open port %d\n",
|
||||
res, SERVER_PORT + SignalBundle->unit);
|
||||
}
|
||||
#endif
|
||||
@ -169,7 +168,7 @@ static void
|
||||
BringDownServer(int signo)
|
||||
{
|
||||
/* Drops all child prompts too ! */
|
||||
ServerClose(SignalBundle);
|
||||
server_Close(SignalBundle);
|
||||
}
|
||||
|
||||
static const char *
|
||||
@ -224,9 +223,9 @@ ProcessArgs(int argc, char **argv, int *mode)
|
||||
labelrequired = 1;
|
||||
} else if (strcmp(cp, "alias") == 0) {
|
||||
#ifndef NOALIAS
|
||||
if (loadAliasHandlers() != 0)
|
||||
if (alias_Load() != 0)
|
||||
#endif
|
||||
LogPrintf(LogWARN, "Cannot load alias library\n");
|
||||
log_Printf(LogWARN, "Cannot load alias library\n");
|
||||
optc--; /* this option isn't exclusive */
|
||||
} else
|
||||
Usage();
|
||||
@ -273,7 +272,7 @@ main(int argc, char **argv)
|
||||
close(nfds);
|
||||
|
||||
name = strrchr(argv[0], '/');
|
||||
LogOpen(name ? name + 1 : argv[0]);
|
||||
log_Open(name ? name + 1 : argv[0]);
|
||||
|
||||
argc--;
|
||||
argv++;
|
||||
@ -327,7 +326,7 @@ main(int argc, char **argv)
|
||||
snprintf(conf, sizeof conf, "%s/%s", _PATH_PPP, CONFFILE);
|
||||
do {
|
||||
if (!access(conf, W_OK)) {
|
||||
LogPrintf(LogALERT, "ppp: Access violation: Please protect %s\n", conf);
|
||||
log_Printf(LogALERT, "ppp: Access violation: Please protect %s\n", conf);
|
||||
return -1;
|
||||
}
|
||||
ptr = conf + strlen(conf)-2;
|
||||
@ -336,50 +335,50 @@ main(int argc, char **argv)
|
||||
} while (ptr >= conf);
|
||||
}
|
||||
|
||||
if (!ValidSystem(label, prompt, mode)) {
|
||||
if (!system_IsValid(label, prompt, mode)) {
|
||||
fprintf(stderr, "You may not use ppp in this mode with this label\n");
|
||||
if (mode == PHYS_DIRECT) {
|
||||
const char *l;
|
||||
l = label ? label : "default";
|
||||
LogPrintf(LogWARN, "Label %s rejected -direct connection\n", l);
|
||||
log_Printf(LogWARN, "Label %s rejected -direct connection\n", l);
|
||||
}
|
||||
LogClose();
|
||||
log_Close();
|
||||
return 1;
|
||||
}
|
||||
|
||||
if ((bundle = bundle_Create(TUN_PREFIX, prompt, mode)) == NULL) {
|
||||
LogPrintf(LogWARN, "bundle_Create: %s\n", strerror(errno));
|
||||
log_Printf(LogWARN, "bundle_Create: %s\n", strerror(errno));
|
||||
return EX_START;
|
||||
}
|
||||
SignalBundle = bundle;
|
||||
|
||||
if (SelectSystem(bundle, "default", CONFFILE, prompt) < 0)
|
||||
if (system_Select(bundle, "default", CONFFILE, prompt) < 0)
|
||||
prompt_Printf(prompt, "Warning: No default entry found in config file.\n");
|
||||
|
||||
pending_signal(SIGHUP, CloseSession);
|
||||
pending_signal(SIGTERM, CloseSession);
|
||||
pending_signal(SIGINT, CloseConnection);
|
||||
pending_signal(SIGQUIT, CloseSession);
|
||||
pending_signal(SIGALRM, SIG_IGN);
|
||||
sig_signal(SIGHUP, CloseSession);
|
||||
sig_signal(SIGTERM, CloseSession);
|
||||
sig_signal(SIGINT, CloseConnection);
|
||||
sig_signal(SIGQUIT, CloseSession);
|
||||
sig_signal(SIGALRM, SIG_IGN);
|
||||
signal(SIGPIPE, SIG_IGN);
|
||||
|
||||
if (mode == PHYS_MANUAL)
|
||||
pending_signal(SIGTSTP, TerminalStop);
|
||||
sig_signal(SIGTSTP, TerminalStop);
|
||||
|
||||
#if 0 /* What's our passwd :-O */
|
||||
pending_signal(SIGUSR1, SetUpServer);
|
||||
sig_signal(SIGUSR1, SetUpServer);
|
||||
#endif
|
||||
pending_signal(SIGUSR2, BringDownServer);
|
||||
sig_signal(SIGUSR2, BringDownServer);
|
||||
|
||||
if (label) {
|
||||
/*
|
||||
* Set label both before and after SelectSystem !
|
||||
* This way, "set enddisc label" works during SelectSystem, and we
|
||||
* Set label both before and after system_Select !
|
||||
* This way, "set enddisc label" works during system_Select, and we
|
||||
* also end up with the correct label if we have embedded load
|
||||
* commands.
|
||||
*/
|
||||
bundle_SetLabel(bundle, label);
|
||||
if (SelectSystem(bundle, label, CONFFILE, prompt) < 0) {
|
||||
if (system_Select(bundle, label, CONFFILE, prompt) < 0) {
|
||||
prompt_Printf(prompt, "Destination system (%s) not found.\n", label);
|
||||
AbortProgram(EX_START);
|
||||
}
|
||||
@ -398,13 +397,13 @@ main(int argc, char **argv)
|
||||
pid_t bgpid;
|
||||
|
||||
if (mode == PHYS_1OFF && pipe(bgpipe)) {
|
||||
LogPrintf(LogERROR, "pipe: %s\n", strerror(errno));
|
||||
log_Printf(LogERROR, "pipe: %s\n", strerror(errno));
|
||||
AbortProgram(EX_SOCK);
|
||||
}
|
||||
|
||||
bgpid = fork();
|
||||
if (bgpid == -1) {
|
||||
LogPrintf(LogERROR, "fork: %s\n", strerror(errno));
|
||||
log_Printf(LogERROR, "fork: %s\n", strerror(errno));
|
||||
AbortProgram(EX_SOCK);
|
||||
}
|
||||
|
||||
@ -423,13 +422,13 @@ main(int argc, char **argv)
|
||||
/* Wait for our child to close its pipe before we exit */
|
||||
if (read(bgpipe[0], &c, 1) != 1) {
|
||||
prompt_Printf(prompt, "Child exit, no status.\n");
|
||||
LogPrintf(LogPHASE, "Parent: Child exit, no status.\n");
|
||||
log_Printf(LogPHASE, "Parent: Child exit, no status.\n");
|
||||
} else if (c == EX_NORMAL) {
|
||||
prompt_Printf(prompt, "PPP enabled.\n");
|
||||
LogPrintf(LogPHASE, "Parent: PPP enabled.\n");
|
||||
log_Printf(LogPHASE, "Parent: PPP enabled.\n");
|
||||
} else {
|
||||
prompt_Printf(prompt, "Child failed (%s).\n", ex_desc((int) c));
|
||||
LogPrintf(LogPHASE, "Parent: Child failed (%s).\n",
|
||||
log_Printf(LogPHASE, "Parent: Child failed (%s).\n",
|
||||
ex_desc((int) c));
|
||||
}
|
||||
close(bgpipe[0]);
|
||||
@ -469,11 +468,11 @@ main(int argc, char **argv)
|
||||
}
|
||||
#ifndef RELEASE_CRUNCH
|
||||
else
|
||||
LogPrintf(LogALERT, "Warning: Can't create %s: %s\n",
|
||||
log_Printf(LogALERT, "Warning: Can't create %s: %s\n",
|
||||
pid_filename, strerror(errno));
|
||||
#endif
|
||||
|
||||
LogPrintf(LogPHASE, "PPP Started (%s mode).\n", mode2Nam(mode));
|
||||
log_Printf(LogPHASE, "PPP Started (%s mode).\n", mode2Nam(mode));
|
||||
DoLoop(bundle, prompt);
|
||||
AbortProgram(EX_NORMAL);
|
||||
|
||||
@ -496,7 +495,7 @@ DoLoop(struct bundle *bundle, struct prompt *prompt)
|
||||
|
||||
qlen = bundle_FillQueues(bundle);
|
||||
|
||||
handle_signals();
|
||||
sig_Handle();
|
||||
|
||||
/* This one comes first 'cos it may nuke a datalink */
|
||||
descriptor_UpdateSet(&bundle->ncp.mp.server.desc, &rfds, &wfds,
|
||||
@ -522,16 +521,16 @@ DoLoop(struct bundle *bundle, struct prompt *prompt)
|
||||
|
||||
if (i < 0) {
|
||||
if (errno == EINTR) {
|
||||
handle_signals();
|
||||
sig_Handle();
|
||||
continue;
|
||||
}
|
||||
LogPrintf(LogERROR, "DoLoop: select(): %s\n", strerror(errno));
|
||||
log_Printf(LogERROR, "DoLoop: select(): %s\n", strerror(errno));
|
||||
break;
|
||||
}
|
||||
|
||||
for (i = 0; i <= nfds; i++)
|
||||
if (FD_ISSET(i, &efds)) {
|
||||
LogPrintf(LogALERT, "Exception detected on descriptor %d\n", i);
|
||||
log_Printf(LogALERT, "Exception detected on descriptor %d\n", i);
|
||||
break;
|
||||
}
|
||||
|
||||
@ -551,12 +550,12 @@ DoLoop(struct bundle *bundle, struct prompt *prompt)
|
||||
/* something to read from tun */
|
||||
n = read(bundle->tun_fd, &tun, sizeof tun);
|
||||
if (n < 0) {
|
||||
LogPrintf(LogERROR, "read from tun: %s\n", strerror(errno));
|
||||
log_Printf(LogERROR, "read from tun: %s\n", strerror(errno));
|
||||
continue;
|
||||
}
|
||||
n -= sizeof tun - sizeof tun.data;
|
||||
if (n <= 0) {
|
||||
LogPrintf(LogERROR, "read from tun: Only %d bytes read\n", n);
|
||||
log_Printf(LogERROR, "read from tun: Only %d bytes read\n", n);
|
||||
continue;
|
||||
}
|
||||
if (!tun_check_header(tun, AF_INET))
|
||||
@ -570,19 +569,19 @@ DoLoop(struct bundle *bundle, struct prompt *prompt)
|
||||
struct mbuf *bp;
|
||||
|
||||
#ifndef NOALIAS
|
||||
if (AliasEnabled()) {
|
||||
if (alias_IsEnabled()) {
|
||||
(*PacketAlias.In)(tun.data, sizeof tun.data);
|
||||
n = ntohs(((struct ip *)tun.data)->ip_len);
|
||||
}
|
||||
#endif
|
||||
bp = mballoc(n, MB_IPIN);
|
||||
bp = mbuf_Alloc(n, MB_IPIN);
|
||||
memcpy(MBUF_CTOP(bp), tun.data, n);
|
||||
IpInput(bundle, bp);
|
||||
LogPrintf(LogDEBUG, "Looped back packet addressed to myself\n");
|
||||
ip_Input(bundle, bp);
|
||||
log_Printf(LogDEBUG, "Looped back packet addressed to myself\n");
|
||||
}
|
||||
continue;
|
||||
} else
|
||||
LogPrintf(LogDEBUG, "Oops - forwarding packet addressed to myself\n");
|
||||
log_Printf(LogDEBUG, "Oops - forwarding packet addressed to myself\n");
|
||||
}
|
||||
|
||||
/*
|
||||
@ -610,15 +609,15 @@ DoLoop(struct bundle *bundle, struct prompt *prompt)
|
||||
pri = PacketCheck(bundle, tun.data, n, &bundle->filter.out);
|
||||
if (pri >= 0) {
|
||||
#ifndef NOALIAS
|
||||
if (AliasEnabled()) {
|
||||
if (alias_IsEnabled()) {
|
||||
(*PacketAlias.Out)(tun.data, sizeof tun.data);
|
||||
n = ntohs(((struct ip *)tun.data)->ip_len);
|
||||
}
|
||||
#endif
|
||||
IpEnqueue(pri, tun.data, n);
|
||||
ip_Enqueue(pri, tun.data, n);
|
||||
}
|
||||
}
|
||||
} while (bundle_CleanDatalinks(bundle), !bundle_IsDead(bundle));
|
||||
|
||||
LogPrintf(LogDEBUG, "DoLoop done.\n");
|
||||
log_Printf(LogDEBUG, "DoLoop done.\n");
|
||||
}
|
||||
|
@ -17,7 +17,7 @@
|
||||
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* $Id: mbuf.c,v 1.13.2.9 1998/04/07 00:54:09 brian Exp $
|
||||
* $Id: mbuf.c,v 1.13.2.10 1998/04/07 01:29:43 brian Exp $
|
||||
*
|
||||
*/
|
||||
#include <sys/types.h>
|
||||
@ -43,7 +43,7 @@ static struct memmap {
|
||||
static int totalalloced;
|
||||
|
||||
int
|
||||
plength(struct mbuf * bp)
|
||||
mbuf_Length(struct mbuf * bp)
|
||||
{
|
||||
int len;
|
||||
|
||||
@ -53,22 +53,22 @@ plength(struct mbuf * bp)
|
||||
}
|
||||
|
||||
struct mbuf *
|
||||
mballoc(int cnt, int type)
|
||||
mbuf_Alloc(int cnt, int type)
|
||||
{
|
||||
u_char *p;
|
||||
struct mbuf *bp;
|
||||
|
||||
if (type > MB_MAX)
|
||||
LogPrintf(LogERROR, "Bad mbuf type %d\n", type);
|
||||
log_Printf(LogERROR, "Bad mbuf type %d\n", type);
|
||||
bp = (struct mbuf *) malloc(sizeof(struct mbuf));
|
||||
if (bp == NULL) {
|
||||
LogPrintf(LogALERT, "failed to allocate memory: %u\n", sizeof(struct mbuf));
|
||||
log_Printf(LogALERT, "failed to allocate memory: %u\n", sizeof(struct mbuf));
|
||||
AbortProgram(EX_OSERR);
|
||||
}
|
||||
memset(bp, '\0', sizeof(struct mbuf));
|
||||
p = (u_char *) malloc(cnt);
|
||||
if (p == NULL) {
|
||||
LogPrintf(LogALERT, "failed to allocate memory: %d\n", cnt);
|
||||
log_Printf(LogALERT, "failed to allocate memory: %d\n", cnt);
|
||||
AbortProgram(EX_OSERR);
|
||||
}
|
||||
MemMap[type].count += cnt;
|
||||
@ -81,7 +81,7 @@ mballoc(int cnt, int type)
|
||||
}
|
||||
|
||||
struct mbuf *
|
||||
mbfree(struct mbuf * bp)
|
||||
mbuf_FreeSeg(struct mbuf * bp)
|
||||
{
|
||||
struct mbuf *nbp;
|
||||
|
||||
@ -97,14 +97,14 @@ mbfree(struct mbuf * bp)
|
||||
}
|
||||
|
||||
void
|
||||
pfree(struct mbuf * bp)
|
||||
mbuf_Free(struct mbuf * bp)
|
||||
{
|
||||
while (bp)
|
||||
bp = mbfree(bp);
|
||||
bp = mbuf_FreeSeg(bp);
|
||||
}
|
||||
|
||||
struct mbuf *
|
||||
mbread(struct mbuf * bp, u_char * ptr, int len)
|
||||
mbuf_Read(struct mbuf * bp, u_char * ptr, int len)
|
||||
{
|
||||
int nb;
|
||||
|
||||
@ -122,7 +122,7 @@ mbread(struct mbuf * bp, u_char * ptr, int len)
|
||||
#ifdef notdef
|
||||
bp = bp->next;
|
||||
#else
|
||||
bp = mbfree(bp);
|
||||
bp = mbuf_FreeSeg(bp);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
@ -130,12 +130,12 @@ mbread(struct mbuf * bp, u_char * ptr, int len)
|
||||
}
|
||||
|
||||
void
|
||||
mbwrite(struct mbuf * bp, u_char * ptr, int cnt)
|
||||
mbuf_Write(struct mbuf * bp, u_char * ptr, int cnt)
|
||||
{
|
||||
int plen;
|
||||
int nb;
|
||||
|
||||
plen = plength(bp);
|
||||
plen = mbuf_Length(bp);
|
||||
if (plen < cnt)
|
||||
cnt = plen;
|
||||
|
||||
@ -148,7 +148,7 @@ mbwrite(struct mbuf * bp, u_char * ptr, int cnt)
|
||||
}
|
||||
|
||||
int
|
||||
ShowMemMap(struct cmdargs const *arg)
|
||||
mbuf_Show(struct cmdargs const *arg)
|
||||
{
|
||||
/* Watch it - ~m calls us with arg == NULL */
|
||||
int i;
|
||||
@ -168,23 +168,23 @@ ShowMemMap(struct cmdargs const *arg)
|
||||
}
|
||||
|
||||
void
|
||||
LogMemory()
|
||||
mbuf_Log()
|
||||
{
|
||||
LogPrintf(LogDEBUG, "LogMemory: mem alloced: %d\n", totalalloced);
|
||||
LogPrintf(LogDEBUG, "LogMemory: 1: %d 2: %d 3: %d 4: %d\n",
|
||||
log_Printf(LogDEBUG, "mbuf_Log: mem alloced: %d\n", totalalloced);
|
||||
log_Printf(LogDEBUG, "mbuf_Log: 1: %d 2: %d 3: %d 4: %d\n",
|
||||
MemMap[1].count, MemMap[2].count, MemMap[3].count, MemMap[4].count);
|
||||
LogPrintf(LogDEBUG, "LogMemory: 5: %d 6: %d 7: %d 8: %d\n",
|
||||
log_Printf(LogDEBUG, "mbuf_Log: 5: %d 6: %d 7: %d 8: %d\n",
|
||||
MemMap[5].count, MemMap[6].count, MemMap[7].count, MemMap[8].count);
|
||||
LogPrintf(LogDEBUG, "LogMemory: 9: %d 10: %d\n",
|
||||
log_Printf(LogDEBUG, "mbuf_Log: 9: %d 10: %d\n",
|
||||
MemMap[9].count, MemMap[10].count);
|
||||
}
|
||||
|
||||
struct mbuf *
|
||||
Dequeue(struct mqueue *q)
|
||||
mbuf_Dequeue(struct mqueue *q)
|
||||
{
|
||||
struct mbuf *bp;
|
||||
|
||||
LogPrintf(LogDEBUG, "Dequeue: queue len = %d\n", q->qlen);
|
||||
log_Printf(LogDEBUG, "mbuf_Dequeue: queue len = %d\n", q->qlen);
|
||||
bp = q->top;
|
||||
if (bp) {
|
||||
q->top = q->top->pnext;
|
||||
@ -192,7 +192,7 @@ Dequeue(struct mqueue *q)
|
||||
if (q->top == NULL) {
|
||||
q->last = q->top;
|
||||
if (q->qlen)
|
||||
LogPrintf(LogERROR, "Dequeue: Not zero (%d)!!!\n", q->qlen);
|
||||
log_Printf(LogERROR, "mbuf_Dequeue: Not zero (%d)!!!\n", q->qlen);
|
||||
}
|
||||
}
|
||||
|
||||
@ -200,7 +200,7 @@ Dequeue(struct mqueue *q)
|
||||
}
|
||||
|
||||
void
|
||||
Enqueue(struct mqueue *queue, struct mbuf *bp)
|
||||
mbuf_Enqueue(struct mqueue *queue, struct mbuf *bp)
|
||||
{
|
||||
if (queue->last) {
|
||||
queue->last->pnext = bp;
|
||||
@ -208,5 +208,5 @@ Enqueue(struct mqueue *queue, struct mbuf *bp)
|
||||
} else
|
||||
queue->last = queue->top = bp;
|
||||
queue->qlen++;
|
||||
LogPrintf(LogDEBUG, "Enqueue: len = %d\n", queue->qlen);
|
||||
log_Printf(LogDEBUG, "mbuf_Enqueue: len = %d\n", queue->qlen);
|
||||
}
|
||||
|
@ -15,7 +15,7 @@
|
||||
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* $Id: mbuf.h,v 1.11.2.3 1998/04/07 00:54:10 brian Exp $
|
||||
* $Id: mbuf.h,v 1.11.2.4 1998/04/07 01:29:44 brian Exp $
|
||||
*
|
||||
* TODO:
|
||||
*/
|
||||
@ -52,13 +52,13 @@ struct mqueue {
|
||||
|
||||
struct cmdargs;
|
||||
|
||||
extern int plength(struct mbuf *);
|
||||
extern struct mbuf *mballoc(int, int);
|
||||
extern struct mbuf *mbfree(struct mbuf *);
|
||||
extern void pfree(struct mbuf *);
|
||||
extern void mbwrite(struct mbuf *, u_char *, int);
|
||||
extern struct mbuf *mbread(struct mbuf *, u_char *, int);
|
||||
extern void LogMemory(void);
|
||||
extern int ShowMemMap(struct cmdargs const *);
|
||||
extern void Enqueue(struct mqueue *, struct mbuf *);
|
||||
extern struct mbuf *Dequeue(struct mqueue *);
|
||||
extern int mbuf_Length(struct mbuf *);
|
||||
extern struct mbuf *mbuf_Alloc(int, int);
|
||||
extern struct mbuf *mbuf_FreeSeg(struct mbuf *);
|
||||
extern void mbuf_Free(struct mbuf *);
|
||||
extern void mbuf_Write(struct mbuf *, u_char *, int);
|
||||
extern struct mbuf *mbuf_Read(struct mbuf *, u_char *, int);
|
||||
extern void mbuf_Log(void);
|
||||
extern int mbuf_Show(struct cmdargs const *);
|
||||
extern void mbuf_Enqueue(struct mqueue *, struct mbuf *);
|
||||
extern struct mbuf *mbuf_Dequeue(struct mqueue *);
|
||||
|
@ -17,7 +17,7 @@
|
||||
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* $Id: modem.c,v 1.77.2.61 1998/05/01 19:20:09 brian Exp $
|
||||
* $Id: modem.c,v 1.77.2.62 1998/05/01 19:22:19 brian Exp $
|
||||
*
|
||||
* TODO:
|
||||
*/
|
||||
@ -103,7 +103,7 @@ modem_Create(struct datalink *dl, int type)
|
||||
|
||||
p->desc.type = PHYSICAL_DESCRIPTOR;
|
||||
p->desc.UpdateSet = modem_UpdateSet;
|
||||
p->desc.IsSet = Physical_IsSet;
|
||||
p->desc.IsSet = physical_IsSet;
|
||||
p->desc.Read = modem_DescriptorRead;
|
||||
p->desc.Write = modem_DescriptorWrite;
|
||||
p->type = type;
|
||||
@ -270,13 +270,13 @@ modem_Timeout(void *data)
|
||||
int ombits = modem->mbits;
|
||||
int change;
|
||||
|
||||
StopTimer(&modem->Timer);
|
||||
StartTimer(&modem->Timer);
|
||||
timer_Stop(&modem->Timer);
|
||||
timer_Start(&modem->Timer);
|
||||
|
||||
if (modem->dev_is_modem) {
|
||||
if (modem->fd >= 0) {
|
||||
if (ioctl(modem->fd, TIOCMGET, &modem->mbits) < 0) {
|
||||
LogPrintf(LogPHASE, "%s: ioctl error (%s)!\n", modem->link.name,
|
||||
log_Printf(LogPHASE, "%s: ioctl error (%s)!\n", modem->link.name,
|
||||
strerror(errno));
|
||||
datalink_Down(modem->dl, 0);
|
||||
return;
|
||||
@ -286,14 +286,14 @@ modem_Timeout(void *data)
|
||||
change = ombits ^ modem->mbits;
|
||||
if (change & TIOCM_CD) {
|
||||
if (modem->mbits & TIOCM_CD)
|
||||
LogPrintf(LogDEBUG, "%s: offline -> online\n", modem->link.name);
|
||||
log_Printf(LogDEBUG, "%s: offline -> online\n", modem->link.name);
|
||||
else {
|
||||
LogPrintf(LogDEBUG, "%s: online -> offline\n", modem->link.name);
|
||||
LogPrintf(LogPHASE, "%s: Carrier lost\n", modem->link.name);
|
||||
log_Printf(LogDEBUG, "%s: online -> offline\n", modem->link.name);
|
||||
log_Printf(LogPHASE, "%s: Carrier lost\n", modem->link.name);
|
||||
datalink_Down(modem->dl, 0);
|
||||
}
|
||||
} else
|
||||
LogPrintf(LogDEBUG, "%s: Still %sline\n", modem->link.name,
|
||||
log_Printf(LogDEBUG, "%s: Still %sline\n", modem->link.name,
|
||||
Online(modem) ? "on" : "off");
|
||||
} else if (!Online(modem)) {
|
||||
/* mbits was set to zero in modem_Open() */
|
||||
@ -308,14 +308,14 @@ modem_StartTimer(struct bundle *bundle, struct physical *modem)
|
||||
|
||||
ModemTimer = &modem->Timer;
|
||||
|
||||
StopTimer(ModemTimer);
|
||||
timer_Stop(ModemTimer);
|
||||
ModemTimer->load = SECTICKS;
|
||||
ModemTimer->func = modem_Timeout;
|
||||
ModemTimer->name = "modem CD";
|
||||
ModemTimer->arg = modem;
|
||||
LogPrintf(LogDEBUG, "%s: Using modem_Timeout [%p]\n",
|
||||
log_Printf(LogDEBUG, "%s: Using modem_Timeout [%p]\n",
|
||||
modem->link.name, modem_Timeout);
|
||||
StartTimer(ModemTimer);
|
||||
timer_Start(ModemTimer);
|
||||
}
|
||||
|
||||
static struct parity {
|
||||
@ -358,7 +358,7 @@ modem_SetParity(struct physical *modem, const char *str)
|
||||
tcsetattr(modem->fd, TCSADRAIN, &rstio);
|
||||
return 0;
|
||||
}
|
||||
LogPrintf(LogWARN, "%s: %s: Invalid parity\n", modem->link.name, str);
|
||||
log_Printf(LogWARN, "%s: %s: Invalid parity\n", modem->link.name, str);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -377,7 +377,7 @@ OpenConnection(const char *name, char *host, char *port)
|
||||
if (hp) {
|
||||
memcpy(&dest.sin_addr.s_addr, hp->h_addr_list[0], 4);
|
||||
} else {
|
||||
LogPrintf(LogWARN, "%s: %s: unknown host\n", name, host);
|
||||
log_Printf(LogWARN, "%s: %s: unknown host\n", name, host);
|
||||
return (-1);
|
||||
}
|
||||
}
|
||||
@ -387,18 +387,18 @@ OpenConnection(const char *name, char *host, char *port)
|
||||
if (sp) {
|
||||
dest.sin_port = sp->s_port;
|
||||
} else {
|
||||
LogPrintf(LogWARN, "%s: %s: unknown service\n", name, port);
|
||||
log_Printf(LogWARN, "%s: %s: unknown service\n", name, port);
|
||||
return (-1);
|
||||
}
|
||||
}
|
||||
LogPrintf(LogPHASE, "%s: Connecting to %s:%s\n", name, host, port);
|
||||
log_Printf(LogPHASE, "%s: Connecting to %s:%s\n", name, host, port);
|
||||
|
||||
sock = socket(PF_INET, SOCK_STREAM, 0);
|
||||
if (sock < 0) {
|
||||
return (sock);
|
||||
}
|
||||
if (connect(sock, (struct sockaddr *)&dest, sizeof dest) < 0) {
|
||||
LogPrintf(LogWARN, "%s: connect: %s\n", name, strerror(errno));
|
||||
log_Printf(LogWARN, "%s: connect: %s\n", name, strerror(errno));
|
||||
return (-1);
|
||||
}
|
||||
return (sock);
|
||||
@ -417,10 +417,10 @@ modem_lock(struct physical *modem, int tunno)
|
||||
if (modem->type != PHYS_DIRECT &&
|
||||
(res = ID0uu_lock(modem->name.base)) != UU_LOCK_OK) {
|
||||
if (res == UU_LOCK_INUSE)
|
||||
LogPrintf(LogPHASE, "%s: %s is in use\n",
|
||||
log_Printf(LogPHASE, "%s: %s is in use\n",
|
||||
modem->link.name, modem->name.full);
|
||||
else
|
||||
LogPrintf(LogPHASE, "%s: %s is in use: uu_lock: %s\n",
|
||||
log_Printf(LogPHASE, "%s: %s is in use: uu_lock: %s\n",
|
||||
modem->link.name, modem->name.full, uu_lockerr(res));
|
||||
return (-1);
|
||||
}
|
||||
@ -433,7 +433,7 @@ modem_lock(struct physical *modem, int tunno)
|
||||
}
|
||||
#ifndef RELEASE_CRUNCH
|
||||
else
|
||||
LogPrintf(LogALERT, "%s: Can't create %s: %s\n",
|
||||
log_Printf(LogALERT, "%s: Can't create %s: %s\n",
|
||||
modem->link.name, fn, strerror(errno));
|
||||
#endif
|
||||
|
||||
@ -451,14 +451,14 @@ modem_Unlock(struct physical *modem)
|
||||
snprintf(fn, sizeof fn, "%s%s.if", _PATH_VARRUN, modem->name.base);
|
||||
#ifndef RELEASE_CRUNCH
|
||||
if (ID0unlink(fn) == -1)
|
||||
LogPrintf(LogALERT, "%s: Can't remove %s: %s\n",
|
||||
log_Printf(LogALERT, "%s: Can't remove %s: %s\n",
|
||||
modem->link.name, fn, strerror(errno));
|
||||
#else
|
||||
ID0unlink(fn);
|
||||
#endif
|
||||
|
||||
if (modem->type != PHYS_DIRECT && ID0uu_unlock(modem->name.base) == -1)
|
||||
LogPrintf(LogALERT, "%s: Can't uu_unlock %s\n", modem->link.name, fn);
|
||||
log_Printf(LogALERT, "%s: Can't uu_unlock %s\n", modem->link.name, fn);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -467,7 +467,7 @@ modem_Found(struct physical *modem, struct bundle *bundle)
|
||||
throughput_start(&modem->link.throughput, "modem throughput",
|
||||
Enabled(bundle, OPT_THROUGHPUT));
|
||||
modem->connect_count++;
|
||||
LogPrintf(LogPHASE, "%s: Connected!\n", modem->link.name);
|
||||
log_Printf(LogPHASE, "%s: Connected!\n", modem->link.name);
|
||||
}
|
||||
|
||||
int
|
||||
@ -481,11 +481,11 @@ modem_Open(struct physical *modem, struct bundle *bundle)
|
||||
char *tmpDevice;
|
||||
|
||||
if (modem->fd >= 0)
|
||||
LogPrintf(LogDEBUG, "%s: Open: Modem is already open!\n", modem->link.name);
|
||||
log_Printf(LogDEBUG, "%s: Open: Modem is already open!\n", modem->link.name);
|
||||
/* We're going back into "term" mode */
|
||||
else if (modem->type == PHYS_DIRECT) {
|
||||
if (isatty(STDIN_FILENO)) {
|
||||
LogPrintf(LogDEBUG, "%s: Open(direct): Modem is a tty\n",
|
||||
log_Printf(LogDEBUG, "%s: Open(direct): Modem is a tty\n",
|
||||
modem->link.name);
|
||||
modem_SetDevice(modem, ttyname(STDIN_FILENO));
|
||||
if (modem_lock(modem, bundle->unit) == -1) {
|
||||
@ -495,7 +495,7 @@ modem_Open(struct physical *modem, struct bundle *bundle)
|
||||
modem->fd = STDIN_FILENO;
|
||||
modem_Found(modem, bundle);
|
||||
} else {
|
||||
LogPrintf(LogDEBUG, "%s: Open(direct): Modem is not a tty\n",
|
||||
log_Printf(LogDEBUG, "%s: Open(direct): Modem is not a tty\n",
|
||||
modem->link.name);
|
||||
modem_SetDevice(modem, "");
|
||||
/* We don't call modem_Timeout() with this type of connection */
|
||||
@ -514,12 +514,12 @@ modem_Open(struct physical *modem, struct bundle *bundle)
|
||||
if (modem_lock(modem, bundle->unit) != -1) {
|
||||
modem->fd = ID0open(modem->name.full, O_RDWR | O_NONBLOCK);
|
||||
if (modem->fd < 0) {
|
||||
LogPrintf(LogERROR, "%s: Open(\"%s\"): %s\n",
|
||||
log_Printf(LogERROR, "%s: Open(\"%s\"): %s\n",
|
||||
modem->link.name, modem->name.full, strerror(errno));
|
||||
modem_Unlock(modem);
|
||||
} else {
|
||||
modem_Found(modem, bundle);
|
||||
LogPrintf(LogDEBUG, "%s: Opened %s\n",
|
||||
log_Printf(LogDEBUG, "%s: Opened %s\n",
|
||||
modem->link.name, modem->name.full);
|
||||
}
|
||||
}
|
||||
@ -540,16 +540,16 @@ modem_Open(struct physical *modem, struct bundle *bundle)
|
||||
if (modem->fd < 0)
|
||||
return (-1);
|
||||
modem_Found(modem, bundle);
|
||||
LogPrintf(LogDEBUG, "%s: Opened socket %s\n", modem->link.name,
|
||||
log_Printf(LogDEBUG, "%s: Opened socket %s\n", modem->link.name,
|
||||
modem->name.full);
|
||||
} else {
|
||||
*cp = ':'; /* Don't destroy name.full */
|
||||
LogPrintf(LogERROR, "%s: Invalid host:port: \"%s\"\n",
|
||||
log_Printf(LogERROR, "%s: Invalid host:port: \"%s\"\n",
|
||||
modem->link.name, modem->name.full);
|
||||
return (-1);
|
||||
}
|
||||
} else {
|
||||
LogPrintf(LogERROR, "%s: Device (%s) must begin with a '/' or be a"
|
||||
log_Printf(LogERROR, "%s: Device (%s) must begin with a '/' or be a"
|
||||
" host:port pair\n", modem->link.name, modem->name.full);
|
||||
return (-1);
|
||||
}
|
||||
@ -566,13 +566,13 @@ modem_Open(struct physical *modem, struct bundle *bundle)
|
||||
* configuted to use CTS/RTS flow control.
|
||||
*/
|
||||
modem->mbits = 0;
|
||||
modem->dev_is_modem = isatty(modem->fd) || Physical_IsSync(modem);
|
||||
if (Physical_IsSync(modem))
|
||||
modem->dev_is_modem = isatty(modem->fd) || physical_IsSync(modem);
|
||||
if (physical_IsSync(modem))
|
||||
nointr_sleep(1);
|
||||
if (modem->dev_is_modem && !Physical_IsSync(modem)) {
|
||||
if (modem->dev_is_modem && !physical_IsSync(modem)) {
|
||||
tcgetattr(modem->fd, &rstio);
|
||||
modem->ios = rstio;
|
||||
LogPrintf(LogDEBUG, "%s: Open: modem (get): fd = %d, iflag = %lx, "
|
||||
log_Printf(LogDEBUG, "%s: Open: modem (get): fd = %d, iflag = %lx, "
|
||||
"oflag = %lx, cflag = %lx\n", modem->link.name, modem->fd,
|
||||
(u_long)rstio.c_iflag, (u_long)rstio.c_oflag,
|
||||
(u_long)rstio.c_cflag);
|
||||
@ -592,29 +592,29 @@ modem_Open(struct physical *modem, struct bundle *bundle)
|
||||
rstio.c_cflag &= ~(CSIZE | PARODD | PARENB);
|
||||
rstio.c_cflag |= modem->cfg.parity;
|
||||
if (cfsetspeed(&rstio, IntToSpeed(modem->cfg.speed)) == -1)
|
||||
LogPrintf(LogWARN, "%s: %s: Unable to set speed to %d\n",
|
||||
log_Printf(LogWARN, "%s: %s: Unable to set speed to %d\n",
|
||||
modem->link.name, modem->name.full, modem->cfg.speed);
|
||||
}
|
||||
tcsetattr(modem->fd, TCSADRAIN, &rstio);
|
||||
LogPrintf(LogDEBUG, "%s: modem (put): iflag = %lx, oflag = %lx, "
|
||||
log_Printf(LogDEBUG, "%s: modem (put): iflag = %lx, oflag = %lx, "
|
||||
"cflag = %lx\n", modem->link.name, (u_long)rstio.c_iflag,
|
||||
(u_long)rstio.c_oflag, (u_long)rstio.c_cflag);
|
||||
|
||||
if (ioctl(modem->fd, TIOCMGET, &modem->mbits) == -1) {
|
||||
if (modem->type != PHYS_DIRECT) {
|
||||
LogPrintf(LogERROR, "%s: Open: Cannot get modem status: %s\n",
|
||||
log_Printf(LogERROR, "%s: Open: Cannot get modem status: %s\n",
|
||||
modem->link.name, strerror(errno));
|
||||
modem_LogicalClose(modem);
|
||||
return (-1);
|
||||
} else
|
||||
modem->mbits = TIOCM_CD;
|
||||
}
|
||||
LogPrintf(LogDEBUG, "%s: Open: modem control = %o\n",
|
||||
log_Printf(LogDEBUG, "%s: Open: modem control = %o\n",
|
||||
modem->link.name, modem->mbits);
|
||||
|
||||
oldflag = fcntl(modem->fd, F_GETFL, 0);
|
||||
if (oldflag < 0) {
|
||||
LogPrintf(LogERROR, "%s: Open: Cannot get modem flags: %s\n",
|
||||
log_Printf(LogERROR, "%s: Open: Cannot get modem flags: %s\n",
|
||||
modem->link.name, strerror(errno));
|
||||
modem_LogicalClose(modem);
|
||||
return (-1);
|
||||
@ -646,13 +646,13 @@ modem_Raw(struct physical *modem, struct bundle *bundle)
|
||||
struct termios rstio;
|
||||
int oldflag;
|
||||
|
||||
LogPrintf(LogDEBUG, "%s: Entering modem_Raw\n", modem->link.name);
|
||||
log_Printf(LogDEBUG, "%s: Entering modem_Raw\n", modem->link.name);
|
||||
|
||||
if (!isatty(modem->fd) || Physical_IsSync(modem))
|
||||
if (!isatty(modem->fd) || physical_IsSync(modem))
|
||||
return 0;
|
||||
|
||||
if (modem->type != PHYS_DIRECT && modem->fd >= 0 && !Online(modem))
|
||||
LogPrintf(LogDEBUG, "%s: Raw: modem = %d, mbits = %x\n",
|
||||
log_Printf(LogDEBUG, "%s: Raw: modem = %d, mbits = %x\n",
|
||||
modem->link.name, modem->fd, modem->mbits);
|
||||
|
||||
tcgetattr(modem->fd, &rstio);
|
||||
@ -681,7 +681,7 @@ modem_Unraw(struct physical *modem)
|
||||
{
|
||||
int oldflag;
|
||||
|
||||
if (isatty(modem->fd) && !Physical_IsSync(modem)) {
|
||||
if (isatty(modem->fd) && !physical_IsSync(modem)) {
|
||||
tcsetattr(modem->fd, TCSAFLUSH, &modem->ios);
|
||||
oldflag = fcntl(modem->fd, F_GETFL, 0);
|
||||
if (oldflag < 0)
|
||||
@ -693,10 +693,10 @@ modem_Unraw(struct physical *modem)
|
||||
static void
|
||||
modem_PhysicalClose(struct physical *modem)
|
||||
{
|
||||
LogPrintf(LogDEBUG, "%s: Physical Close\n", modem->link.name);
|
||||
log_Printf(LogDEBUG, "%s: Physical Close\n", modem->link.name);
|
||||
close(modem->fd);
|
||||
modem->fd = -1;
|
||||
StopTimer(&modem->Timer);
|
||||
timer_Stop(&modem->Timer);
|
||||
bundle_SetTtyCommandMode(modem->dl->bundle, modem->dl);
|
||||
throughput_stop(&modem->link.throughput);
|
||||
throughput_log(&modem->link.throughput, LogPHASE, modem->link.name);
|
||||
@ -712,13 +712,13 @@ modem_Offline(struct physical *modem)
|
||||
if (isatty(modem->fd) && Online(modem)) {
|
||||
tcgetattr(modem->fd, &tio);
|
||||
if (cfsetspeed(&tio, B0) == -1)
|
||||
LogPrintf(LogWARN, "%s: Unable to set modem to speed 0\n",
|
||||
log_Printf(LogWARN, "%s: Unable to set modem to speed 0\n",
|
||||
modem->link.name);
|
||||
else
|
||||
tcsetattr(modem->fd, TCSANOW, &tio);
|
||||
/* nointr_sleep(1); */
|
||||
}
|
||||
LogPrintf(LogPHASE, "%s: Disconnected!\n", modem->link.name);
|
||||
log_Printf(LogPHASE, "%s: Disconnected!\n", modem->link.name);
|
||||
}
|
||||
}
|
||||
|
||||
@ -728,7 +728,7 @@ modem_Close(struct physical *modem)
|
||||
if (modem->fd < 0)
|
||||
return;
|
||||
|
||||
LogPrintf(LogDEBUG, "%s: Close\n", modem->link.name);
|
||||
log_Printf(LogDEBUG, "%s: Close\n", modem->link.name);
|
||||
|
||||
if (!isatty(modem->fd)) {
|
||||
modem_PhysicalClose(modem);
|
||||
@ -754,9 +754,9 @@ modem_Destroy(struct physical *modem)
|
||||
static void
|
||||
modem_LogicalClose(struct physical *modem)
|
||||
{
|
||||
LogPrintf(LogDEBUG, "%s: Logical Close\n", modem->link.name);
|
||||
log_Printf(LogDEBUG, "%s: Logical Close\n", modem->link.name);
|
||||
if (modem->fd >= 0) {
|
||||
Physical_Logout(modem);
|
||||
physical_Logout(modem);
|
||||
modem_PhysicalClose(modem);
|
||||
modem_Unlock(modem);
|
||||
}
|
||||
@ -777,16 +777,16 @@ modem_DescriptorWrite(struct descriptor *d, struct bundle *bundle,
|
||||
if (modem->out) {
|
||||
nb = modem->out->cnt;
|
||||
nw = write(modem->fd, MBUF_CTOP(modem->out), nb);
|
||||
LogPrintf(LogDEBUG, "%s: DescriptorWrite: wrote: %d(%d) to %d\n",
|
||||
log_Printf(LogDEBUG, "%s: DescriptorWrite: wrote: %d(%d) to %d\n",
|
||||
modem->link.name, nw, nb, modem->fd);
|
||||
if (nw > 0) {
|
||||
modem->out->cnt -= nw;
|
||||
modem->out->offset += nw;
|
||||
if (modem->out->cnt == 0)
|
||||
modem->out = mbfree(modem->out);
|
||||
modem->out = mbuf_FreeSeg(modem->out);
|
||||
} else if (nw < 0) {
|
||||
if (errno != EAGAIN) {
|
||||
LogPrintf(LogWARN, "%s: write (%d): %s\n", modem->link.name, modem->fd,
|
||||
log_Printf(LogWARN, "%s: write (%d): %s\n", modem->link.name, modem->fd,
|
||||
strerror(errno));
|
||||
datalink_Down(modem->dl, 0);
|
||||
}
|
||||
@ -831,7 +831,7 @@ modem_ShowStatus(struct cmdargs const *arg)
|
||||
prompt_Printf(arg->prompt, "\nDefaults:\n");
|
||||
prompt_Printf(arg->prompt, " Device List: %s\n", modem->cfg.devlist);
|
||||
prompt_Printf(arg->prompt, " Characteristics: ");
|
||||
if (Physical_IsSync(arg->cx->physical))
|
||||
if (physical_IsSync(arg->cx->physical))
|
||||
prompt_Printf(arg->prompt, "sync");
|
||||
else
|
||||
prompt_Printf(arg->prompt, "%dbps", modem->cfg.speed);
|
||||
@ -874,22 +874,22 @@ modem_DescriptorRead(struct descriptor *d, struct bundle *bundle,
|
||||
if (p->link.lcp.fsm.state <= ST_CLOSED)
|
||||
nointr_usleep(10000);
|
||||
|
||||
n = Physical_Read(p, rbuff, sizeof rbuff);
|
||||
n = physical_Read(p, rbuff, sizeof rbuff);
|
||||
if (p->type == PHYS_DIRECT && n <= 0)
|
||||
datalink_Down(p->dl, 0);
|
||||
else
|
||||
LogDumpBuff(LogASYNC, "ReadFromModem", rbuff, n);
|
||||
log_DumpBuff(LogASYNC, "ReadFromModem", rbuff, n);
|
||||
|
||||
if (p->link.lcp.fsm.state <= ST_CLOSED) {
|
||||
/* In -dedicated mode, we just discard input until LCP is started */
|
||||
if (p->type != PHYS_DEDICATED) {
|
||||
cp = HdlcDetect(p, rbuff, n);
|
||||
cp = hdlc_Detect(p, rbuff, n);
|
||||
if (cp) {
|
||||
/* LCP packet is detected. Turn ourselves into packet mode */
|
||||
if (cp != rbuff) {
|
||||
/* XXX missing return value checks */
|
||||
Physical_Write(p, rbuff, cp - rbuff);
|
||||
Physical_Write(p, "\r\n", 2);
|
||||
physical_Write(p, rbuff, cp - rbuff);
|
||||
physical_Write(p, "\r\n", 2);
|
||||
}
|
||||
datalink_Up(p->dl, 0, 1);
|
||||
} else
|
||||
@ -902,7 +902,7 @@ modem_DescriptorRead(struct descriptor *d, struct bundle *bundle,
|
||||
static int
|
||||
modem_UpdateSet(struct descriptor *d, fd_set *r, fd_set *w, fd_set *e, int *n)
|
||||
{
|
||||
return Physical_UpdateSet(d, r, w, e, n, 0);
|
||||
return physical_UpdateSet(d, r, w, e, n, 0);
|
||||
}
|
||||
|
||||
struct physical *
|
||||
@ -920,7 +920,7 @@ modem_FromBinary(struct datalink *dl, int fd)
|
||||
|
||||
got = fullread(fd, p, sizeof *p);
|
||||
if (got != sizeof *p) {
|
||||
LogPrintf(LogWARN, "Cannot receive physical"
|
||||
log_Printf(LogWARN, "Cannot receive physical"
|
||||
" (got %d bytes, not %d)\n", got, sizeof *p);
|
||||
close(fd);
|
||||
free(p);
|
||||
@ -932,7 +932,7 @@ modem_FromBinary(struct datalink *dl, int fd)
|
||||
memset(p->link.Queue, '\0', sizeof p->link.Queue);
|
||||
|
||||
p->desc.UpdateSet = modem_UpdateSet;
|
||||
p->desc.IsSet = Physical_IsSet;
|
||||
p->desc.IsSet = physical_IsSet;
|
||||
p->desc.Read = modem_DescriptorRead;
|
||||
p->desc.Write = modem_DescriptorWrite;
|
||||
p->desc.next = NULL;
|
||||
@ -967,7 +967,7 @@ modem_FromBinary(struct datalink *dl, int fd)
|
||||
p->hdlc.ReportTimer.state = TIMER_STOPPED;
|
||||
p->hdlc.lqm.timer.state = TIMER_STOPPED;
|
||||
if (p->hdlc.lqm.method && p->hdlc.lqm.timer.load)
|
||||
StartLqm(&p->link.lcp);
|
||||
lqr_Start(&p->link.lcp);
|
||||
hdlc_StartTimer(&p->hdlc);
|
||||
|
||||
p->fd = fd; /* Now talk down it :-) */
|
||||
@ -992,18 +992,18 @@ modem_ToBinary(struct physical *p, int fd)
|
||||
*/
|
||||
|
||||
hdlc_StopTimer(&p->hdlc);
|
||||
StopLqrTimer(p);
|
||||
StopTimer(&p->link.lcp.fsm.FsmTimer);
|
||||
StopTimer(&p->link.ccp.fsm.FsmTimer);
|
||||
StopTimer(&p->link.lcp.fsm.OpenTimer);
|
||||
StopTimer(&p->link.ccp.fsm.OpenTimer);
|
||||
StopTimer(&p->link.lcp.fsm.StoppedTimer);
|
||||
StopTimer(&p->link.ccp.fsm.StoppedTimer);
|
||||
StopTimer(&p->Timer);
|
||||
StopTimer(&p->link.throughput.Timer);
|
||||
lqr_StopTimer(p);
|
||||
timer_Stop(&p->link.lcp.fsm.FsmTimer);
|
||||
timer_Stop(&p->link.ccp.fsm.FsmTimer);
|
||||
timer_Stop(&p->link.lcp.fsm.OpenTimer);
|
||||
timer_Stop(&p->link.ccp.fsm.OpenTimer);
|
||||
timer_Stop(&p->link.lcp.fsm.StoppedTimer);
|
||||
timer_Stop(&p->link.ccp.fsm.StoppedTimer);
|
||||
timer_Stop(&p->Timer);
|
||||
timer_Stop(&p->link.throughput.Timer);
|
||||
|
||||
if (fd != -1 && write(fd, p, sizeof *p) != sizeof *p) {
|
||||
LogPrintf(LogERROR, "Failed sending physical\n");
|
||||
log_Printf(LogERROR, "Failed sending physical\n");
|
||||
close(fd);
|
||||
fd = -1;
|
||||
}
|
||||
|
@ -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.1.2.17 1998/04/28 01:25:33 brian Exp $
|
||||
* $Id: mp.c,v 1.1.2.18 1998/04/30 23:53:51 brian Exp $
|
||||
*/
|
||||
|
||||
#include <sys/types.h>
|
||||
@ -111,7 +111,7 @@ mp_ReadHeader(struct mp *mp, struct mbuf *m, struct mp_header *header)
|
||||
if (mp->local_is12bit) {
|
||||
header->seq = ntohs(*(u_int16_t *)MBUF_CTOP(m));
|
||||
if (header->seq & 0x3000) {
|
||||
LogPrintf(LogWARN, "Oops - MP header without required zero bits\n");
|
||||
log_Printf(LogWARN, "Oops - MP header without required zero bits\n");
|
||||
return 0;
|
||||
}
|
||||
header->begin = header->seq & 0x8000 ? 1 : 0;
|
||||
@ -121,7 +121,7 @@ mp_ReadHeader(struct mp *mp, struct mbuf *m, struct mp_header *header)
|
||||
} else {
|
||||
header->seq = ntohl(*(u_int32_t *)MBUF_CTOP(m));
|
||||
if (header->seq & 0x3f000000) {
|
||||
LogPrintf(LogWARN, "Oops - MP header without required zero bits\n");
|
||||
log_Printf(LogWARN, "Oops - MP header without required zero bits\n");
|
||||
return 0;
|
||||
}
|
||||
header->begin = header->seq & 0x80000000 ? 1 : 0;
|
||||
@ -205,14 +205,14 @@ mp_Up(struct mp *mp, struct datalink *dl)
|
||||
if (mp->active) {
|
||||
/* We're adding a link - do a last validation on our parameters */
|
||||
if (!peerid_Equal(&dl->peer, &mp->peer)) {
|
||||
LogPrintf(LogPHASE, "%s: Inappropriate peer !\n", dl->name);
|
||||
log_Printf(LogPHASE, "%s: Inappropriate peer !\n", dl->name);
|
||||
return MP_FAILED;
|
||||
}
|
||||
if (mp->local_mrru != lcp->want_mrru ||
|
||||
mp->peer_mrru != lcp->his_mrru ||
|
||||
mp->local_is12bit != lcp->want_shortseq ||
|
||||
mp->peer_is12bit != lcp->his_shortseq) {
|
||||
LogPrintf(LogPHASE, "%s: Invalid MRRU/SHORTSEQ MP parameters !\n",
|
||||
log_Printf(LogPHASE, "%s: Invalid MRRU/SHORTSEQ MP parameters !\n",
|
||||
dl->name);
|
||||
return MP_FAILED;
|
||||
}
|
||||
@ -241,7 +241,7 @@ mp_Up(struct mp *mp, struct datalink *dl)
|
||||
*/
|
||||
fd = mpserver_Open(&mp->server, &mp->peer);
|
||||
if (fd >= 0) {
|
||||
LogPrintf(LogPHASE, "mp: Transfer link on %s\n",
|
||||
log_Printf(LogPHASE, "mp: Transfer link on %s\n",
|
||||
mp->server.socket.sun_path);
|
||||
mp->server.send.dl = dl;
|
||||
mp->server.send.fd = fd;
|
||||
@ -249,15 +249,15 @@ mp_Up(struct mp *mp, struct datalink *dl)
|
||||
} else if (!mpserver_IsOpen(&mp->server))
|
||||
return MP_FAILED;
|
||||
else {
|
||||
LogPrintf(LogPHASE, "mp: Listening on %s\n", mp->server.socket.sun_path);
|
||||
LogPrintf(LogPHASE, " First link: %s\n", dl->name);
|
||||
log_Printf(LogPHASE, "mp: Listening on %s\n", mp->server.socket.sun_path);
|
||||
log_Printf(LogPHASE, " First link: %s\n", dl->name);
|
||||
|
||||
/* Re-point our IPCP layer at our MP link */
|
||||
ipcp_SetLink(&mp->bundle->ncp.ipcp, &mp->link);
|
||||
|
||||
/* Our lcp's already up 'cos of the NULL parent */
|
||||
FsmUp(&mp->link.ccp.fsm);
|
||||
FsmOpen(&mp->link.ccp.fsm);
|
||||
fsm_Up(&mp->link.ccp.fsm);
|
||||
fsm_Open(&mp->link.ccp.fsm);
|
||||
|
||||
mp->active = 1;
|
||||
}
|
||||
@ -276,13 +276,13 @@ mp_Down(struct mp *mp)
|
||||
mpserver_Close(&mp->server);
|
||||
|
||||
/* CCP goes down with a bang */
|
||||
FsmDown(&mp->link.ccp.fsm);
|
||||
FsmClose(&mp->link.ccp.fsm);
|
||||
fsm_Down(&mp->link.ccp.fsm);
|
||||
fsm_Close(&mp->link.ccp.fsm);
|
||||
|
||||
/* Received fragments go in the bit-bucket */
|
||||
while (mp->inbufs) {
|
||||
next = mp->inbufs->pnext;
|
||||
pfree(mp->inbufs);
|
||||
mbuf_Free(mp->inbufs);
|
||||
mp->inbufs = next;
|
||||
}
|
||||
|
||||
@ -306,7 +306,7 @@ mp_Input(struct mp *mp, struct mbuf *m, struct physical *p)
|
||||
int32_t seq;
|
||||
|
||||
if (mp_ReadHeader(mp, m, &mh) == 0) {
|
||||
pfree(m);
|
||||
mbuf_Free(m);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -361,9 +361,9 @@ mp_Input(struct mp *mp, struct mbuf *m, struct physical *p)
|
||||
|
||||
/* Zap all older fragments */
|
||||
while (mp->inbufs != q) {
|
||||
LogPrintf(LogDEBUG, "Drop frag\n");
|
||||
log_Printf(LogDEBUG, "Drop frag\n");
|
||||
next = mp->inbufs->pnext;
|
||||
pfree(mp->inbufs);
|
||||
mbuf_Free(mp->inbufs);
|
||||
mp->inbufs = next;
|
||||
}
|
||||
|
||||
@ -380,8 +380,8 @@ mp_Input(struct mp *mp, struct mbuf *m, struct physical *p)
|
||||
break;
|
||||
}
|
||||
next = mp->inbufs->pnext;
|
||||
LogPrintf(LogDEBUG, "Drop frag %u\n", h.seq);
|
||||
pfree(mp->inbufs);
|
||||
log_Printf(LogDEBUG, "Drop frag %u\n", h.seq);
|
||||
mbuf_Free(mp->inbufs);
|
||||
mp->inbufs = next;
|
||||
} while (mp->inbufs && (h.seq >= mp->seq.min_in || h.end));
|
||||
|
||||
@ -415,12 +415,12 @@ mp_Input(struct mp *mp, struct mbuf *m, struct physical *p)
|
||||
(*frag)->cnt -= len;
|
||||
(*frag)->pnext = NULL;
|
||||
if (frag == &q && !h.begin) {
|
||||
LogPrintf(LogWARN, "Oops - MP frag %lu should have a begin flag\n",
|
||||
log_Printf(LogWARN, "Oops - MP frag %lu should have a begin flag\n",
|
||||
(u_long)h.seq);
|
||||
pfree(q);
|
||||
mbuf_Free(q);
|
||||
q = NULL;
|
||||
} else if (frag != &q && h.begin) {
|
||||
LogPrintf(LogWARN, "Oops - MP frag %lu should have an end flag\n",
|
||||
log_Printf(LogWARN, "Oops - MP frag %lu should have an end flag\n",
|
||||
(u_long)h.seq - 1);
|
||||
/*
|
||||
* Stuff our fragment back at the front of the queue and zap
|
||||
@ -429,7 +429,7 @@ mp_Input(struct mp *mp, struct mbuf *m, struct physical *p)
|
||||
(*frag)->pnext = mp->inbufs;
|
||||
mp->inbufs = *frag;
|
||||
*frag = NULL;
|
||||
pfree(q);
|
||||
mbuf_Free(q);
|
||||
q = NULL;
|
||||
frag = &q;
|
||||
h.end = 0; /* just in case it's a whole packet */
|
||||
@ -443,16 +443,16 @@ mp_Input(struct mp *mp, struct mbuf *m, struct physical *p)
|
||||
u_short proto;
|
||||
u_char ch;
|
||||
|
||||
q = mbread(q, &ch, 1);
|
||||
q = mbuf_Read(q, &ch, 1);
|
||||
proto = ch;
|
||||
if (!(proto & 1)) {
|
||||
q = mbread(q, &ch, 1);
|
||||
q = mbuf_Read(q, &ch, 1);
|
||||
proto <<= 8;
|
||||
proto += ch;
|
||||
}
|
||||
if (LogIsKept(LogDEBUG))
|
||||
LogPrintf(LogDEBUG, "MP: Reassembled frags %ld-%lu, length %d\n",
|
||||
first, (u_long)h.seq, plength(q));
|
||||
if (log_IsKept(LogDEBUG))
|
||||
log_Printf(LogDEBUG, "MP: Reassembled frags %ld-%lu, length %d\n",
|
||||
first, (u_long)h.seq, mbuf_Length(q));
|
||||
hdlc_DecodePacket(mp->bundle, proto, q, &mp->link);
|
||||
}
|
||||
|
||||
@ -491,7 +491,7 @@ mp_Output(struct mp *mp, struct link *l, struct mbuf *m, int begin, int end)
|
||||
struct mbuf *mo;
|
||||
|
||||
/* Stuff an MP header on the front of our packet and send it */
|
||||
mo = mballoc(4, MB_MP);
|
||||
mo = mbuf_Alloc(4, MB_MP);
|
||||
mo->next = m;
|
||||
if (mp->peer_is12bit) {
|
||||
u_int16_t *seq16;
|
||||
@ -506,12 +506,12 @@ mp_Output(struct mp *mp, struct link *l, struct mbuf *m, int begin, int end)
|
||||
*seq32 = htonl((begin << 31) | (end << 30) | (u_int32_t)mp->seq.out);
|
||||
mo->cnt = 4;
|
||||
}
|
||||
if (LogIsKept(LogDEBUG))
|
||||
LogPrintf(LogDEBUG, "MP[frag %d]: Send %d bytes on %s\n",
|
||||
mp->seq.out, plength(mo), l->name);
|
||||
if (log_IsKept(LogDEBUG))
|
||||
log_Printf(LogDEBUG, "MP[frag %d]: Send %d bytes on %s\n",
|
||||
mp->seq.out, mbuf_Length(mo), l->name);
|
||||
mp->seq.out = inc_seq(mp, mp->seq.out);
|
||||
|
||||
HdlcOutput(l, PRI_NORMAL, PROTO_MP, mo);
|
||||
hdlc_Output(l, PRI_NORMAL, PROTO_MP, mo);
|
||||
}
|
||||
|
||||
int
|
||||
@ -541,12 +541,12 @@ mp_FillQueues(struct bundle *bundle)
|
||||
if (add)
|
||||
/* this link has got stuff already queued. Let it continue */
|
||||
continue;
|
||||
if (!link_QueueLen(&mp->link) && !IpFlushPacket(&mp->link, bundle))
|
||||
if (!link_QueueLen(&mp->link) && !ip_FlushPacket(&mp->link, bundle))
|
||||
/* Nothing else to send */
|
||||
break;
|
||||
|
||||
m = link_Dequeue(&mp->link);
|
||||
len = plength(m);
|
||||
len = mbuf_Length(m);
|
||||
add += len;
|
||||
begin = 1;
|
||||
end = 0;
|
||||
@ -564,10 +564,10 @@ mp_FillQueues(struct bundle *bundle)
|
||||
mo = m;
|
||||
end = 1;
|
||||
} else {
|
||||
mo = mballoc(dl->mp.weight, MB_MP);
|
||||
mo = mbuf_Alloc(dl->mp.weight, MB_MP);
|
||||
mo->cnt = dl->mp.weight;
|
||||
len -= mo->cnt;
|
||||
m = mbread(m, MBUF_CTOP(mo), mo->cnt);
|
||||
m = mbuf_Read(m, MBUF_CTOP(mo), mo->cnt);
|
||||
}
|
||||
mp_Output(mp, &dl->physical->link, mo, begin, end);
|
||||
begin = 0;
|
||||
@ -589,7 +589,7 @@ mp_SetDatalinkWeight(struct cmdargs const *arg)
|
||||
|
||||
val = atoi(arg->argv[arg->argn]);
|
||||
if (val < LINK_MINWEIGHT) {
|
||||
LogPrintf(LogWARN, "Link weights must not be less than %d\n",
|
||||
log_Printf(LogWARN, "Link weights must not be less than %d\n",
|
||||
LINK_MINWEIGHT);
|
||||
return 1;
|
||||
}
|
||||
@ -706,7 +706,7 @@ mp_SetEnddisc(struct cmdargs const *arg)
|
||||
struct in_addr addr;
|
||||
|
||||
if (bundle_Phase(arg->bundle) != PHASE_DEAD) {
|
||||
LogPrintf(LogWARN, "set enddisc: Only available at phase DEAD\n");
|
||||
log_Printf(LogWARN, "set enddisc: Only available at phase DEAD\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -738,7 +738,7 @@ mp_SetEnddisc(struct cmdargs const *arg)
|
||||
|
||||
s = ID0socket(AF_INET, SOCK_DGRAM, 0);
|
||||
if (s < 0) {
|
||||
LogPrintf(LogERROR, "set enddisc: socket(): %s\n", strerror(errno));
|
||||
log_Printf(LogERROR, "set enddisc: socket(): %s\n", strerror(errno));
|
||||
return 2;
|
||||
}
|
||||
if (get_ether_addr(s, addr, &hwaddr)) {
|
||||
@ -747,7 +747,7 @@ mp_SetEnddisc(struct cmdargs const *arg)
|
||||
hwaddr.sdl_alen);
|
||||
mp->cfg.enddisc.len = hwaddr.sdl_alen;
|
||||
} else {
|
||||
LogPrintf(LogWARN, "set enddisc: Can't locate MAC address for %s\n",
|
||||
log_Printf(LogWARN, "set enddisc: Can't locate MAC address for %s\n",
|
||||
inet_ntoa(addr));
|
||||
close(s);
|
||||
return 4;
|
||||
@ -767,11 +767,11 @@ mp_SetEnddisc(struct cmdargs const *arg)
|
||||
strcpy(mp->cfg.enddisc.address, arg->argv[arg->argn+1]);
|
||||
mp->cfg.enddisc.len = strlen(mp->cfg.enddisc.address);
|
||||
} else {
|
||||
LogPrintf(LogWARN, "PSN endpoint requires additional data\n");
|
||||
log_Printf(LogWARN, "PSN endpoint requires additional data\n");
|
||||
return 5;
|
||||
}
|
||||
} else {
|
||||
LogPrintf(LogWARN, "%s: Unrecognised endpoint type\n",
|
||||
log_Printf(LogWARN, "%s: Unrecognised endpoint type\n",
|
||||
arg->argv[arg->argn]);
|
||||
return 6;
|
||||
}
|
||||
@ -818,7 +818,7 @@ mpserver_Read(struct descriptor *d, struct bundle *bundle, const fd_set *fdset)
|
||||
size = sizeof in;
|
||||
fd = accept(s->fd, &in, &size);
|
||||
if (fd < 0) {
|
||||
LogPrintf(LogERROR, "mpserver_Read: accept(): %s\n", strerror(errno));
|
||||
log_Printf(LogERROR, "mpserver_Read: accept(): %s\n", strerror(errno));
|
||||
return;
|
||||
}
|
||||
|
||||
@ -832,7 +832,7 @@ static void
|
||||
mpserver_Write(struct descriptor *d, struct bundle *bundle, const fd_set *fdset)
|
||||
{
|
||||
/* We never want to write here ! */
|
||||
LogPrintf(LogERROR, "mpserver_Write: Internal error: Bad call !\n");
|
||||
log_Printf(LogERROR, "mpserver_Write: Internal error: Bad call !\n");
|
||||
}
|
||||
|
||||
void
|
||||
@ -857,7 +857,7 @@ mpserver_Open(struct mpserver *s, struct peerid *peer)
|
||||
mode_t mask;
|
||||
|
||||
if (s->fd != -1) {
|
||||
LogPrintf(LogERROR, "Internal error ! mpserver already open\n");
|
||||
log_Printf(LogERROR, "Internal error ! mpserver already open\n");
|
||||
mpserver_Close(s);
|
||||
}
|
||||
|
||||
@ -874,7 +874,7 @@ mpserver_Open(struct mpserver *s, struct peerid *peer)
|
||||
s->socket.sun_len = sizeof s->socket;
|
||||
s->fd = ID0socket(PF_LOCAL, SOCK_STREAM, 0);
|
||||
if (s->fd < 0) {
|
||||
LogPrintf(LogERROR, "mpserver: socket: %s\n", strerror(errno));
|
||||
log_Printf(LogERROR, "mpserver: socket: %s\n", strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -883,7 +883,7 @@ mpserver_Open(struct mpserver *s, struct peerid *peer)
|
||||
mask = umask(0177);
|
||||
if (ID0bind_un(s->fd, &s->socket) < 0) {
|
||||
if (errno != EADDRINUSE) {
|
||||
LogPrintf(LogPHASE, "mpserver: can't create bundle socket %s (%s)\n",
|
||||
log_Printf(LogPHASE, "mpserver: can't create bundle socket %s (%s)\n",
|
||||
s->socket.sun_path, strerror(errno));
|
||||
umask(mask);
|
||||
close(s->fd);
|
||||
@ -892,10 +892,10 @@ mpserver_Open(struct mpserver *s, struct peerid *peer)
|
||||
}
|
||||
umask(mask);
|
||||
if (ID0connect_un(s->fd, &s->socket) < 0) {
|
||||
LogPrintf(LogPHASE, "mpserver: can't connect to bundle socket %s (%s)\n",
|
||||
log_Printf(LogPHASE, "mpserver: can't connect to bundle socket %s (%s)\n",
|
||||
s->socket.sun_path, strerror(errno));
|
||||
if (errno == ECONNREFUSED)
|
||||
LogPrintf(LogPHASE, " Has the previous server died badly ?\n");
|
||||
log_Printf(LogPHASE, " Has the previous server died badly ?\n");
|
||||
close(s->fd);
|
||||
s->fd = -1;
|
||||
return -1;
|
||||
@ -909,7 +909,7 @@ mpserver_Open(struct mpserver *s, struct peerid *peer)
|
||||
|
||||
/* Listen for other ppp invocations that want to donate links */
|
||||
if (listen(s->fd, 5) != 0) {
|
||||
LogPrintf(LogERROR, "mpserver: Unable to listen to socket"
|
||||
log_Printf(LogERROR, "mpserver: Unable to listen to socket"
|
||||
" - BUNDLE overload?\n");
|
||||
mpserver_Close(s);
|
||||
}
|
||||
@ -929,7 +929,7 @@ mpserver_Close(struct mpserver *s)
|
||||
if (s->fd >= 0) {
|
||||
close(s->fd);
|
||||
if (ID0unlink(s->socket.sun_path) == -1)
|
||||
LogPrintf(LogERROR, "%s: Failed to remove: %s\n", s->socket.sun_path,
|
||||
log_Printf(LogERROR, "%s: Failed to remove: %s\n", s->socket.sun_path,
|
||||
strerror(errno));
|
||||
memset(&s->socket, '\0', sizeof s->socket);
|
||||
s->fd = -1;
|
||||
|
@ -23,7 +23,7 @@
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $Id: mp.h,v 1.1.2.8 1998/04/28 01:25:34 brian Exp $
|
||||
* $Id: mp.h,v 1.1.2.9 1998/04/30 23:53:52 brian Exp $
|
||||
*/
|
||||
|
||||
struct mbuf;
|
||||
@ -106,7 +106,6 @@ struct mp_header {
|
||||
u_int32_t seq;
|
||||
};
|
||||
|
||||
#define mpserver2descriptor(s) (&(s)->desc)
|
||||
#define descriptor2mpserver(d) \
|
||||
((d)->type == MPSERVER_DESCRIPTOR ? (struct mpserver *)(d) : NULL)
|
||||
#define mpserver_IsOpen(s) ((s)->fd != -1)
|
||||
|
@ -18,7 +18,7 @@
|
||||
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* $Id: pap.c,v 1.20.2.26 1998/04/24 19:16:12 brian Exp $
|
||||
* $Id: pap.c,v 1.20.2.27 1998/04/28 01:25:36 brian Exp $
|
||||
*
|
||||
* TODO:
|
||||
*/
|
||||
@ -60,7 +60,7 @@
|
||||
static const char *papcodes[] = { "???", "REQUEST", "ACK", "NAK" };
|
||||
|
||||
void
|
||||
SendPapChallenge(struct authinfo *auth, int papid, struct physical *physical)
|
||||
pap_SendChallenge(struct authinfo *auth, int papid, struct physical *physical)
|
||||
{
|
||||
struct fsmheader lh;
|
||||
struct mbuf *bp;
|
||||
@ -70,13 +70,13 @@ SendPapChallenge(struct authinfo *auth, int papid, struct physical *physical)
|
||||
namelen = strlen(physical->dl->bundle->cfg.auth.name);
|
||||
keylen = strlen(physical->dl->bundle->cfg.auth.key);
|
||||
plen = namelen + keylen + 2;
|
||||
LogPrintf(LogDEBUG, "SendPapChallenge: namelen = %d, keylen = %d\n",
|
||||
log_Printf(LogDEBUG, "pap_SendChallenge: namelen = %d, keylen = %d\n",
|
||||
namelen, keylen);
|
||||
LogPrintf(LogPHASE, "PAP: %s\n", physical->dl->bundle->cfg.auth.name);
|
||||
log_Printf(LogPHASE, "PAP: %s\n", physical->dl->bundle->cfg.auth.name);
|
||||
lh.code = PAP_REQUEST;
|
||||
lh.id = papid;
|
||||
lh.length = htons(plen + sizeof(struct fsmheader));
|
||||
bp = mballoc(plen + sizeof(struct fsmheader), MB_FSM);
|
||||
bp = mbuf_Alloc(plen + sizeof(struct fsmheader), MB_FSM);
|
||||
memcpy(MBUF_CTOP(bp), &lh, sizeof(struct fsmheader));
|
||||
cp = MBUF_CTOP(bp) + sizeof(struct fsmheader);
|
||||
*cp++ = namelen;
|
||||
@ -84,9 +84,8 @@ SendPapChallenge(struct authinfo *auth, int papid, struct physical *physical)
|
||||
cp += namelen;
|
||||
*cp++ = keylen;
|
||||
memcpy(cp, physical->dl->bundle->cfg.auth.key, keylen);
|
||||
|
||||
|
||||
HdlcOutput(physical2link(physical), PRI_LINK, PROTO_PAP, bp);
|
||||
hdlc_Output(&physical->link, PRI_LINK, PROTO_PAP, bp);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -102,13 +101,13 @@ SendPapCode(int id, int code, const char *message, struct physical *physical)
|
||||
mlen = strlen(message);
|
||||
plen = mlen + 1;
|
||||
lh.length = htons(plen + sizeof(struct fsmheader));
|
||||
bp = mballoc(plen + sizeof(struct fsmheader), MB_FSM);
|
||||
bp = mbuf_Alloc(plen + sizeof(struct fsmheader), MB_FSM);
|
||||
memcpy(MBUF_CTOP(bp), &lh, sizeof(struct fsmheader));
|
||||
cp = MBUF_CTOP(bp) + sizeof(struct fsmheader);
|
||||
*cp++ = mlen;
|
||||
memcpy(cp, message, mlen);
|
||||
LogPrintf(LogPHASE, "PapOutput: %s\n", papcodes[code]);
|
||||
HdlcOutput(physical2link(physical), PRI_LINK, PROTO_PAP, bp);
|
||||
log_Printf(LogPHASE, "PapOutput: %s\n", papcodes[code]);
|
||||
hdlc_Output(&physical->link, PRI_LINK, PROTO_PAP, bp);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -124,16 +123,16 @@ PapValidate(struct bundle *bundle, u_char *name, u_char *key,
|
||||
klen = *key;
|
||||
*key++ = 0;
|
||||
key[klen] = 0;
|
||||
LogPrintf(LogDEBUG, "PapValidate: name %s (%d), key %s (%d)\n",
|
||||
log_Printf(LogDEBUG, "PapValidate: name %s (%d), key %s (%d)\n",
|
||||
name, nlen, key, klen);
|
||||
|
||||
return AuthValidate(bundle, name, key, physical);
|
||||
return auth_Validate(bundle, name, key, physical);
|
||||
}
|
||||
|
||||
void
|
||||
PapInput(struct bundle *bundle, struct mbuf *bp, struct physical *physical)
|
||||
pap_Input(struct bundle *bundle, struct mbuf *bp, struct physical *physical)
|
||||
{
|
||||
int len = plength(bp);
|
||||
int len = mbuf_Length(bp);
|
||||
struct fsmheader *php;
|
||||
u_char *cp;
|
||||
|
||||
@ -142,7 +141,7 @@ PapInput(struct bundle *bundle, struct mbuf *bp, struct physical *physical)
|
||||
if (len >= ntohs(php->length)) {
|
||||
if (php->code < PAP_REQUEST || php->code > PAP_NAK)
|
||||
php->code = 0;
|
||||
LogPrintf(LogPHASE, "PapInput: %s\n", papcodes[php->code]);
|
||||
log_Printf(LogPHASE, "pap_Input: %s\n", papcodes[php->code]);
|
||||
|
||||
switch (php->code) {
|
||||
case PAP_REQUEST:
|
||||
@ -152,7 +151,7 @@ PapInput(struct bundle *bundle, struct mbuf *bp, struct physical *physical)
|
||||
SendPapCode(php->id, PAP_ACK, "Greetings!!", physical);
|
||||
physical->link.lcp.auth_ineed = 0;
|
||||
if (Enabled(bundle, OPT_UTMP))
|
||||
Physical_Login(physical, cp + 1);
|
||||
physical_Login(physical, cp + 1);
|
||||
|
||||
if (physical->link.lcp.auth_iwait == 0)
|
||||
/*
|
||||
@ -167,11 +166,11 @@ PapInput(struct bundle *bundle, struct mbuf *bp, struct physical *physical)
|
||||
}
|
||||
break;
|
||||
case PAP_ACK:
|
||||
StopAuthTimer(&physical->dl->pap);
|
||||
auth_StopTimer(&physical->dl->pap);
|
||||
cp = (u_char *) (php + 1);
|
||||
len = *cp++;
|
||||
cp[len] = 0;
|
||||
LogPrintf(LogPHASE, "Received PAP_ACK (%s)\n", cp);
|
||||
log_Printf(LogPHASE, "Received PAP_ACK (%s)\n", cp);
|
||||
if (physical->link.lcp.auth_iwait == PROTO_PAP) {
|
||||
physical->link.lcp.auth_iwait = 0;
|
||||
if (physical->link.lcp.auth_ineed == 0)
|
||||
@ -184,15 +183,15 @@ PapInput(struct bundle *bundle, struct mbuf *bp, struct physical *physical)
|
||||
}
|
||||
break;
|
||||
case PAP_NAK:
|
||||
StopAuthTimer(&physical->dl->pap);
|
||||
auth_StopTimer(&physical->dl->pap);
|
||||
cp = (u_char *) (php + 1);
|
||||
len = *cp++;
|
||||
cp[len] = 0;
|
||||
LogPrintf(LogPHASE, "Received PAP_NAK (%s)\n", cp);
|
||||
log_Printf(LogPHASE, "Received PAP_NAK (%s)\n", cp);
|
||||
datalink_AuthNotOk(physical->dl);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
pfree(bp);
|
||||
mbuf_Free(bp);
|
||||
}
|
||||
|
@ -15,7 +15,7 @@
|
||||
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* $Id: pap.h,v 1.5.2.3 1998/03/01 01:07:49 brian Exp $
|
||||
* $Id: pap.h,v 1.5.2.4 1998/04/07 00:54:13 brian Exp $
|
||||
*
|
||||
* TODO:
|
||||
*/
|
||||
@ -29,5 +29,5 @@ struct physical;
|
||||
struct authinfo;
|
||||
struct bundle;
|
||||
|
||||
extern void PapInput(struct bundle *, struct mbuf *, struct physical *);
|
||||
extern void SendPapChallenge(struct authinfo *, int, struct physical *);
|
||||
extern void pap_Input(struct bundle *, struct mbuf *, struct physical *);
|
||||
extern void pap_SendChallenge(struct authinfo *, int, struct physical *);
|
||||
|
@ -1,43 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 1989 The Regents of the University of California.
|
||||
* 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.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the University of
|
||||
* California, Berkeley and its contributors.
|
||||
* 4. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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: pathnames.h,v 1.7 1997/09/10 02:20:33 brian Exp $
|
||||
*
|
||||
* @(#)pathnames.h 5.2 (Berkeley) 6/1/90
|
||||
*/
|
||||
|
||||
#if defined(__FreeBSD__) || defined(__OpenBSD__)
|
||||
#define _PATH_PPP "/etc/ppp"
|
||||
#else
|
||||
#define _PATH_PPP "/etc"
|
||||
#endif
|
@ -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.1.2.28 1998/04/30 23:53:53 brian Exp $
|
||||
* $Id: physical.c,v 1.1.2.29 1998/05/01 19:22:21 brian Exp $
|
||||
*
|
||||
*/
|
||||
|
||||
@ -51,27 +51,27 @@ extern int IntToSpeed(int);
|
||||
|
||||
|
||||
int
|
||||
Physical_GetFD(struct physical *phys) {
|
||||
physical_GetFD(struct physical *phys) {
|
||||
return phys->fd;
|
||||
}
|
||||
|
||||
int
|
||||
Physical_IsATTY(struct physical *phys) {
|
||||
physical_IsATTY(struct physical *phys) {
|
||||
return isatty(phys->fd);
|
||||
}
|
||||
|
||||
int
|
||||
Physical_IsSync(struct physical *phys) {
|
||||
physical_IsSync(struct physical *phys) {
|
||||
return phys->cfg.speed == 0;
|
||||
}
|
||||
|
||||
const char *Physical_GetDevice(struct physical *phys)
|
||||
const char *physical_GetDevice(struct physical *phys)
|
||||
{
|
||||
return phys->name.full;
|
||||
}
|
||||
|
||||
void
|
||||
Physical_SetDeviceList(struct physical *p, int argc, const char *const *argv)
|
||||
physical_SetDeviceList(struct physical *p, int argc, const char *const *argv)
|
||||
{
|
||||
int f, pos;
|
||||
|
||||
@ -86,7 +86,7 @@ Physical_SetDeviceList(struct physical *p, int argc, const char *const *argv)
|
||||
|
||||
|
||||
int
|
||||
Physical_SetSpeed(struct physical *phys, int speed) {
|
||||
physical_SetSpeed(struct physical *phys, int speed) {
|
||||
if (IntToSpeed(speed) != B0) {
|
||||
phys->cfg.speed = speed;
|
||||
return 1;
|
||||
@ -96,13 +96,13 @@ Physical_SetSpeed(struct physical *phys, int speed) {
|
||||
}
|
||||
|
||||
void
|
||||
Physical_SetSync(struct physical *phys) {
|
||||
physical_SetSync(struct physical *phys) {
|
||||
phys->cfg.speed = 0;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
Physical_SetRtsCts(struct physical *phys, int enable) {
|
||||
physical_SetRtsCts(struct physical *phys, int enable) {
|
||||
phys->cfg.rts_cts = enable ? 1 : 0;
|
||||
return 1;
|
||||
}
|
||||
@ -110,17 +110,17 @@ Physical_SetRtsCts(struct physical *phys, int enable) {
|
||||
/* Encapsulation for a read on the FD. Avoids some exposure, and
|
||||
concentrates control. */
|
||||
ssize_t
|
||||
Physical_Read(struct physical *phys, void *buf, size_t nbytes) {
|
||||
physical_Read(struct physical *phys, void *buf, size_t nbytes) {
|
||||
return read(phys->fd, buf, nbytes);
|
||||
}
|
||||
|
||||
ssize_t
|
||||
Physical_Write(struct physical *phys, const void *buf, size_t nbytes) {
|
||||
physical_Write(struct physical *phys, const void *buf, size_t nbytes) {
|
||||
return write(phys->fd, buf, nbytes);
|
||||
}
|
||||
|
||||
int
|
||||
Physical_UpdateSet(struct descriptor *d, fd_set *r, fd_set *w, fd_set *e,
|
||||
physical_UpdateSet(struct descriptor *d, fd_set *r, fd_set *w, fd_set *e,
|
||||
int *n, int force)
|
||||
{
|
||||
struct physical *p = descriptor2physical(d);
|
||||
@ -148,18 +148,18 @@ Physical_UpdateSet(struct descriptor *d, fd_set *r, fd_set *w, fd_set *e,
|
||||
}
|
||||
|
||||
int
|
||||
Physical_IsSet(struct descriptor *d, const fd_set *fdset)
|
||||
physical_IsSet(struct descriptor *d, const fd_set *fdset)
|
||||
{
|
||||
struct physical *p = descriptor2physical(d);
|
||||
return p->fd >= 0 && FD_ISSET(p->fd, fdset);
|
||||
}
|
||||
|
||||
void
|
||||
Physical_Login(struct physical *phys, const char *name)
|
||||
physical_Login(struct physical *phys, const char *name)
|
||||
{
|
||||
if (phys->type == PHYS_DIRECT && Physical_IsATTY(phys)) {
|
||||
if (phys->type == PHYS_DIRECT && physical_IsATTY(phys)) {
|
||||
if (phys->Utmp)
|
||||
LogPrintf(LogERROR, "Oops, already logged in on %s\n", phys->name.base);
|
||||
log_Printf(LogERROR, "Oops, already logged in on %s\n", phys->name.base);
|
||||
else {
|
||||
struct utmp ut;
|
||||
|
||||
@ -174,7 +174,7 @@ Physical_Login(struct physical *phys, const char *name)
|
||||
}
|
||||
|
||||
void
|
||||
Physical_Logout(struct physical *phys)
|
||||
physical_Logout(struct physical *phys)
|
||||
{
|
||||
if (phys->Utmp) {
|
||||
ID0logout(phys->name.base);
|
||||
|
@ -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.1.2.22 1998/04/20 00:20:41 brian Exp $
|
||||
* $Id: physical.h,v 1.1.2.23 1998/05/01 19:22:23 brian Exp $
|
||||
*
|
||||
*/
|
||||
|
||||
@ -25,7 +25,7 @@ struct bundle;
|
||||
struct physical {
|
||||
struct link link;
|
||||
struct descriptor desc;
|
||||
int type; /* What sort of link are we ? */
|
||||
int type; /* What sort of PHYS_* link are we ? */
|
||||
struct async async; /* Our async state */
|
||||
struct hdlc hdlc; /* Our hdlc state */
|
||||
int fd; /* File descriptor for this device */
|
||||
@ -64,39 +64,35 @@ struct physical {
|
||||
#define field2phys(fp, name) \
|
||||
((struct physical *)((char *)fp - (int)(&((struct physical *)0)->name)))
|
||||
|
||||
#define physical2link(p) (&(p)->link)
|
||||
#define link2physical(l) \
|
||||
((l)->type == PHYSICAL_LINK ? field2phys(l, link) : NULL)
|
||||
|
||||
#define physical2descriptor(p) (&(p)->desc)
|
||||
#define descriptor2physical(d) \
|
||||
((d)->type == PHYSICAL_DESCRIPTOR ? field2phys(d, desc) : NULL)
|
||||
|
||||
int Physical_GetFD(struct physical *);
|
||||
int Physical_IsATTY(struct physical *);
|
||||
int Physical_IsSync(struct physical *);
|
||||
const char *Physical_GetDevice(struct physical *);
|
||||
extern int physical_GetFD(struct physical *);
|
||||
extern int physical_IsATTY(struct physical *);
|
||||
extern int physical_IsSync(struct physical *);
|
||||
extern const char *physical_GetDevice(struct physical *);
|
||||
extern void physical_SetDeviceList(struct physical *, int, const char *const *);
|
||||
extern int physical_SetSpeed(struct physical *, int);
|
||||
|
||||
/*
|
||||
* XXX-ML I'm not certain this is the right way to handle this, but we
|
||||
* can solve that later.
|
||||
*/
|
||||
extern void physical_SetSync(struct physical *);
|
||||
|
||||
void Physical_SetDeviceList(struct physical *, int, const char *const *);
|
||||
int /* Was this speed OK? */
|
||||
Physical_SetSpeed(struct physical *, int);
|
||||
/*
|
||||
* Can this be set? (Might not be a relevant attribute for this
|
||||
* device, for instance)
|
||||
*/
|
||||
extern int physical_SetRtsCts(struct physical *, int);
|
||||
|
||||
/* XXX-ML I'm not certain this is the right way to handle this, but we
|
||||
can solve that later. */
|
||||
void Physical_SetSync(struct physical *);
|
||||
|
||||
int /* Can this be set? (Might not be a relevant attribute for this
|
||||
device, for instance) */
|
||||
Physical_SetRtsCts(struct physical *, int);
|
||||
|
||||
ssize_t Physical_Read(struct physical *, void *, size_t);
|
||||
ssize_t Physical_Write(struct physical *, const void *, size_t);
|
||||
int Physical_UpdateSet(struct descriptor *, fd_set *, fd_set *, fd_set *,
|
||||
int *, int);
|
||||
int Physical_IsSet(struct descriptor *, const fd_set *);
|
||||
void Physical_DescriptorWrite(struct descriptor *, struct bundle *,
|
||||
const fd_set *);
|
||||
|
||||
void Physical_Login(struct physical *, const char *);
|
||||
void Physical_Logout(struct physical *);
|
||||
extern ssize_t physical_Read(struct physical *, void *, size_t);
|
||||
extern ssize_t physical_Write(struct physical *, const void *, size_t);
|
||||
extern int physical_UpdateSet(struct descriptor *, fd_set *, fd_set *,
|
||||
fd_set *, int *, int);
|
||||
extern int physical_IsSet(struct descriptor *, const fd_set *);
|
||||
extern void physical_Login(struct physical *, const char *);
|
||||
extern void physical_Logout(struct physical *);
|
||||
|
@ -26,7 +26,7 @@
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $Id: pred.c,v 1.20.2.10 1998/04/24 19:15:26 brian Exp $
|
||||
* $Id: pred.c,v 1.20.2.11 1998/04/25 00:09:14 brian Exp $
|
||||
*/
|
||||
|
||||
#include <sys/types.h>
|
||||
@ -132,7 +132,7 @@ Pred1ResetInput(void *v)
|
||||
struct pred1_state *state = (struct pred1_state *)v;
|
||||
state->hash = 0;
|
||||
memset(state->dict, '\0', sizeof state->dict);
|
||||
LogPrintf(LogCCP, "Predictor1: Input channel reset\n");
|
||||
log_Printf(LogCCP, "Predictor1: Input channel reset\n");
|
||||
}
|
||||
|
||||
static void
|
||||
@ -141,7 +141,7 @@ Pred1ResetOutput(void *v)
|
||||
struct pred1_state *state = (struct pred1_state *)v;
|
||||
state->hash = 0;
|
||||
memset(state->dict, '\0', sizeof state->dict);
|
||||
LogPrintf(LogCCP, "Predictor1: Output channel reset\n");
|
||||
log_Printf(LogCCP, "Predictor1: Output channel reset\n");
|
||||
}
|
||||
|
||||
static void *
|
||||
@ -175,20 +175,20 @@ Pred1Output(void *v, struct ccp *ccp, struct link *l, int pri, u_short proto,
|
||||
u_char bufp[MAX_MTU + 2];
|
||||
u_short fcs;
|
||||
|
||||
orglen = plength(bp) + 2; /* add count of proto */
|
||||
mwp = mballoc((orglen + 2) / 8 * 9 + 12, MB_HDLCOUT);
|
||||
orglen = mbuf_Length(bp) + 2; /* add count of proto */
|
||||
mwp = mbuf_Alloc((orglen + 2) / 8 * 9 + 12, MB_HDLCOUT);
|
||||
hp = wp = MBUF_CTOP(mwp);
|
||||
cp = bufp;
|
||||
*wp++ = *cp++ = orglen >> 8;
|
||||
*wp++ = *cp++ = orglen & 0377;
|
||||
*cp++ = proto >> 8;
|
||||
*cp++ = proto & 0377;
|
||||
mbread(bp, cp, orglen - 2);
|
||||
fcs = HdlcFcs(INITFCS, bufp, 2 + orglen);
|
||||
mbuf_Read(bp, cp, orglen - 2);
|
||||
fcs = hdlc_Fcs(INITFCS, bufp, 2 + orglen);
|
||||
fcs = ~fcs;
|
||||
|
||||
len = compress(state, bufp + 2, wp, orglen);
|
||||
LogPrintf(LogDEBUG, "Pred1Output: orglen (%d) --> len (%d)\n", orglen, len);
|
||||
log_Printf(LogDEBUG, "Pred1Output: orglen (%d) --> len (%d)\n", orglen, len);
|
||||
ccp->uncompout += orglen;
|
||||
if (len < orglen) {
|
||||
*hp |= 0x80;
|
||||
@ -203,7 +203,7 @@ Pred1Output(void *v, struct ccp *ccp, struct link *l, int pri, u_short proto,
|
||||
*wp++ = fcs & 0377;
|
||||
*wp++ = fcs >> 8;
|
||||
mwp->cnt = wp - MBUF_CTOP(mwp);
|
||||
HdlcOutput(l, PRI_NORMAL, ccp_Proto(ccp), mwp);
|
||||
hdlc_Output(l, PRI_NORMAL, ccp_Proto(ccp), mwp);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -217,9 +217,9 @@ Pred1Input(void *v, struct ccp *ccp, u_short *proto, struct mbuf *bp)
|
||||
u_char *bufp;
|
||||
u_short fcs;
|
||||
|
||||
wp = mballoc(MAX_MTU + 2, MB_IPIN);
|
||||
wp = mbuf_Alloc(MAX_MTU + 2, MB_IPIN);
|
||||
cp = MBUF_CTOP(bp);
|
||||
olen = plength(bp);
|
||||
olen = mbuf_Length(bp);
|
||||
pp = bufp = MBUF_CTOP(wp);
|
||||
*pp++ = *cp & 0177;
|
||||
len = *cp++ << 8;
|
||||
@ -231,10 +231,10 @@ Pred1Input(void *v, struct ccp *ccp, u_short *proto, struct mbuf *bp)
|
||||
ccp->compin += olen;
|
||||
len &= 0x7fff;
|
||||
if (len != len1) { /* Error is detected. Send reset request */
|
||||
LogPrintf(LogCCP, "Pred1: Length error\n");
|
||||
CcpSendResetReq(&ccp->fsm);
|
||||
pfree(bp);
|
||||
pfree(wp);
|
||||
log_Printf(LogCCP, "Pred1: Length error\n");
|
||||
ccp_SendResetReq(&ccp->fsm);
|
||||
mbuf_Free(bp);
|
||||
mbuf_Free(wp);
|
||||
return NULL;
|
||||
}
|
||||
cp += olen - 4;
|
||||
@ -247,9 +247,9 @@ Pred1Input(void *v, struct ccp *ccp, u_short *proto, struct mbuf *bp)
|
||||
}
|
||||
*pp++ = *cp++; /* CRC */
|
||||
*pp++ = *cp++;
|
||||
fcs = HdlcFcs(INITFCS, bufp, wp->cnt = pp - bufp);
|
||||
fcs = hdlc_Fcs(INITFCS, bufp, wp->cnt = pp - bufp);
|
||||
if (fcs != GOODFCS)
|
||||
LogPrintf(LogDEBUG, "Pred1Input: fcs = 0x%04x (%s), len = 0x%x,"
|
||||
log_Printf(LogDEBUG, "Pred1Input: fcs = 0x%04x (%s), len = 0x%x,"
|
||||
" olen = 0x%x\n", fcs, (fcs == GOODFCS) ? "good" : "bad",
|
||||
len, olen);
|
||||
if (fcs == GOODFCS) {
|
||||
@ -265,14 +265,14 @@ Pred1Input(void *v, struct ccp *ccp, u_short *proto, struct mbuf *bp)
|
||||
wp->cnt -= 2;
|
||||
*proto = (*proto << 8) | *pp++;
|
||||
}
|
||||
pfree(bp);
|
||||
mbuf_Free(bp);
|
||||
return wp;
|
||||
} else {
|
||||
LogDumpBp(LogHDLC, "Bad FCS", wp);
|
||||
CcpSendResetReq(&ccp->fsm);
|
||||
pfree(wp);
|
||||
log_DumpBp(LogHDLC, "Bad FCS", wp);
|
||||
ccp_SendResetReq(&ccp->fsm);
|
||||
mbuf_Free(wp);
|
||||
}
|
||||
pfree(bp);
|
||||
mbuf_Free(bp);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -23,7 +23,7 @@
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $Id: prompt.c,v 1.1.2.27 1998/04/18 01:01:27 brian Exp $
|
||||
* $Id: prompt.c,v 1.1.2.28 1998/04/19 15:24:49 brian Exp $
|
||||
*/
|
||||
|
||||
#include <sys/param.h>
|
||||
@ -178,12 +178,12 @@ prompt_Read(struct descriptor *d, struct bundle *bundle, const fd_set *fdset)
|
||||
linebuff[--n] = '\0';
|
||||
else
|
||||
linebuff[n] = '\0';
|
||||
p->nonewline = 1; /* Maybe DecodeCommand does a prompt */
|
||||
p->nonewline = 1; /* Maybe command_Decode does a prompt */
|
||||
prompt_Required(p);
|
||||
if (n)
|
||||
DecodeCommand(bundle, linebuff, n, p, p->src.from);
|
||||
command_Decode(bundle, linebuff, n, p, p->src.from);
|
||||
} else if (n <= 0) {
|
||||
LogPrintf(LogPHASE, "Client connection closed.\n");
|
||||
log_Printf(LogPHASE, "Client connection closed.\n");
|
||||
prompt_Destroy(p, 0);
|
||||
}
|
||||
return;
|
||||
@ -216,7 +216,7 @@ prompt_Read(struct descriptor *d, struct bundle *bundle, const fd_set *fdset)
|
||||
* We are in terminal mode, decode special sequences
|
||||
*/
|
||||
n = read(p->fd_in, &ch, 1);
|
||||
LogPrintf(LogDEBUG, "Got %d bytes (reading from the terminal)\n", n);
|
||||
log_Printf(LogDEBUG, "Got %d bytes (reading from the terminal)\n", n);
|
||||
|
||||
if (n > 0) {
|
||||
switch (ttystate) {
|
||||
@ -224,8 +224,8 @@ prompt_Read(struct descriptor *d, struct bundle *bundle, const fd_set *fdset)
|
||||
if (ch == '~')
|
||||
ttystate++;
|
||||
else
|
||||
if (Physical_Write(p->TermMode->physical, &ch, n) < 0) {
|
||||
LogPrintf(LogERROR, "error writing to modem: %s\n", strerror(errno));
|
||||
if (physical_Write(p->TermMode->physical, &ch, n) < 0) {
|
||||
log_Printf(LogERROR, "error writing to modem: %s\n", strerror(errno));
|
||||
prompt_TtyCommandMode(p);
|
||||
}
|
||||
break;
|
||||
@ -245,14 +245,14 @@ prompt_Read(struct descriptor *d, struct bundle *bundle, const fd_set *fdset)
|
||||
prompt_Required(p);
|
||||
break;
|
||||
case 't':
|
||||
ShowTimers(0, p);
|
||||
timer_Show(0, p);
|
||||
break;
|
||||
case 'm':
|
||||
ShowMemMap(NULL);
|
||||
mbuf_Show(NULL);
|
||||
break;
|
||||
default:
|
||||
if (Physical_Write(p->TermMode->physical, &ch, n) < 0) {
|
||||
LogPrintf(LogERROR, "error writing to modem: %s\n", strerror(errno));
|
||||
if (physical_Write(p->TermMode->physical, &ch, n) < 0) {
|
||||
log_Printf(LogERROR, "error writing to modem: %s\n", strerror(errno));
|
||||
prompt_TtyCommandMode(p);
|
||||
}
|
||||
break;
|
||||
@ -267,7 +267,7 @@ static void
|
||||
prompt_Write(struct descriptor *d, struct bundle *bundle, const fd_set *fdset)
|
||||
{
|
||||
/* We never want to write here ! */
|
||||
LogPrintf(LogERROR, "prompt_Write: Internal error: Bad call !\n");
|
||||
log_Printf(LogERROR, "prompt_Write: Internal error: Bad call !\n");
|
||||
}
|
||||
|
||||
struct prompt *
|
||||
@ -309,7 +309,7 @@ prompt_Create(struct server *s, struct bundle *bundle, int fd)
|
||||
if (p->bundle)
|
||||
bundle_RegisterDescriptor(p->bundle, &p->desc);
|
||||
log_RegisterPrompt(p);
|
||||
LogDiscardAllLocal(&p->logmask);
|
||||
log_DiscardAllLocal(&p->logmask);
|
||||
}
|
||||
|
||||
return p;
|
||||
@ -324,7 +324,7 @@ prompt_Destroy(struct prompt *p, int verbose)
|
||||
if (p->fd_out != p->fd_in)
|
||||
close(p->fd_out);
|
||||
if (verbose)
|
||||
LogPrintf(LogPHASE, "Client connection dropped.\n");
|
||||
log_Printf(LogPHASE, "Client connection dropped.\n");
|
||||
} else
|
||||
prompt_TtyOldMode(p);
|
||||
|
||||
@ -460,12 +460,12 @@ PasswdCommand(struct cmdargs const *arg)
|
||||
const char *pass;
|
||||
|
||||
if (!arg->prompt) {
|
||||
LogPrintf(LogWARN, "passwd: Cannot specify without a prompt\n");
|
||||
log_Printf(LogWARN, "passwd: Cannot specify without a prompt\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (arg->prompt->owner == NULL) {
|
||||
LogPrintf(LogWARN, "passwd: Not required\n");
|
||||
log_Printf(LogWARN, "passwd: Not required\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -495,7 +495,7 @@ prompt_TimedContinue(void *v)
|
||||
void
|
||||
prompt_Continue(struct prompt *p)
|
||||
{
|
||||
StopTimer(&bgtimer);
|
||||
timer_Stop(&bgtimer);
|
||||
if (getpgrp() == prompt_pgrp(p)) {
|
||||
prompt_TtyCommandMode(p);
|
||||
p->nonewline = 1;
|
||||
@ -506,7 +506,7 @@ prompt_Continue(struct prompt *p)
|
||||
bgtimer.name = "prompt bg";
|
||||
bgtimer.load = SECTICKS;
|
||||
bgtimer.arg = p;
|
||||
StartTimer(&bgtimer);
|
||||
timer_Start(&bgtimer);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -23,7 +23,7 @@
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $Id: prompt.h,v 1.1.2.7 1998/04/10 13:19:19 brian Exp $
|
||||
* $Id: prompt.h,v 1.1.2.8 1998/04/19 23:08:50 brian Exp $
|
||||
*/
|
||||
|
||||
#define LOCAL_AUTH 0x01
|
||||
@ -61,7 +61,6 @@ struct prompt {
|
||||
struct termios comtio; /* Command level tty mode */
|
||||
};
|
||||
|
||||
#define prompt2descriptor(p) (&(p)->desc)
|
||||
#define descriptor2prompt(d) \
|
||||
((d)->type == PROMPT_DESCRIPTOR ? (struct prompt *)(d) : NULL)
|
||||
|
||||
|
@ -17,7 +17,7 @@
|
||||
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* $Id: route.c,v 1.42.2.19 1998/04/25 10:49:43 brian Exp $
|
||||
* $Id: route.c,v 1.42.2.20 1998/04/28 01:25:39 brian Exp $
|
||||
*
|
||||
*/
|
||||
|
||||
@ -212,7 +212,7 @@ Index2Nam(int idx)
|
||||
mib[5] = 0;
|
||||
|
||||
if (sysctl(mib, 6, NULL, &needed, NULL, 0) < 0) {
|
||||
LogPrintf(LogERROR, "Index2Nam: sysctl: estimate: %s\n", strerror(errno));
|
||||
log_Printf(LogERROR, "Index2Nam: sysctl: estimate: %s\n", strerror(errno));
|
||||
return "???";
|
||||
}
|
||||
if ((buf = malloc(needed)) == NULL)
|
||||
@ -236,7 +236,7 @@ Index2Nam(int idx)
|
||||
else
|
||||
ifs = (char **)malloc(sizeof(char *) * have);
|
||||
if (!ifs) {
|
||||
LogPrintf(LogDEBUG, "Index2Nam: %s\n", strerror(errno));
|
||||
log_Printf(LogDEBUG, "Index2Nam: %s\n", strerror(errno));
|
||||
nifs = 0;
|
||||
return "???";
|
||||
}
|
||||
@ -249,20 +249,20 @@ Index2Nam(int idx)
|
||||
if (nifs < ifm->ifm_index)
|
||||
nifs = ifm->ifm_index;
|
||||
}
|
||||
} else if (LogIsKept(LogDEBUG))
|
||||
LogPrintf(LogDEBUG, "Skipping out-of-range interface %d!\n",
|
||||
} else if (log_IsKept(LogDEBUG))
|
||||
log_Printf(LogDEBUG, "Skipping out-of-range interface %d!\n",
|
||||
ifm->ifm_index);
|
||||
}
|
||||
free(buf);
|
||||
}
|
||||
|
||||
if (LogIsKept(LogDEBUG) && !debug_done) {
|
||||
if (log_IsKept(LogDEBUG) && !debug_done) {
|
||||
int f;
|
||||
|
||||
LogPrintf(LogDEBUG, "Found the following interfaces:\n");
|
||||
log_Printf(LogDEBUG, "Found the following interfaces:\n");
|
||||
for (f = 0; f < nifs; f++)
|
||||
if (ifs[f] != NULL)
|
||||
LogPrintf(LogDEBUG, " Index %d, name \"%s\"\n", f+1, ifs[f]);
|
||||
log_Printf(LogDEBUG, " Index %d, name \"%s\"\n", f+1, ifs[f]);
|
||||
debug_done = 1;
|
||||
}
|
||||
|
||||
@ -273,7 +273,7 @@ Index2Nam(int idx)
|
||||
}
|
||||
|
||||
int
|
||||
ShowRoute(struct cmdargs const *arg)
|
||||
route_Show(struct cmdargs const *arg)
|
||||
{
|
||||
struct rt_msghdr *rtm;
|
||||
struct sockaddr *sa_dst, *sa_gw, *sa_mask;
|
||||
@ -288,7 +288,7 @@ ShowRoute(struct cmdargs const *arg)
|
||||
mib[4] = NET_RT_DUMP;
|
||||
mib[5] = 0;
|
||||
if (sysctl(mib, 6, NULL, &needed, NULL, 0) < 0) {
|
||||
LogPrintf(LogERROR, "ShowRoute: sysctl: estimate: %s\n", strerror(errno));
|
||||
log_Printf(LogERROR, "route_Show: sysctl: estimate: %s\n", strerror(errno));
|
||||
return (1);
|
||||
}
|
||||
if (needed < 0)
|
||||
@ -297,7 +297,7 @@ ShowRoute(struct cmdargs const *arg)
|
||||
if (sp == NULL)
|
||||
return (1);
|
||||
if (sysctl(mib, 6, sp, &needed, NULL, 0) < 0) {
|
||||
LogPrintf(LogERROR, "ShowRoute: sysctl: getroute: %s\n", strerror(errno));
|
||||
log_Printf(LogERROR, "route_Show: sysctl: getroute: %s\n", strerror(errno));
|
||||
free(sp);
|
||||
return (1);
|
||||
}
|
||||
@ -341,7 +341,7 @@ ShowRoute(struct cmdargs const *arg)
|
||||
* Delete routes associated with our interface
|
||||
*/
|
||||
void
|
||||
DeleteIfRoutes(struct bundle *bundle, int all)
|
||||
route_IfDelete(struct bundle *bundle, int all)
|
||||
{
|
||||
struct rt_msghdr *rtm;
|
||||
struct sockaddr *sa;
|
||||
@ -351,7 +351,7 @@ DeleteIfRoutes(struct bundle *bundle, int all)
|
||||
char *sp, *cp, *ep;
|
||||
int mib[6];
|
||||
|
||||
LogPrintf(LogDEBUG, "DeleteIfRoutes (%d)\n", bundle->ifIndex);
|
||||
log_Printf(LogDEBUG, "route_IfDelete (%d)\n", bundle->ifIndex);
|
||||
sa_none.s_addr = INADDR_ANY;
|
||||
|
||||
mib[0] = CTL_NET;
|
||||
@ -361,7 +361,7 @@ DeleteIfRoutes(struct bundle *bundle, int all)
|
||||
mib[4] = NET_RT_DUMP;
|
||||
mib[5] = 0;
|
||||
if (sysctl(mib, 6, NULL, &needed, NULL, 0) < 0) {
|
||||
LogPrintf(LogERROR, "DeleteIfRoutes: sysctl: estimate: %s\n",
|
||||
log_Printf(LogERROR, "route_IfDelete: sysctl: estimate: %s\n",
|
||||
strerror(errno));
|
||||
return;
|
||||
}
|
||||
@ -373,7 +373,7 @@ DeleteIfRoutes(struct bundle *bundle, int all)
|
||||
return;
|
||||
|
||||
if (sysctl(mib, 6, sp, &needed, NULL, 0) < 0) {
|
||||
LogPrintf(LogERROR, "DeleteIfRoutes: sysctl: getroute: %s\n",
|
||||
log_Printf(LogERROR, "route_IfDelete: sysctl: getroute: %s\n",
|
||||
strerror(errno));
|
||||
free(sp);
|
||||
return;
|
||||
@ -394,7 +394,7 @@ DeleteIfRoutes(struct bundle *bundle, int all)
|
||||
for (cp = sp; cp < ep; cp += rtm->rtm_msglen) {
|
||||
rtm = (struct rt_msghdr *) cp;
|
||||
sa = (struct sockaddr *) (rtm + 1);
|
||||
LogPrintf(LogDEBUG, "DeleteIfRoutes: addrs: %x, Netif: %d (%s),"
|
||||
log_Printf(LogDEBUG, "route_IfDelete: addrs: %x, Netif: %d (%s),"
|
||||
" flags: %x, dst: %s ?\n", rtm->rtm_addrs, rtm->rtm_index,
|
||||
Index2Nam(rtm->rtm_index), rtm->rtm_flags,
|
||||
inet_ntoa(((struct sockaddr_in *) sa)->sin_addr));
|
||||
@ -406,13 +406,13 @@ DeleteIfRoutes(struct bundle *bundle, int all)
|
||||
if (sa->sa_family == AF_INET || sa->sa_family == AF_LINK) {
|
||||
if ((pass == 0 && (rtm->rtm_flags & RTF_WASCLONED)) ||
|
||||
(pass == 1 && !(rtm->rtm_flags & RTF_WASCLONED))) {
|
||||
LogPrintf(LogDEBUG, "DeleteIfRoutes: Remove it (pass %d)\n", pass);
|
||||
log_Printf(LogDEBUG, "route_IfDelete: Remove it (pass %d)\n", pass);
|
||||
bundle_SetRoute(bundle, RTM_DELETE, sa_dst, sa_none, sa_none, 0);
|
||||
} else
|
||||
LogPrintf(LogDEBUG, "DeleteIfRoutes: Skip it (pass %d)\n", pass);
|
||||
log_Printf(LogDEBUG, "route_IfDelete: Skip it (pass %d)\n", pass);
|
||||
} else
|
||||
LogPrintf(LogDEBUG,
|
||||
"DeleteIfRoutes: Can't remove routes of %d family !\n",
|
||||
log_Printf(LogDEBUG,
|
||||
"route_IfDelete: Can't remove routes of %d family !\n",
|
||||
sa->sa_family);
|
||||
}
|
||||
}
|
||||
|
@ -17,7 +17,7 @@
|
||||
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* $Id: route.h,v 1.10.2.3 1998/02/07 20:50:08 brian Exp $
|
||||
* $Id: route.h,v 1.10.2.4 1998/04/07 00:54:17 brian Exp $
|
||||
*
|
||||
*/
|
||||
|
||||
@ -25,6 +25,6 @@ struct bundle;
|
||||
struct cmdargs;
|
||||
|
||||
extern int GetIfIndex(char *);
|
||||
extern int ShowRoute(struct cmdargs const *);
|
||||
extern void DeleteIfRoutes(struct bundle *, int);
|
||||
extern int route_Show(struct cmdargs const *);
|
||||
extern void route_IfDelete(struct bundle *, int);
|
||||
extern const char *Index2Nam(int);
|
||||
|
@ -23,7 +23,7 @@
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $Id: server.c,v 1.16.2.16 1998/04/18 01:01:28 brian Exp $
|
||||
* $Id: server.c,v 1.16.2.17 1998/04/28 01:25:41 brian Exp $
|
||||
*/
|
||||
|
||||
#include <sys/types.h>
|
||||
@ -100,24 +100,24 @@ server_Read(struct descriptor *d, struct bundle *bundle, const fd_set *fdset)
|
||||
|
||||
wfd = accept(s->fd, sa, &ssize);
|
||||
if (wfd < 0) {
|
||||
LogPrintf(LogERROR, "server_Read: accept(): %s\n", strerror(errno));
|
||||
log_Printf(LogERROR, "server_Read: accept(): %s\n", strerror(errno));
|
||||
return;
|
||||
}
|
||||
|
||||
switch (sa->sa_family) {
|
||||
case AF_LOCAL:
|
||||
LogPrintf(LogPHASE, "Connected to local client.\n");
|
||||
log_Printf(LogPHASE, "Connected to local client.\n");
|
||||
break;
|
||||
|
||||
case AF_INET:
|
||||
if (ntohs(in->sin_port) < 1024) {
|
||||
LogPrintf(LogALERT, "Rejected client connection from %s:%u"
|
||||
log_Printf(LogALERT, "Rejected client connection from %s:%u"
|
||||
"(invalid port number) !\n",
|
||||
inet_ntoa(in->sin_addr), ntohs(in->sin_port));
|
||||
close(wfd);
|
||||
return;
|
||||
}
|
||||
LogPrintf(LogPHASE, "Connected to client from %s:%u\n",
|
||||
log_Printf(LogPHASE, "Connected to client from %s:%u\n",
|
||||
inet_ntoa(in->sin_addr), in->sin_port);
|
||||
break;
|
||||
|
||||
@ -152,7 +152,7 @@ static void
|
||||
server_Write(struct descriptor *d, struct bundle *bundle, const fd_set *fdset)
|
||||
{
|
||||
/* We never want to write here ! */
|
||||
LogPrintf(LogERROR, "server_Write: Internal error: Bad call !\n");
|
||||
log_Printf(LogERROR, "server_Write: Internal error: Bad call !\n");
|
||||
}
|
||||
|
||||
struct server server = {
|
||||
@ -168,20 +168,20 @@ struct server server = {
|
||||
};
|
||||
|
||||
int
|
||||
ServerLocalOpen(struct bundle *bundle, const char *name, mode_t mask)
|
||||
server_LocalOpen(struct bundle *bundle, const char *name, mode_t mask)
|
||||
{
|
||||
int s;
|
||||
|
||||
if (server.rm && !strcmp(server.rm, name)) {
|
||||
if (chmod(server.rm, mask))
|
||||
LogPrintf(LogERROR, "Local: chmod: %s\n", strerror(errno));
|
||||
log_Printf(LogERROR, "Local: chmod: %s\n", strerror(errno));
|
||||
return 0;
|
||||
}
|
||||
|
||||
memset(&server.ifsun, '\0', sizeof server.ifsun);
|
||||
server.ifsun.sun_len = strlen(name);
|
||||
if (server.ifsun.sun_len > sizeof server.ifsun.sun_path - 1) {
|
||||
LogPrintf(LogERROR, "Local: %s: Path too long\n", name);
|
||||
log_Printf(LogERROR, "Local: %s: Path too long\n", name);
|
||||
return 2;
|
||||
}
|
||||
server.ifsun.sun_family = AF_LOCAL;
|
||||
@ -189,7 +189,7 @@ ServerLocalOpen(struct bundle *bundle, const char *name, mode_t mask)
|
||||
|
||||
s = ID0socket(PF_LOCAL, SOCK_STREAM, 0);
|
||||
if (s < 0) {
|
||||
LogPrintf(LogERROR, "Local: socket: %s\n", strerror(errno));
|
||||
log_Printf(LogERROR, "Local: socket: %s\n", strerror(errno));
|
||||
return 3;
|
||||
}
|
||||
setsockopt(s, SOL_SOCKET, SO_REUSEADDR, &s, sizeof s);
|
||||
@ -198,27 +198,27 @@ ServerLocalOpen(struct bundle *bundle, const char *name, mode_t mask)
|
||||
if (bind(s, (struct sockaddr *)&server.ifsun, sizeof server.ifsun) < 0) {
|
||||
if (mask != (mode_t)-1)
|
||||
umask(mask);
|
||||
LogPrintf(LogWARN, "Local: bind: %s\n", strerror(errno));
|
||||
log_Printf(LogWARN, "Local: bind: %s\n", strerror(errno));
|
||||
close(s);
|
||||
return 4;
|
||||
}
|
||||
if (mask != (mode_t)-1)
|
||||
umask(mask);
|
||||
if (listen(s, 5) != 0) {
|
||||
LogPrintf(LogERROR, "Local: Unable to listen to socket - BUNDLE overload?\n");
|
||||
log_Printf(LogERROR, "Local: Unable to listen to socket - BUNDLE overload?\n");
|
||||
close(s);
|
||||
ID0unlink(name);
|
||||
return 5;
|
||||
}
|
||||
ServerClose(bundle);
|
||||
server_Close(bundle);
|
||||
server.fd = s;
|
||||
server.rm = server.ifsun.sun_path;
|
||||
LogPrintf(LogPHASE, "Listening at local socket %s.\n", name);
|
||||
log_Printf(LogPHASE, "Listening at local socket %s.\n", name);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
ServerTcpOpen(struct bundle *bundle, int port)
|
||||
server_TcpOpen(struct bundle *bundle, int port)
|
||||
{
|
||||
struct sockaddr_in ifsin;
|
||||
int s;
|
||||
@ -228,7 +228,7 @@ ServerTcpOpen(struct bundle *bundle, int port)
|
||||
|
||||
s = ID0socket(PF_INET, SOCK_STREAM, 0);
|
||||
if (s < 0) {
|
||||
LogPrintf(LogERROR, "Tcp: socket: %s\n", strerror(errno));
|
||||
log_Printf(LogERROR, "Tcp: socket: %s\n", strerror(errno));
|
||||
return 7;
|
||||
}
|
||||
memset(&ifsin, '\0', sizeof ifsin);
|
||||
@ -237,24 +237,24 @@ ServerTcpOpen(struct bundle *bundle, int port)
|
||||
ifsin.sin_port = htons(port);
|
||||
setsockopt(s, SOL_SOCKET, SO_REUSEADDR, &s, sizeof s);
|
||||
if (bind(s, (struct sockaddr *)&ifsin, sizeof ifsin) < 0) {
|
||||
LogPrintf(LogWARN, "Tcp: bind: %s\n", strerror(errno));
|
||||
log_Printf(LogWARN, "Tcp: bind: %s\n", strerror(errno));
|
||||
close(s);
|
||||
return 8;
|
||||
}
|
||||
if (listen(s, 5) != 0) {
|
||||
LogPrintf(LogERROR, "Tcp: Unable to listen to socket - BUNDLE overload?\n");
|
||||
log_Printf(LogERROR, "Tcp: Unable to listen to socket - BUNDLE overload?\n");
|
||||
close(s);
|
||||
return 9;
|
||||
}
|
||||
ServerClose(bundle);
|
||||
server_Close(bundle);
|
||||
server.fd = s;
|
||||
server.port = port;
|
||||
LogPrintf(LogPHASE, "Listening at port %d.\n", port);
|
||||
log_Printf(LogPHASE, "Listening at port %d.\n", port);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
ServerClose(struct bundle *bundle)
|
||||
server_Close(struct bundle *bundle)
|
||||
{
|
||||
if (server.fd >= 0) {
|
||||
close(server.fd);
|
||||
|
@ -23,7 +23,7 @@
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $Id: server.h,v 1.4.2.3 1998/04/07 00:54:18 brian Exp $
|
||||
* $Id: server.h,v 1.4.2.4 1998/04/10 13:19:20 brian Exp $
|
||||
*/
|
||||
|
||||
struct bundle;
|
||||
@ -39,12 +39,11 @@ struct server {
|
||||
u_short port; /* tcp socket */
|
||||
};
|
||||
|
||||
#define server2descriptor(s) (&(s)->desc)
|
||||
#define descriptor2server(d) \
|
||||
((d)->type == SERVER_DESCRIPTOR ? (struct server *)(d) : NULL)
|
||||
|
||||
extern struct server server;
|
||||
|
||||
extern int ServerLocalOpen(struct bundle *, const char *, mode_t);
|
||||
extern int ServerTcpOpen(struct bundle *, int);
|
||||
extern int ServerClose(struct bundle *);
|
||||
extern int server_LocalOpen(struct bundle *, const char *, mode_t);
|
||||
extern int server_TcpOpen(struct bundle *, int);
|
||||
extern int server_Close(struct bundle *);
|
||||
|
@ -23,7 +23,7 @@
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $Id: sig.c,v 1.11.2.3 1998/04/07 00:54:18 brian Exp $
|
||||
* $Id: sig.c,v 1.11.2.4 1998/04/19 23:08:54 brian Exp $
|
||||
*/
|
||||
|
||||
#include <sys/types.h>
|
||||
@ -52,13 +52,13 @@ signal_recorder(int sig)
|
||||
*/
|
||||
|
||||
sig_type
|
||||
pending_signal(int sig, sig_type fn)
|
||||
sig_signal(int sig, sig_type fn)
|
||||
{
|
||||
sig_type Result;
|
||||
|
||||
if (sig <= 0 || sig > NSIG) {
|
||||
/* Oops - we must be a bit out of date (too many sigs ?) */
|
||||
LogPrintf(LogALERT, "Eeek! %s:%d: I must be out of date!\n",
|
||||
log_Printf(LogALERT, "Eeek! %s:%d: I must be out of date!\n",
|
||||
__FILE__, __LINE__);
|
||||
return signal(sig, fn);
|
||||
}
|
||||
@ -78,7 +78,7 @@ pending_signal(int sig, sig_type fn)
|
||||
/* Call the handlers for any pending signals */
|
||||
|
||||
void
|
||||
handle_signals()
|
||||
sig_Handle()
|
||||
{
|
||||
int sig;
|
||||
int got;
|
||||
|
@ -23,13 +23,13 @@
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $Id$
|
||||
* $Id: sig.h,v 1.11 1997/12/21 12:11:09 brian Exp $
|
||||
*/
|
||||
|
||||
typedef void (*sig_type)(int);
|
||||
|
||||
/* Call this instead of signal() */
|
||||
extern sig_type pending_signal(int, sig_type);
|
||||
extern sig_type sig_signal(int, sig_type);
|
||||
|
||||
/* Call this when you want things to *actually* happen */
|
||||
extern void handle_signals(void);
|
||||
extern void sig_Handle(void);
|
||||
|
@ -17,7 +17,7 @@
|
||||
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* $Id: slcompress.c,v 1.15.2.9 1998/04/25 10:49:48 brian Exp $
|
||||
* $Id: slcompress.c,v 1.15.2.10 1998/04/28 01:25:43 brian Exp $
|
||||
*
|
||||
* Van Jacobson (van@helios.ee.lbl.gov), Dec 31, 1989:
|
||||
* - Initial distribution.
|
||||
@ -150,15 +150,15 @@ sl_compress_tcp(struct mbuf * m,
|
||||
* the caller has already made sure the packet is IP proto TCP).
|
||||
*/
|
||||
if ((ip->ip_off & htons(0x3fff)) || m->cnt < 40) {
|
||||
LogPrintf(LogDEBUG, "??? 1 ip_off = %x, cnt = %d\n",
|
||||
log_Printf(LogDEBUG, "??? 1 ip_off = %x, cnt = %d\n",
|
||||
ip->ip_off, m->cnt);
|
||||
LogDumpBp(LogDEBUG, "", m);
|
||||
log_DumpBp(LogDEBUG, "", m);
|
||||
return (TYPE_IP);
|
||||
}
|
||||
th = (struct tcphdr *) & ((int *) ip)[hlen];
|
||||
if ((th->th_flags & (TH_SYN | TH_FIN | TH_RST | TH_ACK)) != TH_ACK) {
|
||||
LogPrintf(LogDEBUG, "??? 2 th_flags = %x\n", th->th_flags);
|
||||
LogDumpBp(LogDEBUG, "", m);
|
||||
log_Printf(LogDEBUG, "??? 2 th_flags = %x\n", th->th_flags);
|
||||
log_DumpBp(LogDEBUG, "", m);
|
||||
return (TYPE_IP);
|
||||
}
|
||||
|
||||
@ -448,7 +448,7 @@ sl_uncompress_tcp(u_char ** bufp, int len, u_int type,
|
||||
slstat->sls_compressedin++;
|
||||
cp = *bufp;
|
||||
changes = *cp++;
|
||||
LogPrintf(LogDEBUG, "compressed: changes = %02x\n", changes);
|
||||
log_Printf(LogDEBUG, "compressed: changes = %02x\n", changes);
|
||||
if (changes & NEW_C) {
|
||||
|
||||
/*
|
||||
@ -508,7 +508,7 @@ sl_uncompress_tcp(u_char ** bufp, int len, u_int type,
|
||||
if (changes & NEW_A)
|
||||
DECODEL(th->th_ack)
|
||||
if (changes & NEW_S) {
|
||||
LogPrintf(LogDEBUG, "NEW_S: %02x, %02x, %02x\n",
|
||||
log_Printf(LogDEBUG, "NEW_S: %02x, %02x, %02x\n",
|
||||
*cp, cp[1], cp[2]);
|
||||
DECODEL(th->th_seq)
|
||||
}
|
||||
@ -519,7 +519,7 @@ sl_uncompress_tcp(u_char ** bufp, int len, u_int type,
|
||||
} else
|
||||
cs->cs_ip.ip_id = htons(ntohs(cs->cs_ip.ip_id) + 1);
|
||||
|
||||
LogPrintf(LogDEBUG, "Uncompress: id = %04x, seq = %08lx\n",
|
||||
log_Printf(LogDEBUG, "Uncompress: id = %04x, seq = %08lx\n",
|
||||
cs->cs_ip.ip_id, (u_long)ntohl(th->th_seq));
|
||||
|
||||
/*
|
||||
@ -571,7 +571,7 @@ sl_uncompress_tcp(u_char ** bufp, int len, u_int type,
|
||||
}
|
||||
|
||||
int
|
||||
ReportCompress(struct cmdargs const *arg)
|
||||
sl_Show(struct cmdargs const *arg)
|
||||
{
|
||||
prompt_Printf(arg->prompt, "VJ compression statistics:\n");
|
||||
prompt_Printf(arg->prompt, " Out: %d (compress) / %d (total)",
|
||||
|
@ -16,7 +16,7 @@
|
||||
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* $Id: slcompress.h,v 1.10.2.3 1998/03/16 22:54:26 brian Exp $
|
||||
* $Id: slcompress.h,v 1.10.2.4 1998/04/07 00:54:20 brian Exp $
|
||||
*
|
||||
* Van Jacobson (van@helios.ee.lbl.gov), Dec 31, 1989:
|
||||
* - Initial distribution.
|
||||
@ -146,4 +146,4 @@ extern u_char sl_compress_tcp(struct mbuf *, struct ip *, struct slcompress *,
|
||||
struct slstat *, int);
|
||||
extern int sl_uncompress_tcp(u_char **, int, u_int, struct slcompress *,
|
||||
struct slstat *);
|
||||
extern int ReportCompress(struct cmdargs const *);
|
||||
extern int sl_Show(struct cmdargs const *);
|
||||
|
@ -17,7 +17,7 @@
|
||||
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* $Id: systems.c,v 1.35.2.7 1998/04/14 23:17:11 brian Exp $
|
||||
* $Id: systems.c,v 1.35.2.8 1998/04/30 23:53:56 brian Exp $
|
||||
*
|
||||
* TODO:
|
||||
*/
|
||||
@ -34,7 +34,6 @@
|
||||
#include "log.h"
|
||||
#include "id.h"
|
||||
#include "defs.h"
|
||||
#include "pathnames.h"
|
||||
#include "systems.h"
|
||||
|
||||
#define issep(ch) ((ch) == ' ' || (ch) == '\t')
|
||||
@ -48,7 +47,7 @@ OpenSecret(const char *file)
|
||||
snprintf(line, sizeof line, "%s/%s", _PATH_PPP, file);
|
||||
fp = ID0fopen(line, "r");
|
||||
if (fp == NULL)
|
||||
LogPrintf(LogWARN, "OpenSecret: Can't open %s.\n", line);
|
||||
log_Printf(LogWARN, "OpenSecret: Can't open %s.\n", line);
|
||||
return (fp);
|
||||
}
|
||||
|
||||
@ -157,7 +156,7 @@ DecodeCtrlCommand(char *line, char *arg)
|
||||
return CTRL_UNKNOWN;
|
||||
}
|
||||
|
||||
/* Initialised in ValidSystem(), set in ReadSystem(), used by ValidSystem() */
|
||||
/* Initialised in system_IsValid(), set in ReadSystem(), used by system_IsValid() */
|
||||
static int modeok;
|
||||
static int userok;
|
||||
static int modereq;
|
||||
@ -165,7 +164,7 @@ static int modereq;
|
||||
int
|
||||
AllowUsers(struct cmdargs const *arg)
|
||||
{
|
||||
/* arg->bundle may be NULL (see ValidSystem()) ! */
|
||||
/* arg->bundle may be NULL (see system_IsValid()) ! */
|
||||
int f;
|
||||
char *user;
|
||||
|
||||
@ -210,7 +209,7 @@ mode2Nam(int mode)
|
||||
int
|
||||
AllowModes(struct cmdargs const *arg)
|
||||
{
|
||||
/* arg->bundle may be NULL (see ValidSystem()) ! */
|
||||
/* arg->bundle may be NULL (see system_IsValid()) ! */
|
||||
int f;
|
||||
int m;
|
||||
int allowed;
|
||||
@ -223,7 +222,7 @@ AllowModes(struct cmdargs const *arg)
|
||||
break;
|
||||
}
|
||||
if (modes[m].mode == 0)
|
||||
LogPrintf(LogWARN, "allow modes: %s: Invalid mode\n", arg->argv[f]);
|
||||
log_Printf(LogWARN, "allow modes: %s: Invalid mode\n", arg->argv[f]);
|
||||
}
|
||||
|
||||
modeok = modereq & allowed ? 1 : 0;
|
||||
@ -294,10 +293,10 @@ ReadSystem(struct bundle *bundle, const char *name, const char *file,
|
||||
snprintf(filename, sizeof filename, "%s/%s", _PATH_PPP, file);
|
||||
fp = ID0fopen(filename, "r");
|
||||
if (fp == NULL) {
|
||||
LogPrintf(LogDEBUG, "ReadSystem: Can't open %s.\n", filename);
|
||||
log_Printf(LogDEBUG, "ReadSystem: Can't open %s.\n", filename);
|
||||
return (-1);
|
||||
}
|
||||
LogPrintf(LogDEBUG, "ReadSystem: Checking %s (%s).\n", name, filename);
|
||||
log_Printf(LogDEBUG, "ReadSystem: Checking %s (%s).\n", name, filename);
|
||||
|
||||
linenum = 0;
|
||||
while ((n = xgets(line, sizeof line, fp))) {
|
||||
@ -314,14 +313,14 @@ ReadSystem(struct bundle *bundle, const char *name, const char *file,
|
||||
case '!':
|
||||
switch (DecodeCtrlCommand(cp+1, arg)) {
|
||||
case CTRL_INCLUDE:
|
||||
LogPrintf(LogCOMMAND, "%s: Including \"%s\"\n", filename, arg);
|
||||
log_Printf(LogCOMMAND, "%s: Including \"%s\"\n", filename, arg);
|
||||
n = ReadSystem(bundle, name, arg, doexec, prompt);
|
||||
LogPrintf(LogCOMMAND, "%s: Done include of \"%s\"\n", filename, arg);
|
||||
log_Printf(LogCOMMAND, "%s: Done include of \"%s\"\n", filename, arg);
|
||||
if (!n)
|
||||
return 0; /* got it */
|
||||
break;
|
||||
default:
|
||||
LogPrintf(LogWARN, "%s: %s: Invalid command\n", filename, cp);
|
||||
log_Printf(LogWARN, "%s: %s: Invalid command\n", filename, cp);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
@ -329,7 +328,7 @@ ReadSystem(struct bundle *bundle, const char *name, const char *file,
|
||||
default:
|
||||
wp = strchr(cp, ':');
|
||||
if (wp == NULL || wp[1] != '\0') {
|
||||
LogPrintf(LogWARN, "Bad rule in %s (line %d) - missing colon.\n",
|
||||
log_Printf(LogWARN, "Bad rule in %s (line %d) - missing colon.\n",
|
||||
filename, linenum);
|
||||
continue;
|
||||
}
|
||||
@ -350,10 +349,10 @@ ReadSystem(struct bundle *bundle, const char *name, const char *file,
|
||||
break;
|
||||
|
||||
len = strlen(cp);
|
||||
InterpretCommand(cp, len, &argc, &argv);
|
||||
command_Interpret(cp, len, &argc, &argv);
|
||||
allowcmd = argc > 0 && !strcasecmp(*argv, "allow");
|
||||
if ((!doexec && allowcmd) || (doexec && !allowcmd))
|
||||
RunCommand(bundle, argc, (char const *const *)argv, prompt, name);
|
||||
command_Run(bundle, argc, (char const *const *)argv, prompt, name);
|
||||
}
|
||||
|
||||
fclose(fp); /* everything read - get out */
|
||||
@ -367,7 +366,7 @@ ReadSystem(struct bundle *bundle, const char *name, const char *file,
|
||||
}
|
||||
|
||||
int
|
||||
ValidSystem(const char *name, struct prompt *prompt, int mode)
|
||||
system_IsValid(const char *name, struct prompt *prompt, int mode)
|
||||
{
|
||||
/*
|
||||
* Note: The ReadSystem() calls only result in calls to the Allow*
|
||||
@ -385,7 +384,7 @@ ValidSystem(const char *name, struct prompt *prompt, int mode)
|
||||
}
|
||||
|
||||
int
|
||||
SelectSystem(struct bundle *bundle, const char *name, const char *file,
|
||||
system_Select(struct bundle *bundle, const char *name, const char *file,
|
||||
struct prompt *prompt)
|
||||
{
|
||||
userok = modeok = 1;
|
||||
|
@ -17,7 +17,7 @@
|
||||
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* $Id: systems.h,v 1.10.2.3 1998/04/07 00:54:21 brian Exp $
|
||||
* $Id: systems.h,v 1.10.2.4 1998/04/10 13:19:22 brian Exp $
|
||||
*
|
||||
*/
|
||||
|
||||
@ -25,9 +25,9 @@ struct prompt;
|
||||
struct bundle;
|
||||
struct cmdargs;
|
||||
|
||||
extern int SelectSystem(struct bundle *bundle, const char *, const char *,
|
||||
extern int system_Select(struct bundle *bundle, const char *, const char *,
|
||||
struct prompt *);
|
||||
extern int ValidSystem(const char *, struct prompt *, int);
|
||||
extern int system_IsValid(const char *, struct prompt *, int);
|
||||
extern FILE *OpenSecret(const char *);
|
||||
extern void CloseSecret(FILE *);
|
||||
extern int AllowUsers(struct cmdargs const *);
|
||||
|
@ -23,7 +23,7 @@
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $Id: throughput.c,v 1.4.4.7 1998/04/16 00:26:18 brian Exp $
|
||||
* $Id: throughput.c,v 1.4.4.8 1998/04/19 15:24:50 brian Exp $
|
||||
*/
|
||||
|
||||
#include <sys/types.h>
|
||||
@ -86,18 +86,18 @@ throughput_log(struct pppThroughput *t, int level, const char *title)
|
||||
|
||||
secs_up = t->uptime ? time(NULL) - t->uptime : 0;
|
||||
if (title)
|
||||
LogPrintf(level, "%s: Connect time: %d secs: %ld octets in, %ld octets"
|
||||
log_Printf(level, "%s: Connect time: %d secs: %ld octets in, %ld octets"
|
||||
" out\n", title, secs_up, t->OctetsIn, t->OctetsOut);
|
||||
else
|
||||
LogPrintf(level, "Connect time: %d secs: %ld octets in, %ld octets out\n",
|
||||
log_Printf(level, "Connect time: %d secs: %ld octets in, %ld octets out\n",
|
||||
secs_up, t->OctetsIn, t->OctetsOut);
|
||||
if (secs_up == 0)
|
||||
secs_up = 1;
|
||||
if (t->rolling)
|
||||
LogPrintf(level, " total %ld bytes/sec, peak %d bytes/sec\n",
|
||||
log_Printf(level, " total %ld bytes/sec, peak %d bytes/sec\n",
|
||||
(t->OctetsIn+t->OctetsOut)/secs_up, t->BestOctetsPerSecond);
|
||||
else
|
||||
LogPrintf(level, " total %ld bytes/sec\n",
|
||||
log_Printf(level, " total %ld bytes/sec\n",
|
||||
(t->OctetsIn+t->OctetsOut)/secs_up);
|
||||
}
|
||||
}
|
||||
@ -108,7 +108,7 @@ throughput_sampler(void *v)
|
||||
struct pppThroughput *t = (struct pppThroughput *)v;
|
||||
u_long old;
|
||||
|
||||
StopTimer(&t->Timer);
|
||||
timer_Stop(&t->Timer);
|
||||
|
||||
old = t->SampleOctets[t->nSample];
|
||||
t->SampleOctets[t->nSample] = t->OctetsIn + t->OctetsOut;
|
||||
@ -118,13 +118,13 @@ throughput_sampler(void *v)
|
||||
if (++t->nSample == SAMPLE_PERIOD)
|
||||
t->nSample = 0;
|
||||
|
||||
StartTimer(&t->Timer);
|
||||
timer_Start(&t->Timer);
|
||||
}
|
||||
|
||||
void
|
||||
throughput_start(struct pppThroughput *t, const char *name, int rolling)
|
||||
{
|
||||
StopTimer(&t->Timer);
|
||||
timer_Stop(&t->Timer);
|
||||
throughput_init(t);
|
||||
t->rolling = rolling ? 1 : 0;
|
||||
time(&t->uptime);
|
||||
@ -133,14 +133,14 @@ throughput_start(struct pppThroughput *t, const char *name, int rolling)
|
||||
t->Timer.func = throughput_sampler;
|
||||
t->Timer.name = name;
|
||||
t->Timer.arg = t;
|
||||
StartTimer(&t->Timer);
|
||||
timer_Start(&t->Timer);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
throughput_stop(struct pppThroughput *t)
|
||||
{
|
||||
StopTimer(&t->Timer);
|
||||
timer_Stop(&t->Timer);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -17,7 +17,7 @@
|
||||
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* $Id: timer.c,v 1.27.2.8 1998/04/21 01:02:32 brian Exp $
|
||||
* $Id: timer.c,v 1.27.2.9 1998/04/30 23:53:56 brian Exp $
|
||||
*
|
||||
* TODO:
|
||||
*/
|
||||
@ -51,7 +51,7 @@ tState2Nam(u_int state)
|
||||
}
|
||||
|
||||
void
|
||||
StopTimer(struct pppTimer * tp)
|
||||
timer_Stop(struct pppTimer * tp)
|
||||
{
|
||||
int omask;
|
||||
|
||||
@ -61,7 +61,7 @@ StopTimer(struct pppTimer * tp)
|
||||
}
|
||||
|
||||
void
|
||||
StartTimer(struct pppTimer * tp)
|
||||
timer_Start(struct pppTimer * tp)
|
||||
{
|
||||
struct pppTimer *t, *pt;
|
||||
u_long ticks = 0;
|
||||
@ -73,7 +73,7 @@ StartTimer(struct pppTimer * tp)
|
||||
StopTimerNoBlock(tp);
|
||||
|
||||
if (tp->load == 0) {
|
||||
LogPrintf(LogTIMER, "%s timer[%p] has 0 load!\n", tp->name, tp);
|
||||
log_Printf(LogTIMER, "%s timer[%p] has 0 load!\n", tp->name, tp);
|
||||
sigsetmask(omask);
|
||||
return;
|
||||
}
|
||||
@ -89,10 +89,10 @@ StartTimer(struct pppTimer * tp)
|
||||
tp->rest = tp->load - ticks;
|
||||
|
||||
if (t)
|
||||
LogPrintf(LogTIMER, "StartTimer: Inserting %s timer[%p] before %s "
|
||||
log_Printf(LogTIMER, "timer_Start: Inserting %s timer[%p] before %s "
|
||||
"timer[%p], delta = %ld\n", tp->name, tp, t->name, t, tp->rest);
|
||||
else
|
||||
LogPrintf(LogTIMER, "StartTimer: Inserting %s timer[%p]\n", tp->name, tp);
|
||||
log_Printf(LogTIMER, "timer_Start: Inserting %s timer[%p]\n", tp->name, tp);
|
||||
|
||||
/* Insert given *tp just before *t */
|
||||
tp->next = t;
|
||||
@ -132,12 +132,12 @@ StopTimerNoBlock(struct pppTimer * tp)
|
||||
} else {
|
||||
TimerList = t->next;
|
||||
if (TimerList == NULL) /* Last one ? */
|
||||
TermTimerService(); /* Terminate Timer Service */
|
||||
timer_TermService(); /* Terminate Timer Service */
|
||||
}
|
||||
if (t->next)
|
||||
t->next->rest += tp->rest;
|
||||
} else
|
||||
LogPrintf(LogERROR, "Oops, %s timer not found!!\n", tp->name);
|
||||
log_Printf(LogERROR, "Oops, %s timer not found!!\n", tp->name);
|
||||
|
||||
tp->next = NULL;
|
||||
tp->state = TIMER_STOPPED;
|
||||
@ -148,12 +148,12 @@ TimerService(void)
|
||||
{
|
||||
struct pppTimer *tp, *exp, *wt;
|
||||
|
||||
if (LogIsKept(LogTIMER)) {
|
||||
if (log_IsKept(LogTIMER)) {
|
||||
static time_t t;
|
||||
time_t n = time(NULL); /* Only show timers every second */
|
||||
|
||||
if (n > t)
|
||||
ShowTimers(LogTIMER, NULL);
|
||||
timer_Show(LogTIMER, NULL);
|
||||
t = n;
|
||||
}
|
||||
tp = TimerList;
|
||||
@ -175,14 +175,14 @@ TimerService(void)
|
||||
|
||||
TimerList = tp;
|
||||
if (TimerList == NULL) /* No timers ? */
|
||||
TermTimerService(); /* Terminate Timer Service */
|
||||
timer_TermService(); /* Terminate Timer Service */
|
||||
|
||||
/*
|
||||
* Process all expired timers.
|
||||
*/
|
||||
while (exp) {
|
||||
#ifdef notdef
|
||||
StopTimer(exp);
|
||||
timer_Stop(exp);
|
||||
#endif
|
||||
if (exp->func)
|
||||
(*exp->func) (exp->arg);
|
||||
@ -198,7 +198,7 @@ TimerService(void)
|
||||
}
|
||||
|
||||
void
|
||||
ShowTimers(int LogLevel, struct prompt *prompt)
|
||||
timer_Show(int LogLevel, struct prompt *prompt)
|
||||
{
|
||||
struct pppTimer *pt;
|
||||
int rest = 0;
|
||||
@ -211,18 +211,18 @@ ShowTimers(int LogLevel, struct prompt *prompt)
|
||||
HSECS(rest), tState2Nam(pt->state)
|
||||
|
||||
if (!prompt)
|
||||
LogPrintf(LogLevel, "---- Begin of Timer Service List---\n");
|
||||
log_Printf(LogLevel, "---- Begin of Timer Service List---\n");
|
||||
|
||||
for (pt = TimerList; pt; pt = pt->next) {
|
||||
rest += pt->rest;
|
||||
if (prompt)
|
||||
prompt_Printf(prompt, DISP);
|
||||
else
|
||||
LogPrintf(LogLevel, DISP);
|
||||
log_Printf(LogLevel, DISP);
|
||||
}
|
||||
|
||||
if (!prompt)
|
||||
LogPrintf(LogLevel, "---- End of Timer Service List ---\n");
|
||||
log_Printf(LogLevel, "---- End of Timer Service List ---\n");
|
||||
}
|
||||
|
||||
static void
|
||||
@ -245,7 +245,7 @@ nointr_dosleep(u_int sec, u_int usec)
|
||||
(to.tv_sec == et.tv_sec + 1 && to.tv_usec > et.tv_usec) ||
|
||||
to.tv_sec < st.tv_sec ||
|
||||
(to.tv_sec == st.tv_sec && to.tv_usec < st.tv_usec)) {
|
||||
LogPrintf(LogWARN, "Clock adjusted between %ld and %ld seconds "
|
||||
log_Printf(LogWARN, "Clock adjusted between %ld and %ld seconds "
|
||||
"during sleep !\n",
|
||||
to.tv_sec - st.tv_sec, sec + to.tv_sec - st.tv_sec);
|
||||
st.tv_sec = to.tv_sec;
|
||||
@ -286,21 +286,21 @@ InitTimerService()
|
||||
{
|
||||
struct itimerval itimer;
|
||||
|
||||
pending_signal(SIGALRM, (void (*) (int)) TimerService);
|
||||
sig_signal(SIGALRM, (void (*) (int)) TimerService);
|
||||
itimer.it_interval.tv_sec = itimer.it_value.tv_sec = 0;
|
||||
itimer.it_interval.tv_usec = itimer.it_value.tv_usec = TICKUNIT;
|
||||
if (setitimer(ITIMER_REAL, &itimer, NULL) == -1)
|
||||
LogPrintf(LogERROR, "Unable to set itimer.\n");
|
||||
log_Printf(LogERROR, "Unable to set itimer.\n");
|
||||
}
|
||||
|
||||
void
|
||||
TermTimerService(void)
|
||||
timer_TermService(void)
|
||||
{
|
||||
struct itimerval itimer;
|
||||
|
||||
itimer.it_interval.tv_usec = itimer.it_interval.tv_sec = 0;
|
||||
itimer.it_value.tv_usec = itimer.it_value.tv_sec = 0;
|
||||
if (setitimer(ITIMER_REAL, &itimer, NULL) == -1)
|
||||
LogPrintf(LogERROR, "Unable to set itimer.\n");
|
||||
pending_signal(SIGALRM, SIG_IGN);
|
||||
log_Printf(LogERROR, "Unable to set itimer.\n");
|
||||
sig_signal(SIGALRM, SIG_IGN);
|
||||
}
|
||||
|
@ -15,7 +15,7 @@
|
||||
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* $Id: timer.h,v 1.5.4.2 1998/04/03 19:26:01 brian Exp $
|
||||
* $Id: timer.h,v 1.5.4.3 1998/04/07 00:54:22 brian Exp $
|
||||
*
|
||||
* TODO:
|
||||
*/
|
||||
@ -40,9 +40,9 @@ struct pppTimer {
|
||||
|
||||
struct prompt;
|
||||
|
||||
extern void StartTimer(struct pppTimer *);
|
||||
extern void StopTimer(struct pppTimer *);
|
||||
extern void TermTimerService(void);
|
||||
extern void ShowTimers(int LogLevel, struct prompt *);
|
||||
extern void timer_Start(struct pppTimer *);
|
||||
extern void timer_Stop(struct pppTimer *);
|
||||
extern void timer_TermService(void);
|
||||
extern void timer_Show(int LogLevel, struct prompt *);
|
||||
extern void nointr_sleep(u_int);
|
||||
extern void nointr_usleep(u_int);
|
||||
|
@ -23,7 +23,7 @@
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $Id: tun.c,v 1.6.4.14 1998/04/25 10:49:52 brian Exp $
|
||||
* $Id: tun.c,v 1.6.4.15 1998/04/28 01:25:44 brian Exp $
|
||||
*/
|
||||
|
||||
#include <sys/types.h>
|
||||
@ -71,6 +71,6 @@ tun_configure(struct bundle *bundle, int mtu, int speed)
|
||||
info.flags = IFF_UP|IFF_POINTOPOINT;
|
||||
#endif
|
||||
if (ioctl(bundle->tun_fd, TUNSIFINFO, &info) < 0)
|
||||
LogPrintf(LogERROR, "tun_configure: ioctl(TUNSIFINFO): %s\n",
|
||||
log_Printf(LogERROR, "tun_configure: ioctl(TUNSIFINFO): %s\n",
|
||||
strerror(errno));
|
||||
}
|
||||
|
@ -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.16.2.14 1998/04/16 00:26:21 brian Exp $
|
||||
* $Id: vjcomp.c,v 1.16.2.15 1998/04/28 01:25:46 brian Exp $
|
||||
*
|
||||
* TODO:
|
||||
*/
|
||||
@ -53,13 +53,13 @@
|
||||
#define MAX_VJHEADER 16 /* Maximum size of compressed header */
|
||||
|
||||
void
|
||||
SendPppFrame(struct link *l, struct mbuf * bp, struct bundle *bundle)
|
||||
vj_SendFrame(struct link *l, struct mbuf * bp, struct bundle *bundle)
|
||||
{
|
||||
int type;
|
||||
u_short proto;
|
||||
u_short cproto = bundle->ncp.ipcp.peer_compproto >> 16;
|
||||
|
||||
LogPrintf(LogDEBUG, "SendPppFrame: proto = %x\n",
|
||||
log_Printf(LogDEBUG, "vj_SendFrame: proto = %x\n",
|
||||
bundle->ncp.ipcp.peer_compproto);
|
||||
if (((struct ip *) MBUF_CTOP(bp))->ip_p == IPPROTO_TCP
|
||||
&& cproto == PROTO_VJCOMP) {
|
||||
@ -67,7 +67,7 @@ SendPppFrame(struct link *l, struct mbuf * bp, struct bundle *bundle)
|
||||
&bundle->ncp.ipcp.vj.cslc,
|
||||
&bundle->ncp.ipcp.vj.slstat,
|
||||
bundle->ncp.ipcp.peer_compproto & 0xff);
|
||||
LogPrintf(LogDEBUG, "SendPppFrame: type = %x\n", type);
|
||||
log_Printf(LogDEBUG, "vj_SendFrame: type = %x\n", type);
|
||||
switch (type) {
|
||||
case TYPE_IP:
|
||||
proto = PROTO_IP;
|
||||
@ -79,15 +79,15 @@ SendPppFrame(struct link *l, struct mbuf * bp, struct bundle *bundle)
|
||||
proto = PROTO_VJCOMP;
|
||||
break;
|
||||
default:
|
||||
LogPrintf(LogERROR, "Unknown frame type %x\n", type);
|
||||
pfree(bp);
|
||||
log_Printf(LogERROR, "Unknown frame type %x\n", type);
|
||||
mbuf_Free(bp);
|
||||
return;
|
||||
}
|
||||
} else
|
||||
proto = PROTO_IP;
|
||||
|
||||
if (!ccp_Compress(&l->ccp, l, PRI_NORMAL, proto, bp))
|
||||
HdlcOutput(l, PRI_NORMAL, proto, bp);
|
||||
hdlc_Output(l, PRI_NORMAL, proto, bp);
|
||||
}
|
||||
|
||||
static struct mbuf *
|
||||
@ -98,7 +98,7 @@ VjUncompressTcp(struct ipcp *ipcp, struct mbuf * bp, u_char type)
|
||||
struct mbuf *nbp;
|
||||
u_char work[MAX_HDR + MAX_VJHEADER]; /* enough to hold TCP/IP header */
|
||||
|
||||
olen = len = plength(bp);
|
||||
olen = len = mbuf_Length(bp);
|
||||
if (type == TYPE_UNCOMPRESSED_TCP) {
|
||||
|
||||
/*
|
||||
@ -108,7 +108,7 @@ VjUncompressTcp(struct ipcp *ipcp, struct mbuf * bp, u_char type)
|
||||
bufp = MBUF_CTOP(bp);
|
||||
len = sl_uncompress_tcp(&bufp, len, type, &ipcp->vj.cslc, &ipcp->vj.slstat);
|
||||
if (len <= 0) {
|
||||
pfree(bp);
|
||||
mbuf_Free(bp);
|
||||
bp = NULL;
|
||||
}
|
||||
return (bp);
|
||||
@ -123,27 +123,27 @@ VjUncompressTcp(struct ipcp *ipcp, struct mbuf * bp, u_char type)
|
||||
len = MAX_VJHEADER;
|
||||
rlen = len;
|
||||
bufp = work + MAX_HDR;
|
||||
bp = mbread(bp, bufp, rlen);
|
||||
bp = mbuf_Read(bp, bufp, rlen);
|
||||
len = sl_uncompress_tcp(&bufp, olen, type, &ipcp->vj.cslc, &ipcp->vj.slstat);
|
||||
if (len <= 0) {
|
||||
pfree(bp);
|
||||
mbuf_Free(bp);
|
||||
return NULL;
|
||||
}
|
||||
len -= olen;
|
||||
len += rlen;
|
||||
nbp = mballoc(len, MB_VJCOMP);
|
||||
nbp = mbuf_Alloc(len, MB_VJCOMP);
|
||||
memcpy(MBUF_CTOP(nbp), bufp, len);
|
||||
nbp->next = bp;
|
||||
return (nbp);
|
||||
}
|
||||
|
||||
struct mbuf *
|
||||
VjCompInput(struct ipcp *ipcp, struct mbuf *bp, int proto)
|
||||
vj_Input(struct ipcp *ipcp, struct mbuf *bp, int proto)
|
||||
{
|
||||
u_char type;
|
||||
|
||||
LogPrintf(LogDEBUG, "VjCompInput: proto %02x\n", proto);
|
||||
LogDumpBp(LogDEBUG, "Raw packet info:", bp);
|
||||
log_Printf(LogDEBUG, "vj_Input: proto %02x\n", proto);
|
||||
log_DumpBp(LogDEBUG, "Raw packet info:", bp);
|
||||
|
||||
switch (proto) {
|
||||
case PROTO_VJCOMP:
|
||||
@ -153,7 +153,7 @@ VjCompInput(struct ipcp *ipcp, struct mbuf *bp, int proto)
|
||||
type = TYPE_UNCOMPRESSED_TCP;
|
||||
break;
|
||||
default:
|
||||
LogPrintf(LogERROR, "VjCompInput...???\n");
|
||||
log_Printf(LogERROR, "vj_Input...???\n");
|
||||
return (bp);
|
||||
}
|
||||
bp = VjUncompressTcp(ipcp, bp, type);
|
||||
|
@ -23,7 +23,7 @@
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $Id: vjcomp.h,v 1.5.4.4 1998/03/16 22:54:35 brian Exp $
|
||||
* $Id: vjcomp.h,v 1.5.4.5 1998/04/07 00:54:26 brian Exp $
|
||||
*/
|
||||
|
||||
struct mbuf;
|
||||
@ -31,6 +31,6 @@ struct link;
|
||||
struct ipcp;
|
||||
struct bundle;
|
||||
|
||||
extern void SendPppFrame(struct link *, struct mbuf *, struct bundle *);
|
||||
extern struct mbuf *VjCompInput(struct ipcp *, struct mbuf *, int);
|
||||
extern void vj_SendFrame(struct link *, struct mbuf *, struct bundle *);
|
||||
extern struct mbuf *vj_Input(struct ipcp *, struct mbuf *, int);
|
||||
extern const char *vj2asc(u_int32_t);
|
||||
|
Loading…
Reference in New Issue
Block a user