o Add the link name to modem diagnostics.
o Create struct mpserver as part of struct mp. mpserver creates a unix-domain socket based on the peers auth name and endpoint discriminator. If it already exists, ppp will ``pass the link'' over to the owner of the socket, joining it into the bundle of another ppp invocation, otherwise ppp waits for other invocations to pass it links through this socket. The final piece of code will be the code that flattens our datalink info and passes it down this channel (not yet implemented).
This commit is contained in:
parent
107d62e7ac
commit
1fa665f5b3
@ -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.12 1998/04/07 00:53:14 brian Exp $
|
||||
* $Id: arp.c,v 1.27.2.13 1998/04/23 23:50:36 brian Exp $
|
||||
*
|
||||
*/
|
||||
|
||||
@ -35,6 +35,7 @@
|
||||
#include <arpa/inet.h>
|
||||
#include <netinet/in_systm.h>
|
||||
#include <netinet/ip.h>
|
||||
#include <sys/un.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
@ -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.23 1998/04/23 03:22:43 brian Exp $
|
||||
* $Id: auth.c,v 1.27.2.24 1998/04/24 19:15:55 brian Exp $
|
||||
*
|
||||
* TODO:
|
||||
* o Implement check against with registered IP addresses.
|
||||
@ -26,6 +26,7 @@
|
||||
#include <netinet/in.h>
|
||||
#include <netinet/in_systm.h>
|
||||
#include <netinet/ip.h>
|
||||
#include <sys/un.h>
|
||||
|
||||
#include <pwd.h>
|
||||
#include <stdio.h>
|
||||
|
@ -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.62 1998/04/25 10:48:45 brian Exp $
|
||||
* $Id: bundle.c,v 1.1.2.63 1998/04/27 01:40:37 brian Exp $
|
||||
*/
|
||||
|
||||
#include <sys/types.h>
|
||||
@ -36,6 +36,7 @@
|
||||
#include <netinet/in_systm.h>
|
||||
#include <netinet/ip.h>
|
||||
#include <net/if_tun.h>
|
||||
#include <sys/un.h>
|
||||
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
@ -1087,3 +1088,17 @@ bundle_GetLabel(struct bundle *bundle)
|
||||
{
|
||||
return *bundle->cfg.label ? bundle->cfg.label : NULL;
|
||||
}
|
||||
|
||||
void
|
||||
bundle_SendDatalink(struct datalink *dl, int fd)
|
||||
{
|
||||
LogPrintf(LogERROR, "Can't send link yet !\n");
|
||||
close(fd);
|
||||
}
|
||||
|
||||
void
|
||||
bundle_ReceiveDatalink(struct bundle *bundle, int fd)
|
||||
{
|
||||
LogPrintf(LogERROR, "Can't receive link yet !\n");
|
||||
close(fd);
|
||||
}
|
||||
|
@ -23,7 +23,7 @@
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $Id: bundle.h,v 1.1.2.31 1998/04/17 22:05:06 brian Exp $
|
||||
* $Id: bundle.h,v 1.1.2.32 1998/04/23 03:22:45 brian Exp $
|
||||
*/
|
||||
|
||||
#define PHASE_DEAD 0 /* Link is dead */
|
||||
@ -140,3 +140,5 @@ extern void bundle_DatalinkRemove(struct bundle *, struct datalink *);
|
||||
extern void bundle_CleanDatalinks(struct bundle *);
|
||||
extern void bundle_SetLabel(struct bundle *, const char *);
|
||||
extern const char *bundle_GetLabel(struct bundle *);
|
||||
extern void bundle_SendDatalink(struct datalink *, int);
|
||||
extern void bundle_ReceiveDatalink(struct bundle *, int);
|
||||
|
@ -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.38 1998/04/24 19:15:36 brian Exp $
|
||||
* $Id: ccp.c,v 1.30.2.39 1998/04/25 10:48:49 brian Exp $
|
||||
*
|
||||
* TODO:
|
||||
* o Support other compression protocols
|
||||
@ -26,6 +26,7 @@
|
||||
#include <netinet/in.h>
|
||||
#include <netinet/in_systm.h>
|
||||
#include <netinet/ip.h>
|
||||
#include <sys/un.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
@ -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.24 1998/04/16 00:25:52 brian Exp $
|
||||
* $Id: chap.c,v 1.28.2.25 1998/04/24 19:15:58 brian Exp $
|
||||
*
|
||||
* TODO:
|
||||
*/
|
||||
@ -25,15 +25,11 @@
|
||||
#include <netinet/in.h>
|
||||
#include <netinet/in_systm.h>
|
||||
#include <netinet/ip.h>
|
||||
#include <sys/un.h>
|
||||
|
||||
#ifdef HAVE_DES
|
||||
#endif
|
||||
#include <md5.h>
|
||||
#include <stdlib.h>
|
||||
#include <termios.h>
|
||||
#ifdef __OpenBSD__
|
||||
#else
|
||||
#endif
|
||||
|
||||
#include "mbuf.h"
|
||||
#include "log.h"
|
||||
|
@ -23,13 +23,14 @@
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $Id: chat.c,v 1.44.2.24 1998/04/18 23:17:24 brian Exp $
|
||||
* $Id: chat.c,v 1.44.2.25 1998/04/19 15:24:37 brian Exp $
|
||||
*/
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <netinet/in.h>
|
||||
#include <netinet/in_systm.h>
|
||||
#include <netinet/ip.h>
|
||||
#include <sys/un.h>
|
||||
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
|
@ -23,13 +23,14 @@
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $Id: datalink.c,v 1.1.2.47 1998/04/25 00:09:09 brian Exp $
|
||||
* $Id: datalink.c,v 1.1.2.48 1998/04/25 00:09:20 brian Exp $
|
||||
*/
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <netinet/in.h>
|
||||
#include <netinet/in_systm.h>
|
||||
#include <netinet/ip.h>
|
||||
#include <sys/un.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
@ -451,16 +452,21 @@ datalink_GotAuthname(struct datalink *dl, const char *name, int len)
|
||||
void
|
||||
datalink_AuthOk(struct datalink *dl)
|
||||
{
|
||||
/* XXX: Connect to another ppp instance HERE */
|
||||
|
||||
if (dl->physical->link.lcp.want_mrru && dl->physical->link.lcp.his_mrru) {
|
||||
if (!mp_Up(&dl->bundle->ncp.mp, dl->name, &dl->peer,
|
||||
dl->physical->link.lcp.want_mrru,
|
||||
dl->physical->link.lcp.his_mrru,
|
||||
dl->physical->link.lcp.want_shortseq,
|
||||
dl->physical->link.lcp.his_shortseq)) {
|
||||
datalink_AuthNotOk(dl);
|
||||
return;
|
||||
/* we've authenticated in multilink mode ! */
|
||||
switch (mp_Up(&dl->bundle->ncp.mp, dl)) {
|
||||
case MP_LINKSENT:
|
||||
/* We've handed the link off to another ppp ! */
|
||||
return;
|
||||
case MP_UP:
|
||||
AuthSelect(dl->bundle, dl->peer.authname, dl->physical);
|
||||
/* Fall through */
|
||||
case MP_ADDED:
|
||||
/* We're in multilink mode ! */
|
||||
break;
|
||||
case MP_FAILED:
|
||||
datalink_AuthNotOk(dl);
|
||||
return;
|
||||
}
|
||||
} else if (bundle_Phase(dl->bundle) == PHASE_NETWORK) {
|
||||
LogPrintf(LogPHASE, "%s: Already in NETWORK phase\n", dl->name);
|
||||
@ -471,7 +477,6 @@ datalink_AuthOk(struct datalink *dl)
|
||||
ipcp_SetLink(&dl->bundle->ncp.ipcp, &dl->physical->link);
|
||||
}
|
||||
|
||||
AuthSelect(dl->bundle, dl->peer.authname, dl->physical);
|
||||
FsmUp(&dl->physical->link.ccp.fsm);
|
||||
FsmOpen(&dl->physical->link.ccp.fsm);
|
||||
dl->state = DATALINK_OPEN;
|
||||
|
@ -23,7 +23,7 @@
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $Id: descriptor.h,v 1.1.2.8 1998/03/20 19:47:56 brian Exp $
|
||||
* $Id: descriptor.h,v 1.1.2.9 1998/04/07 00:53:38 brian Exp $
|
||||
*/
|
||||
|
||||
#define PHYSICAL_DESCRIPTOR (1)
|
||||
@ -32,6 +32,7 @@
|
||||
#define CHAT_DESCRIPTOR (4)
|
||||
#define DATALINK_DESCRIPTOR (5)
|
||||
#define BUNDLE_DESCRIPTOR (6)
|
||||
#define MPSERVER_DESCRIPTOR (7)
|
||||
|
||||
struct bundle;
|
||||
|
||||
|
@ -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.16 1998/04/16 18:30:51 brian Exp $
|
||||
* $Id: filter.c,v 1.22.2.17 1998/04/25 10:48:59 brian Exp $
|
||||
*
|
||||
* TODO: Shoud send ICMP error message when we discard packets.
|
||||
*/
|
||||
@ -28,6 +28,7 @@
|
||||
#include <netdb.h>
|
||||
#include <netinet/in_systm.h>
|
||||
#include <netinet/ip.h>
|
||||
#include <sys/un.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
@ -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.31 1998/04/23 21:50:07 brian Exp $
|
||||
* $Id: fsm.c,v 1.27.2.32 1998/04/24 19:15:38 brian Exp $
|
||||
*
|
||||
* TODO:
|
||||
*/
|
||||
@ -26,6 +26,7 @@
|
||||
#include <netinet/in.h>
|
||||
#include <netinet/in_systm.h>
|
||||
#include <netinet/ip.h>
|
||||
#include <sys/un.h>
|
||||
|
||||
#include <string.h>
|
||||
#include <termios.h>
|
||||
@ -261,8 +262,9 @@ FsmUp(struct fsm * fp)
|
||||
{
|
||||
switch (fp->state) {
|
||||
case ST_INITIAL:
|
||||
LogPrintf(fp->LogLevel, "FSM: Using \"%s\" as a transport\n",
|
||||
fp->link->name);
|
||||
NewState(fp, ST_CLOSED);
|
||||
LogPrintf(fp->LogLevel, "Using \"%s\" as a transport\n", fp->link->name);
|
||||
break;
|
||||
case ST_STARTING:
|
||||
FsmInitRestartCounter(fp);
|
||||
|
@ -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.28 1998/04/23 21:50:09 brian Exp $
|
||||
* $Id: hdlc.c,v 1.28.2.29 1998/04/24 19:16:03 brian Exp $
|
||||
*
|
||||
* TODO:
|
||||
*/
|
||||
@ -25,6 +25,7 @@
|
||||
#include <netinet/in.h>
|
||||
#include <netinet/in_systm.h>
|
||||
#include <netinet/ip.h>
|
||||
#include <sys/un.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
@ -23,11 +23,12 @@
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $Id: id.c,v 1.6.4.6 1998/04/19 23:08:19 brian Exp $
|
||||
* $Id: id.c,v 1.6.4.7 1998/04/25 10:49:01 brian Exp $
|
||||
*/
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/un.h>
|
||||
|
||||
#include <sys/ioctl.h>
|
||||
#include <fcntl.h>
|
||||
@ -212,3 +213,29 @@ ID0logout(const char *device)
|
||||
LogPrintf(LogERROR, "ID0logout: No longer logged in on %s\n", ut.ut_line);
|
||||
ID0setuser();
|
||||
}
|
||||
|
||||
int
|
||||
ID0bind_un(int s, const struct sockaddr_un *name, int namelen)
|
||||
{
|
||||
int result;
|
||||
|
||||
ID0set0();
|
||||
result = bind(s, (const struct sockaddr *)name, namelen);
|
||||
LogPrintf(LogID0, "%d = bind(%d, \"%s\", %d)\n",
|
||||
result, s, name->sun_path, namelen);
|
||||
ID0setuser();
|
||||
return result;
|
||||
}
|
||||
|
||||
int
|
||||
ID0connect_un(int s, const struct sockaddr_un *name, int namelen)
|
||||
{
|
||||
int result;
|
||||
|
||||
ID0set0();
|
||||
result = connect(s, (const struct sockaddr *)name, namelen);
|
||||
LogPrintf(LogID0, "%d = connect(%d, \"%s\", %d)\n",
|
||||
result, s, name->sun_path, namelen);
|
||||
ID0setuser();
|
||||
return result;
|
||||
}
|
||||
|
@ -23,10 +23,11 @@
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $Id: id.h,v 1.3.4.1 1998/02/19 02:08:47 brian Exp $
|
||||
* $Id: id.h,v 1.3.4.2 1998/04/17 22:05:19 brian Exp $
|
||||
*/
|
||||
|
||||
struct utmp;
|
||||
struct sockaddr_un;
|
||||
|
||||
extern void ID0init(void);
|
||||
extern uid_t ID0realuid(void);
|
||||
@ -40,3 +41,5 @@ extern int ID0uu_lock(const char *);
|
||||
extern int ID0uu_unlock(const char *);
|
||||
extern void ID0login(struct utmp *);
|
||||
extern void ID0logout(const char *);
|
||||
extern int ID0bind_un(int, const struct sockaddr_un *, int);
|
||||
extern int ID0connect_un(int, const struct sockaddr_un *, int);
|
||||
|
@ -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.22 1998/04/16 18:30:53 brian Exp $
|
||||
* $Id: ip.c,v 1.38.2.23 1998/04/25 10:49:04 brian Exp $
|
||||
*
|
||||
* TODO:
|
||||
* o Return ICMP message for filterd packet
|
||||
@ -33,6 +33,7 @@
|
||||
#include <netinet/tcp.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <net/if_tun.h>
|
||||
#include <sys/un.h>
|
||||
|
||||
#ifndef NOALIAS
|
||||
#include <alias.h>
|
||||
|
@ -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.45 1998/04/25 00:09:11 brian Exp $
|
||||
* $Id: ipcp.c,v 1.50.2.46 1998/04/25 10:49:09 brian Exp $
|
||||
*
|
||||
* TODO:
|
||||
* o More RFC1772 backwoard compatibility
|
||||
@ -31,6 +31,7 @@
|
||||
#include <netdb.h>
|
||||
#include <net/if.h>
|
||||
#include <sys/sockio.h>
|
||||
#include <sys/un.h>
|
||||
|
||||
#include <fcntl.h>
|
||||
#include <resolv.h>
|
||||
|
@ -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.48 1998/04/25 00:09:12 brian Exp $
|
||||
* $Id: lcp.c,v 1.55.2.49 1998/04/25 10:49:12 brian Exp $
|
||||
*
|
||||
* TODO:
|
||||
* o Limit data field length by MRU
|
||||
@ -27,6 +27,7 @@
|
||||
#include <netinet/in.h>
|
||||
#include <netinet/in_systm.h>
|
||||
#include <netinet/ip.h>
|
||||
#include <sys/un.h>
|
||||
|
||||
#include <signal.h>
|
||||
#include <stdio.h>
|
||||
|
@ -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.26 1998/04/19 23:08:40 brian Exp $
|
||||
* $Id: lqr.c,v 1.22.2.27 1998/04/24 19:16:06 brian Exp $
|
||||
*
|
||||
* o LQR based on RFC1333
|
||||
*
|
||||
@ -27,6 +27,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/un.h>
|
||||
|
||||
#include <string.h>
|
||||
#include <termios.h>
|
||||
|
@ -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.50 1998/04/23 03:22:58 brian Exp $
|
||||
* $Id: main.c,v 1.121.2.51 1998/04/25 10:49:26 brian Exp $
|
||||
*
|
||||
* TODO:
|
||||
*/
|
||||
@ -500,6 +500,8 @@ DoLoop(struct bundle *bundle, struct prompt *prompt)
|
||||
|
||||
descriptor_UpdateSet(&bundle->desc, &rfds, &wfds, &efds, &nfds);
|
||||
descriptor_UpdateSet(&server.desc, &rfds, &wfds, &efds, &nfds);
|
||||
descriptor_UpdateSet(&bundle->ncp.mp.server.desc, &rfds, &wfds,
|
||||
&efds, &nfds);
|
||||
|
||||
/* If there are aren't many packets queued, look for some more. */
|
||||
if (qlen < 20 && bundle->tun_fd >= 0) {
|
||||
@ -532,6 +534,9 @@ DoLoop(struct bundle *bundle, struct prompt *prompt)
|
||||
break;
|
||||
}
|
||||
|
||||
if (descriptor_IsSet(&bundle->ncp.mp.server.desc, &rfds))
|
||||
descriptor_Read(&bundle->ncp.mp.server.desc, bundle, &rfds);
|
||||
|
||||
if (descriptor_IsSet(&server.desc, &rfds))
|
||||
descriptor_Read(&server.desc, bundle, &rfds);
|
||||
|
||||
|
@ -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.57 1998/04/25 00:09:28 brian Exp $
|
||||
* $Id: modem.c,v 1.77.2.58 1998/04/25 10:49:31 brian Exp $
|
||||
*
|
||||
* TODO:
|
||||
*/
|
||||
@ -28,6 +28,7 @@
|
||||
#include <netdb.h>
|
||||
#include <netinet/in_systm.h>
|
||||
#include <netinet/ip.h>
|
||||
#include <sys/un.h>
|
||||
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
@ -279,7 +280,8 @@ modem_Timeout(void *data)
|
||||
if (modem->dev_is_modem) {
|
||||
if (modem->fd >= 0) {
|
||||
if (ioctl(modem->fd, TIOCMGET, &modem->mbits) < 0) {
|
||||
LogPrintf(LogPHASE, "ioctl error (%s)!\n", strerror(errno));
|
||||
LogPrintf(LogPHASE, "%s: ioctl error (%s)!\n", modem->link.name,
|
||||
strerror(errno));
|
||||
datalink_Down(modem->dl, 0);
|
||||
return;
|
||||
}
|
||||
@ -287,20 +289,15 @@ modem_Timeout(void *data)
|
||||
modem->mbits = 0;
|
||||
change = ombits ^ modem->mbits;
|
||||
if (change & TIOCM_CD) {
|
||||
if (modem->mbits & TIOCM_CD) {
|
||||
LogPrintf(LogDEBUG, "modem_Timeout: offline -> online\n");
|
||||
/*
|
||||
* In -dedicated mode, start packet mode immediately after we've
|
||||
* detected carrier.
|
||||
*/
|
||||
} else {
|
||||
LogPrintf(LogDEBUG, "modem_Timeout: online -> offline\n");
|
||||
if (modem->mbits & TIOCM_CD)
|
||||
LogPrintf(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);
|
||||
datalink_Down(modem->dl, 0);
|
||||
}
|
||||
}
|
||||
else
|
||||
LogPrintf(LogDEBUG, "modem_Timeout: Still %sline\n",
|
||||
} else
|
||||
LogPrintf(LogDEBUG, "%s: Still %sline\n", modem->link.name,
|
||||
Online(modem) ? "on" : "off");
|
||||
} else if (!Online(modem)) {
|
||||
/* mbits was set to zero in modem_Open() */
|
||||
@ -320,7 +317,8 @@ modem_StartTimer(struct bundle *bundle, struct physical *modem)
|
||||
ModemTimer->func = modem_Timeout;
|
||||
ModemTimer->name = "modem CD";
|
||||
ModemTimer->arg = modem;
|
||||
LogPrintf(LogDEBUG, "ModemTimer using modem_Timeout() - %p\n", modem_Timeout);
|
||||
LogPrintf(LogDEBUG, "%s: Using modem_Timeout [%p]\n",
|
||||
modem->link.name, modem_Timeout);
|
||||
StartTimer(ModemTimer);
|
||||
}
|
||||
|
||||
@ -364,12 +362,12 @@ modem_SetParity(struct physical *modem, const char *str)
|
||||
tcsetattr(modem->fd, TCSADRAIN, &rstio);
|
||||
return 0;
|
||||
}
|
||||
LogPrintf(LogWARN, "modem_SetParity: %s: Invalid parity\n", str);
|
||||
LogPrintf(LogWARN, "%s: %s: Invalid parity\n", modem->link.name, str);
|
||||
return -1;
|
||||
}
|
||||
|
||||
static int
|
||||
OpenConnection(char *host, char *port)
|
||||
OpenConnection(const char *name, char *host, char *port)
|
||||
{
|
||||
struct sockaddr_in dest;
|
||||
int sock;
|
||||
@ -383,7 +381,7 @@ OpenConnection(char *host, char *port)
|
||||
if (hp) {
|
||||
memcpy(&dest.sin_addr.s_addr, hp->h_addr_list[0], 4);
|
||||
} else {
|
||||
LogPrintf(LogWARN, "OpenConnection: unknown host: %s\n", host);
|
||||
LogPrintf(LogWARN, "%s: %s: unknown host\n", name, host);
|
||||
return (-1);
|
||||
}
|
||||
}
|
||||
@ -393,21 +391,20 @@ OpenConnection(char *host, char *port)
|
||||
if (sp) {
|
||||
dest.sin_port = sp->s_port;
|
||||
} else {
|
||||
LogPrintf(LogWARN, "OpenConnection: unknown service: %s\n", port);
|
||||
LogPrintf(LogWARN, "%s: %s: unknown service\n", name, port);
|
||||
return (-1);
|
||||
}
|
||||
}
|
||||
LogPrintf(LogPHASE, "Connecting to %s:%s\n", host, port);
|
||||
LogPrintf(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, "OpenConnection: connection failed.\n");
|
||||
LogPrintf(LogWARN, "%s: connect: %s\n", name, strerror(errno));
|
||||
return (-1);
|
||||
}
|
||||
LogPrintf(LogDEBUG, "OpenConnection: modem fd is %d.\n", sock);
|
||||
return (sock);
|
||||
}
|
||||
|
||||
@ -424,10 +421,11 @@ modem_lock(struct physical *modem, int tunno)
|
||||
if (modem->type != PHYS_STDIN &&
|
||||
(res = ID0uu_lock(modem->name.base)) != UU_LOCK_OK) {
|
||||
if (res == UU_LOCK_INUSE)
|
||||
LogPrintf(LogPHASE, "Modem %s is in use\n", modem->name.full);
|
||||
LogPrintf(LogPHASE, "%s: %s is in use\n",
|
||||
modem->link.name, modem->name.full);
|
||||
else
|
||||
LogPrintf(LogPHASE, "Modem %s is in use: uu_lock: %s\n",
|
||||
modem->name.full, uu_lockerr(res));
|
||||
LogPrintf(LogPHASE, "%s: %s is in use: uu_lock: %s\n",
|
||||
modem->link.name, modem->name.full, uu_lockerr(res));
|
||||
return (-1);
|
||||
}
|
||||
|
||||
@ -439,7 +437,8 @@ modem_lock(struct physical *modem, int tunno)
|
||||
}
|
||||
#ifndef RELEASE_CRUNCH
|
||||
else
|
||||
LogPrintf(LogALERT, "Warning: Can't create %s: %s\n", fn, strerror(errno));
|
||||
LogPrintf(LogALERT, "%s: Can't create %s: %s\n",
|
||||
modem->link.name, fn, strerror(errno));
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
@ -456,13 +455,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, "Warning: Can't remove %s: %s\n", fn, strerror(errno));
|
||||
LogPrintf(LogALERT, "%s: Can't remove %s: %s\n",
|
||||
modem->link.name, fn, strerror(errno));
|
||||
#else
|
||||
ID0unlink(fn);
|
||||
#endif
|
||||
|
||||
if (modem->type != PHYS_STDIN && ID0uu_unlock(modem->name.base) == -1)
|
||||
LogPrintf(LogALERT, "Warning: Can't uu_unlock %s\n", fn);
|
||||
LogPrintf(LogALERT, "%s: Can't uu_unlock %s\n", modem->link.name, fn);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -471,7 +471,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, "Connected!\n");
|
||||
LogPrintf(LogPHASE, "%s: Connected!\n", modem->link.name);
|
||||
}
|
||||
|
||||
int
|
||||
@ -485,11 +485,12 @@ modem_Open(struct physical *modem, struct bundle *bundle)
|
||||
char *tmpDevice;
|
||||
|
||||
if (modem->fd >= 0)
|
||||
LogPrintf(LogDEBUG, "modem_Open: Modem is already open!\n");
|
||||
LogPrintf(LogDEBUG, "%s: Open: Modem is already open!\n", modem->link.name);
|
||||
/* We're going back into "term" mode */
|
||||
else if (modem->type == PHYS_STDIN) {
|
||||
if (isatty(STDIN_FILENO)) {
|
||||
LogPrintf(LogDEBUG, "modem_Open(direct): Modem is a tty\n");
|
||||
LogPrintf(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) {
|
||||
close(STDIN_FILENO);
|
||||
@ -498,7 +499,8 @@ modem_Open(struct physical *modem, struct bundle *bundle)
|
||||
modem->fd = STDIN_FILENO;
|
||||
modem_Found(modem, bundle);
|
||||
} else {
|
||||
LogPrintf(LogDEBUG, "modem_Open(direct): Modem is not a tty\n");
|
||||
LogPrintf(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 */
|
||||
modem_Found(modem, bundle);
|
||||
@ -516,12 +518,13 @@ 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, "modem_Open failed: %s: %s\n", modem->name.full,
|
||||
strerror(errno));
|
||||
LogPrintf(LogERROR, "%s: Open(\"%s\"): %s\n",
|
||||
modem->link.name, modem->name.full, strerror(errno));
|
||||
modem_Unlock(modem);
|
||||
} else {
|
||||
modem_Found(modem, bundle);
|
||||
LogPrintf(LogDEBUG, "modem_Open: Modem is %s\n", modem->name.full);
|
||||
LogPrintf(LogDEBUG, "%s: Opened %s\n",
|
||||
modem->link.name, modem->name.full);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@ -536,22 +539,22 @@ modem_Open(struct physical *modem, struct bundle *bundle)
|
||||
host = modem->name.full;
|
||||
port = cp + 1;
|
||||
if (*host && *port) {
|
||||
modem->fd = OpenConnection(host, port);
|
||||
modem->fd = OpenConnection(modem->link.name, host, port);
|
||||
*cp = ':'; /* Don't destroy name.full */
|
||||
if (modem->fd < 0)
|
||||
return (-1);
|
||||
modem_Found(modem, bundle);
|
||||
LogPrintf(LogDEBUG, "modem_Open: Modem is socket %s\n",
|
||||
LogPrintf(LogDEBUG, "%s: Opened socket %s\n", modem->link.name,
|
||||
modem->name.full);
|
||||
} else {
|
||||
*cp = ':'; /* Don't destroy name.full */
|
||||
LogPrintf(LogERROR, "Invalid host:port: \"%s\"\n",
|
||||
modem->name.full);
|
||||
LogPrintf(LogERROR, "%s: Invalid host:port: \"%s\"\n",
|
||||
modem->link.name, modem->name.full);
|
||||
return (-1);
|
||||
}
|
||||
} else {
|
||||
LogPrintf(LogERROR, "Device (%s) must begin with a '/' or be a"
|
||||
" host:port pair\n", modem->name.full);
|
||||
LogPrintf(LogERROR, "%s: Device (%s) must begin with a '/' or be a"
|
||||
" host:port pair\n", modem->link.name, modem->name.full);
|
||||
return (-1);
|
||||
}
|
||||
}
|
||||
@ -573,9 +576,10 @@ modem_Open(struct physical *modem, struct bundle *bundle)
|
||||
if (modem->dev_is_modem && !Physical_IsSync(modem)) {
|
||||
tcgetattr(modem->fd, &rstio);
|
||||
modem->ios = rstio;
|
||||
LogPrintf(LogDEBUG, "modem_Open: modem (get): fd = %d, iflag = %lx, "
|
||||
"oflag = %lx, cflag = %lx\n", modem->fd, (u_long)rstio.c_iflag,
|
||||
(u_long)rstio.c_oflag, (u_long)rstio.c_cflag);
|
||||
LogPrintf(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);
|
||||
cfmakeraw(&rstio);
|
||||
if (modem->cfg.rts_cts)
|
||||
rstio.c_cflag |= CLOCAL | CCTS_OFLOW | CRTS_IFLOW;
|
||||
@ -592,29 +596,30 @@ 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, "Unable to set modem speed (modem %d to %d)\n",
|
||||
modem->fd, modem->cfg.speed);
|
||||
LogPrintf(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, "modem (put): iflag = %lx, oflag = %lx, cflag = %lx\n",
|
||||
(u_long)rstio.c_iflag, (u_long)rstio.c_oflag,
|
||||
(u_long)rstio.c_cflag);
|
||||
LogPrintf(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_STDIN) {
|
||||
LogPrintf(LogERROR, "modem_Open: Cannot get modem status: %s\n",
|
||||
strerror(errno));
|
||||
LogPrintf(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, "modem_Open: modem control = %o\n", modem->mbits);
|
||||
LogPrintf(LogDEBUG, "%s: Open: modem control = %o\n",
|
||||
modem->link.name, modem->mbits);
|
||||
|
||||
oldflag = fcntl(modem->fd, F_GETFL, 0);
|
||||
if (oldflag < 0) {
|
||||
LogPrintf(LogERROR, "modem_Open: Cannot get modem flags: %s\n",
|
||||
strerror(errno));
|
||||
LogPrintf(LogERROR, "%s: Open: Cannot get modem flags: %s\n",
|
||||
modem->link.name, strerror(errno));
|
||||
modem_LogicalClose(modem);
|
||||
return (-1);
|
||||
}
|
||||
@ -645,14 +650,14 @@ modem_Raw(struct physical *modem, struct bundle *bundle)
|
||||
struct termios rstio;
|
||||
int oldflag;
|
||||
|
||||
LogPrintf(LogDEBUG, "Entering modem_Raw\n");
|
||||
LogPrintf(LogDEBUG, "%s: Entering modem_Raw\n", modem->link.name);
|
||||
|
||||
if (!isatty(modem->fd) || Physical_IsSync(modem))
|
||||
return 0;
|
||||
|
||||
if (modem->type != PHYS_STDIN && modem->fd >= 0 && !Online(modem))
|
||||
LogPrintf(LogDEBUG, "modem_Raw: modem = %d, mbits = %x\n",
|
||||
modem->fd, modem->mbits);
|
||||
LogPrintf(LogDEBUG, "%s: Raw: modem = %d, mbits = %x\n",
|
||||
modem->link.name, modem->fd, modem->mbits);
|
||||
|
||||
tcgetattr(modem->fd, &rstio);
|
||||
cfmakeraw(&rstio);
|
||||
@ -692,7 +697,7 @@ modem_Unraw(struct physical *modem)
|
||||
static void
|
||||
modem_PhysicalClose(struct physical *modem)
|
||||
{
|
||||
LogPrintf(LogDEBUG, "modem_PhysicalClose\n");
|
||||
LogPrintf(LogDEBUG, "%s: Physical Close\n", modem->link.name);
|
||||
close(modem->fd);
|
||||
modem->fd = -1;
|
||||
StopTimer(&modem->Timer);
|
||||
@ -711,12 +716,13 @@ modem_Offline(struct physical *modem)
|
||||
if (isatty(modem->fd) && Online(modem)) {
|
||||
tcgetattr(modem->fd, &tio);
|
||||
if (cfsetspeed(&tio, B0) == -1)
|
||||
LogPrintf(LogWARN, "Unable to set modem to speed 0\n");
|
||||
LogPrintf(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);
|
||||
LogPrintf(LogPHASE, "%s: Disconnected!\n", modem->link.name);
|
||||
}
|
||||
}
|
||||
|
||||
@ -726,7 +732,7 @@ modem_Close(struct physical *modem)
|
||||
if (modem->fd < 0)
|
||||
return;
|
||||
|
||||
LogPrintf(LogDEBUG, "Close modem\n");
|
||||
LogPrintf(LogDEBUG, "%s: Close\n", modem->link.name);
|
||||
|
||||
if (!isatty(modem->fd)) {
|
||||
modem_PhysicalClose(modem);
|
||||
@ -752,7 +758,7 @@ modem_Destroy(struct physical *modem)
|
||||
static void
|
||||
modem_LogicalClose(struct physical *modem)
|
||||
{
|
||||
LogPrintf(LogDEBUG, "modem_LogicalClose\n");
|
||||
LogPrintf(LogDEBUG, "%s: Logical Close\n", modem->link.name);
|
||||
if (modem->fd >= 0) {
|
||||
Physical_Logout(modem);
|
||||
modem_PhysicalClose(modem);
|
||||
@ -775,8 +781,8 @@ 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, "modem_DescriptorWrite: wrote: %d(%d) to %d\n",
|
||||
nw, nb, modem->fd);
|
||||
LogPrintf(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;
|
||||
@ -784,7 +790,7 @@ modem_DescriptorWrite(struct descriptor *d, struct bundle *bundle,
|
||||
modem->out = mbfree(modem->out);
|
||||
} else if (nw < 0) {
|
||||
if (errno != EAGAIN) {
|
||||
LogPrintf(LogERROR, "modem write (%d): %s\n", modem->fd,
|
||||
LogPrintf(LogWARN, "%s: write (%d): %s\n", modem->link.name, modem->fd,
|
||||
strerror(errno));
|
||||
datalink_Down(modem->dl, 0);
|
||||
}
|
||||
@ -860,20 +866,6 @@ modem_ShowStatus(struct cmdargs const *arg)
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/* Dummy linker functions, to keep this quiet. Might end up a full
|
||||
regression test later, right now it is just to be able to track
|
||||
external symbols. */
|
||||
#ifdef TESTMAIN
|
||||
int main(void) {}
|
||||
|
||||
void LogPrintf(int i, const char *a, ...) {}
|
||||
int LogIsKept(int garble) { return 0; }
|
||||
int Physical_IsSync(struct physical *phys) {return 0;}
|
||||
int DoChat(struct physical *a, char *b) {return 0;}
|
||||
|
||||
#endif
|
||||
|
||||
static void
|
||||
modem_DescriptorRead(struct descriptor *d, struct bundle *bundle,
|
||||
const fd_set *fdset)
|
||||
|
@ -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.15 1998/04/25 00:09:21 brian Exp $
|
||||
* $Id: mp.c,v 1.1.2.16 1998/04/25 10:49:35 brian Exp $
|
||||
*/
|
||||
|
||||
#include <sys/types.h>
|
||||
@ -33,11 +33,14 @@
|
||||
#include <arpa/inet.h>
|
||||
#include <net/if_dl.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/un.h>
|
||||
|
||||
#include <errno.h>
|
||||
#include <paths.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <sys/stat.h>
|
||||
#include <termios.h>
|
||||
#include <unistd.h>
|
||||
|
||||
@ -181,6 +184,8 @@ mp_Init(struct mp *mp, struct bundle *bundle)
|
||||
mp->fsmp.LayerFinish = mp_LayerFinish;
|
||||
mp->fsmp.object = mp;
|
||||
|
||||
mpserver_Init(&mp->server);
|
||||
|
||||
mp->cfg.mrru = 0;
|
||||
mp->cfg.shortseq = NEG_ENABLED|NEG_ACCEPTED;
|
||||
mp->cfg.enddisc.class = 0;
|
||||
@ -192,31 +197,34 @@ mp_Init(struct mp *mp, struct bundle *bundle)
|
||||
}
|
||||
|
||||
int
|
||||
mp_Up(struct mp *mp, const char *name, const struct peerid *peer,
|
||||
u_short local_mrru, u_short peer_mrru, int local_shortseq,
|
||||
int peer_shortseq)
|
||||
mp_Up(struct mp *mp, struct datalink *dl)
|
||||
{
|
||||
struct lcp *lcp = &dl->physical->link.lcp;
|
||||
int fd;
|
||||
|
||||
if (mp->active) {
|
||||
/* We're adding a link - do a last validation on our parameters */
|
||||
if (!peerid_Equal(peer, &mp->peer)) {
|
||||
LogPrintf(LogPHASE, "%s: Inappropriate peer !\n", name);
|
||||
return 0;
|
||||
if (!peerid_Equal(&dl->peer, &mp->peer)) {
|
||||
LogPrintf(LogPHASE, "%s: Inappropriate peer !\n", dl->name);
|
||||
return MP_FAILED;
|
||||
}
|
||||
if (mp->local_mrru != local_mrru ||
|
||||
mp->peer_mrru != peer_mrru ||
|
||||
mp->local_is12bit != local_shortseq ||
|
||||
mp->peer_is12bit != peer_shortseq) {
|
||||
LogPrintf(LogPHASE, "%s: Invalid MRRU/SHORTSEQ MP parameters !\n", name);
|
||||
return 0;
|
||||
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",
|
||||
dl->name);
|
||||
return MP_FAILED;
|
||||
}
|
||||
return MP_ADDED;
|
||||
} else {
|
||||
/* First link in multilink mode */
|
||||
|
||||
mp->local_mrru = local_mrru;
|
||||
mp->peer_mrru = peer_mrru;
|
||||
mp->local_is12bit = local_shortseq;
|
||||
mp->peer_is12bit = peer_shortseq;
|
||||
mp->peer = *peer;
|
||||
mp->local_mrru = lcp->want_mrru;
|
||||
mp->peer_mrru = lcp->his_mrru;
|
||||
mp->local_is12bit = lcp->want_shortseq;
|
||||
mp->peer_is12bit = lcp->his_shortseq;
|
||||
mp->peer = dl->peer;
|
||||
|
||||
throughput_init(&mp->link.throughput);
|
||||
memset(mp->link.Queue, '\0', sizeof mp->link.Queue);
|
||||
@ -227,17 +235,33 @@ mp_Up(struct mp *mp, const char *name, const struct peerid *peer,
|
||||
mp->seq.min_in = 0;
|
||||
mp->seq.next_in = 0;
|
||||
|
||||
/* Re-point our IPCP layer at our MP link */
|
||||
ipcp_SetLink(&mp->bundle->ncp.ipcp, &mp->link);
|
||||
/*
|
||||
* Now we create our server socket.
|
||||
* If it already exists, join it. Otherwise, create and own it
|
||||
*/
|
||||
fd = mpserver_Open(&mp->server, &mp->peer);
|
||||
if (fd >= 0) {
|
||||
LogPrintf(LogPHASE, "mp: Transfer link %s\n", mp->server.ifsun.sun_path);
|
||||
bundle_SendDatalink(dl, fd);
|
||||
return MP_LINKSENT;
|
||||
} else if (!mpserver_IsOpen(&mp->server))
|
||||
return MP_FAILED;
|
||||
else {
|
||||
LogPrintf(LogPHASE, "mp: Listening on %s\n", mp->server.ifsun.sun_path);
|
||||
LogPrintf(LogPHASE, " First link: %s\n", dl->name);
|
||||
|
||||
/* Our lcp's already up 'cos of the NULL parent */
|
||||
FsmUp(&mp->link.ccp.fsm);
|
||||
FsmOpen(&mp->link.ccp.fsm);
|
||||
/* Re-point our IPCP layer at our MP link */
|
||||
ipcp_SetLink(&mp->bundle->ncp.ipcp, &mp->link);
|
||||
|
||||
mp->active = 1;
|
||||
/* Our lcp's already up 'cos of the NULL parent */
|
||||
FsmUp(&mp->link.ccp.fsm);
|
||||
FsmOpen(&mp->link.ccp.fsm);
|
||||
|
||||
mp->active = 1;
|
||||
}
|
||||
}
|
||||
|
||||
return 1;
|
||||
return MP_UP;
|
||||
}
|
||||
|
||||
void
|
||||
@ -246,7 +270,10 @@ mp_Down(struct mp *mp)
|
||||
if (mp->active) {
|
||||
struct mbuf *next;
|
||||
|
||||
/* CCP goes down with a bank */
|
||||
/* Don't want any more of these */
|
||||
mpserver_Close(&mp->server);
|
||||
|
||||
/* CCP goes down with a bang */
|
||||
FsmDown(&mp->link.ccp.fsm);
|
||||
FsmClose(&mp->link.ccp.fsm);
|
||||
|
||||
@ -570,6 +597,9 @@ mp_ShowStatus(struct cmdargs const *arg)
|
||||
struct mp *mp = &arg->bundle->ncp.mp;
|
||||
|
||||
prompt_Printf(arg->prompt, "Multilink is %sactive\n", mp->active ? "" : "in");
|
||||
if (mp->active)
|
||||
prompt_Printf(arg->prompt, "Socket: %s\n",
|
||||
mp->server.ifsun.sun_path);
|
||||
|
||||
prompt_Printf(arg->prompt, "\nMy Side:\n");
|
||||
if (mp->active) {
|
||||
@ -743,3 +773,138 @@ mp_SetEnddisc(struct cmdargs const *arg)
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
mpserver_UpdateSet(struct descriptor *d, fd_set *r, fd_set *w, fd_set *e,
|
||||
int *n)
|
||||
{
|
||||
struct mpserver *s = descriptor2mpserver(d);
|
||||
|
||||
if (r && s->fd >= 0) {
|
||||
if (*n < s->fd + 1)
|
||||
*n = s->fd + 1;
|
||||
FD_SET(s->fd, r);
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
mpserver_IsSet(struct descriptor *d, const fd_set *fdset)
|
||||
{
|
||||
struct mpserver *s = descriptor2mpserver(d);
|
||||
return s->fd >= 0 && FD_ISSET(s->fd, fdset);
|
||||
}
|
||||
|
||||
static void
|
||||
mpserver_Read(struct descriptor *d, struct bundle *bundle, const fd_set *fdset)
|
||||
{
|
||||
struct mpserver *s = descriptor2mpserver(d);
|
||||
int fd, size;
|
||||
|
||||
size = sizeof s->ifsun;
|
||||
fd = accept(s->fd, (struct sockaddr *)&s->ifsun, &size);
|
||||
if (fd < 0) {
|
||||
LogPrintf(LogERROR, "mpserver_Read: accept(): %s\n", strerror(errno));
|
||||
return;
|
||||
}
|
||||
|
||||
if (s->ifsun.sun_family != AF_LOCAL) { /* ??? */
|
||||
close(fd);
|
||||
return;
|
||||
}
|
||||
|
||||
bundle_ReceiveDatalink(bundle, fd);
|
||||
}
|
||||
|
||||
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");
|
||||
}
|
||||
|
||||
void
|
||||
mpserver_Init(struct mpserver *s)
|
||||
{
|
||||
s->desc.type = MPSERVER_DESCRIPTOR;
|
||||
s->desc.next = NULL;
|
||||
s->desc.UpdateSet = mpserver_UpdateSet;
|
||||
s->desc.IsSet = mpserver_IsSet;
|
||||
s->desc.Read = mpserver_Read;
|
||||
s->desc.Write = mpserver_Write;
|
||||
s->fd = -1;
|
||||
memset(&s->ifsun, '\0', sizeof s->ifsun);
|
||||
}
|
||||
|
||||
int
|
||||
mpserver_Open(struct mpserver *s, struct peerid *peer)
|
||||
{
|
||||
mode_t mask;
|
||||
int f;
|
||||
|
||||
if (s->fd != -1) {
|
||||
LogPrintf(LogERROR, "Internal error ! mpserver already open\n");
|
||||
close(s->fd);
|
||||
memset(&s->ifsun, '\0', sizeof s->ifsun);
|
||||
}
|
||||
|
||||
s->ifsun.sun_len = snprintf(s->ifsun.sun_path, sizeof s->ifsun.sun_path,
|
||||
"%sppp-%s-%02x-", _PATH_VARRUN,
|
||||
peer->authname, peer->enddisc.class);
|
||||
|
||||
for (f = 0; f < peer->enddisc.len; f++) {
|
||||
snprintf(s->ifsun.sun_path + s->ifsun.sun_len,
|
||||
sizeof s->ifsun.sun_path - s->ifsun.sun_len,
|
||||
"%02x", *(u_char *)(peer->enddisc.address+f));
|
||||
s->ifsun.sun_len += 2;
|
||||
}
|
||||
|
||||
s->ifsun.sun_family = AF_LOCAL;
|
||||
s->fd = ID0socket(PF_LOCAL, SOCK_STREAM, 0);
|
||||
if (s->fd < 0) {
|
||||
LogPrintf(LogERROR, "mpserver: socket: %s\n", strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
setsockopt(s->fd, SOL_SOCKET, SO_REUSEADDR, (struct sockaddr *)&s->ifsun,
|
||||
sizeof s->ifsun);
|
||||
|
||||
mask = umask(0177);
|
||||
|
||||
if (ID0bind_un(s->fd, &s->ifsun, sizeof s->ifsun) < 0) {
|
||||
umask(mask);
|
||||
f = sizeof s->ifsun;
|
||||
getsockopt(s->fd, SOL_SOCKET, SO_ERROR, (struct sockaddr *)&s->ifsun, &f);
|
||||
if (ID0connect_un(s->fd, &s->ifsun, sizeof s->ifsun) < 0) {
|
||||
LogPrintf(LogPHASE, "mpserver: can't open bundle socket (%s)\n",
|
||||
strerror(errno));
|
||||
close(s->fd);
|
||||
s->fd = -1;
|
||||
return -1;
|
||||
} else {
|
||||
/* We wanna donate our link to the other guy */
|
||||
int fd = s->fd;
|
||||
s->fd = -1;
|
||||
return fd;
|
||||
}
|
||||
} else {
|
||||
umask(mask);
|
||||
if (listen(s->fd, 5) != 0) {
|
||||
LogPrintf(LogERROR, "mpserver: Unable to listen to socket"
|
||||
" - BUNDLE overload?\n");
|
||||
mpserver_Close(s);
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
void
|
||||
mpserver_Close(struct mpserver *s)
|
||||
{
|
||||
if (s->fd >= 0) {
|
||||
close(s->fd);
|
||||
ID0unlink(s->ifsun.sun_path);
|
||||
s->fd = -1;
|
||||
}
|
||||
}
|
||||
|
@ -23,13 +23,14 @@
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $Id: mp.h,v 1.1.2.6 1998/04/24 19:16:10 brian Exp $
|
||||
* $Id: mp.h,v 1.1.2.7 1998/04/25 00:09:22 brian Exp $
|
||||
*/
|
||||
|
||||
struct mbuf;
|
||||
struct physical;
|
||||
struct bundle;
|
||||
struct cmdargs;
|
||||
struct datalink;
|
||||
|
||||
#define ENDDISC_NULL 0
|
||||
#define ENDDISC_LOCAL 1
|
||||
@ -38,6 +39,11 @@ struct cmdargs;
|
||||
#define ENDDISC_MAGIC 4
|
||||
#define ENDDISC_PSN 5
|
||||
|
||||
#define MP_LINKSENT 0 /* We attached the link to another ppp */
|
||||
#define MP_UP 1 /* We've started MP */
|
||||
#define MP_ADDED 2 /* We've added the link to our MP */
|
||||
#define MP_FAILED 3 /* No go */
|
||||
|
||||
struct enddisc {
|
||||
u_char class;
|
||||
char address[50];
|
||||
@ -49,8 +55,11 @@ struct peerid {
|
||||
char authname[50]; /* Peers name (authenticated) */
|
||||
};
|
||||
|
||||
extern void peerid_Init(struct peerid *);
|
||||
extern int peerid_Equal(const struct peerid *, const struct peerid *);
|
||||
struct mpserver {
|
||||
struct descriptor desc;
|
||||
int fd; /* listen()ing here */
|
||||
struct sockaddr_un ifsun; /* On this socket */
|
||||
};
|
||||
|
||||
struct mp {
|
||||
struct link link;
|
||||
@ -62,6 +71,7 @@ struct mp {
|
||||
u_short local_mrru;
|
||||
|
||||
struct peerid peer; /* Who are we talking to */
|
||||
struct mpserver server; /* Our ``sharing'' socket */
|
||||
|
||||
struct {
|
||||
u_int32_t out; /* next outgoing seq */
|
||||
@ -91,10 +101,19 @@ 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)
|
||||
|
||||
extern void peerid_Init(struct peerid *);
|
||||
extern int peerid_Equal(const struct peerid *, const struct peerid *);
|
||||
extern void mpserver_Init(struct mpserver *);
|
||||
extern int mpserver_Open(struct mpserver *, struct peerid *);
|
||||
extern void mpserver_Close(struct mpserver *);
|
||||
extern void mp_Init(struct mp *, struct bundle *);
|
||||
extern void mp_linkInit(struct mp_link *);
|
||||
extern int mp_Up(struct mp *, const char *, const struct peerid *, u_short,
|
||||
u_short, int, int);
|
||||
extern int mp_Up(struct mp *, struct datalink *);
|
||||
extern void mp_Down(struct mp *);
|
||||
extern void mp_Input(struct mp *, struct mbuf *, struct physical *);
|
||||
extern int mp_FillQueues(struct bundle *);
|
||||
|
@ -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.25 1998/04/16 00:26:12 brian Exp $
|
||||
* $Id: pap.c,v 1.20.2.26 1998/04/24 19:16:12 brian Exp $
|
||||
*
|
||||
* TODO:
|
||||
*/
|
||||
@ -26,11 +26,9 @@
|
||||
#include <netinet/in.h>
|
||||
#include <netinet/in_systm.h>
|
||||
#include <netinet/ip.h>
|
||||
#include <sys/un.h>
|
||||
|
||||
#include <termios.h>
|
||||
#ifdef __OpenBSD__
|
||||
#else
|
||||
#endif
|
||||
|
||||
#include "mbuf.h"
|
||||
#include "log.h"
|
||||
|
@ -16,11 +16,12 @@
|
||||
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* $Id: physical.c,v 1.1.2.25 1998/04/16 00:26:13 brian Exp $
|
||||
* $Id: physical.c,v 1.1.2.26 1998/04/25 10:49:39 brian Exp $
|
||||
*
|
||||
*/
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/un.h>
|
||||
|
||||
#include <sys/tty.h>
|
||||
|
||||
|
@ -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.18 1998/04/19 03:41:01 brian Exp $
|
||||
* $Id: route.c,v 1.42.2.19 1998/04/25 10:49:43 brian Exp $
|
||||
*
|
||||
*/
|
||||
|
||||
@ -31,6 +31,7 @@
|
||||
#include <net/if_dl.h>
|
||||
#include <netinet/in_systm.h>
|
||||
#include <netinet/ip.h>
|
||||
#include <sys/un.h>
|
||||
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
|
@ -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.15 1998/04/10 13:19:20 brian Exp $
|
||||
* $Id: server.c,v 1.16.2.16 1998/04/18 01:01:28 brian Exp $
|
||||
*/
|
||||
|
||||
#include <sys/types.h>
|
||||
@ -32,12 +32,12 @@
|
||||
#include <arpa/inet.h>
|
||||
#include <netinet/in_systm.h>
|
||||
#include <netinet/ip.h>
|
||||
#include <sys/un.h>
|
||||
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/un.h>
|
||||
#include <termios.h>
|
||||
#include <unistd.h>
|
||||
|
||||
|
@ -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.8 1998/04/19 23:08:58 brian Exp $
|
||||
* $Id: slcompress.c,v 1.15.2.9 1998/04/25 10:49:48 brian Exp $
|
||||
*
|
||||
* Van Jacobson (van@helios.ee.lbl.gov), Dec 31, 1989:
|
||||
* - Initial distribution.
|
||||
@ -28,6 +28,7 @@
|
||||
#include <netinet/in.h>
|
||||
#include <netinet/tcp.h>
|
||||
#include <netinet/ip.h>
|
||||
#include <sys/un.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
@ -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.13 1998/04/07 00:54:23 brian Exp $
|
||||
* $Id: tun.c,v 1.6.4.14 1998/04/25 10:49:52 brian Exp $
|
||||
*/
|
||||
|
||||
#include <sys/types.h>
|
||||
@ -33,6 +33,7 @@
|
||||
#include <net/if_tun.h>
|
||||
#include <netinet/in_systm.h>
|
||||
#include <netinet/ip.h>
|
||||
#include <sys/un.h>
|
||||
|
||||
#include <string.h>
|
||||
#include <sys/ioctl.h>
|
||||
|
@ -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.13 1998/04/07 00:54:25 brian Exp $
|
||||
* $Id: vjcomp.c,v 1.16.2.14 1998/04/16 00:26:21 brian Exp $
|
||||
*
|
||||
* TODO:
|
||||
*/
|
||||
@ -25,6 +25,7 @@
|
||||
#include <netinet/in.h>
|
||||
#include <netinet/in_systm.h>
|
||||
#include <netinet/ip.h>
|
||||
#include <sys/un.h>
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user