1998-04-03 19:21:56 +00:00
|
|
|
/*-
|
|
|
|
* Copyright (c) 1998 Brian Somers <brian@Awfulhak.org>
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
|
|
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
|
|
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
* SUCH DAMAGE.
|
|
|
|
*
|
1999-08-28 01:35:59 +00:00
|
|
|
* $FreeBSD$
|
1998-04-03 19:21:56 +00:00
|
|
|
*/
|
|
|
|
|
1998-04-07 00:54:26 +00:00
|
|
|
struct mbuf;
|
|
|
|
struct physical;
|
|
|
|
struct bundle;
|
|
|
|
struct cmdargs;
|
1998-04-28 01:25:46 +00:00
|
|
|
struct datalink;
|
1998-04-07 00:54:26 +00:00
|
|
|
|
1998-04-23 23:50:40 +00:00
|
|
|
#define ENDDISC_NULL 0
|
|
|
|
#define ENDDISC_LOCAL 1
|
|
|
|
#define ENDDISC_IP 2
|
|
|
|
#define ENDDISC_MAC 3
|
|
|
|
#define ENDDISC_MAGIC 4
|
|
|
|
#define ENDDISC_PSN 5
|
|
|
|
|
1998-04-28 01:25:46 +00:00
|
|
|
#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 */
|
|
|
|
|
1998-05-02 21:57:50 +00:00
|
|
|
#define MPSERVER_CONNECTED 0
|
|
|
|
#define MPSERVER_LISTENING 1
|
|
|
|
#define MPSERVER_FAILED 2
|
|
|
|
|
1998-04-24 19:16:15 +00:00
|
|
|
struct enddisc {
|
|
|
|
u_char class;
|
|
|
|
char address[50];
|
|
|
|
int len;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct peerid {
|
|
|
|
struct enddisc enddisc; /* Peers endpoint discriminator */
|
2000-01-17 12:27:29 +00:00
|
|
|
char authname[AUTHLEN]; /* Peers name (authenticated) */
|
1998-04-24 19:16:15 +00:00
|
|
|
};
|
|
|
|
|
1998-04-28 01:25:46 +00:00
|
|
|
struct mpserver {
|
2000-03-14 01:46:09 +00:00
|
|
|
struct fdescriptor desc;
|
1998-05-02 21:57:50 +00:00
|
|
|
int fd; /* listen()ing or connect()ing here */
|
1998-04-30 23:53:56 +00:00
|
|
|
struct sockaddr_un socket; /* On this socket */
|
|
|
|
|
|
|
|
struct {
|
1998-05-02 21:57:50 +00:00
|
|
|
struct datalink *dl; /* Send this datalink */
|
1998-04-30 23:53:56 +00:00
|
|
|
} send; /* (in UpdateSet()) */
|
1998-04-28 01:25:46 +00:00
|
|
|
};
|
1998-04-24 19:16:15 +00:00
|
|
|
|
1998-04-03 19:21:56 +00:00
|
|
|
struct mp {
|
|
|
|
struct link link;
|
|
|
|
|
|
|
|
unsigned active : 1;
|
1998-04-24 19:16:15 +00:00
|
|
|
unsigned peer_is12bit : 1; /* 12/24bit seq nos */
|
1998-04-23 03:23:03 +00:00
|
|
|
unsigned local_is12bit : 1;
|
|
|
|
u_short peer_mrru;
|
|
|
|
u_short local_mrru;
|
|
|
|
|
1998-04-24 19:16:15 +00:00
|
|
|
struct peerid peer; /* Who are we talking to */
|
1998-04-28 01:25:46 +00:00
|
|
|
struct mpserver server; /* Our ``sharing'' socket */
|
1998-04-03 19:21:56 +00:00
|
|
|
|
|
|
|
struct {
|
1998-05-03 22:13:14 +00:00
|
|
|
u_int32_t seq; /* next outgoing seq */
|
|
|
|
int link; /* Next link to send on */
|
2001-08-14 16:05:52 +00:00
|
|
|
int af; /* Next address family to send */
|
1998-05-03 22:13:14 +00:00
|
|
|
} out;
|
|
|
|
|
|
|
|
struct {
|
1998-04-24 19:16:15 +00:00
|
|
|
u_int32_t min_in; /* minimum received incoming seq */
|
|
|
|
u_int32_t next_in; /* next incoming seq to process */
|
1998-04-03 19:21:56 +00:00
|
|
|
} seq;
|
|
|
|
|
1998-04-23 03:23:03 +00:00
|
|
|
struct {
|
1998-04-24 19:16:15 +00:00
|
|
|
u_short mrru; /* Max Reconstructed Receive Unit */
|
|
|
|
unsigned shortseq : 2; /* I want short Sequence Numbers */
|
1999-06-09 16:54:04 +00:00
|
|
|
unsigned negenddisc : 2; /* I want an endpoint discriminator */
|
1998-04-24 19:16:15 +00:00
|
|
|
struct enddisc enddisc; /* endpoint discriminator */
|
1999-08-05 10:32:16 +00:00
|
|
|
struct {
|
|
|
|
int min; /* Lowest percent of bundle->bandwidth */
|
|
|
|
int max; /* Highest percent of bundle->bandwidth out */
|
|
|
|
int period; /* link->throughput sample period */
|
|
|
|
} autoload;
|
1998-04-23 03:23:03 +00:00
|
|
|
} cfg;
|
1998-04-03 19:21:56 +00:00
|
|
|
|
1998-04-24 19:16:15 +00:00
|
|
|
struct mbuf *inbufs; /* Received fragments */
|
|
|
|
struct fsm_parent fsmp; /* Our callback functions */
|
|
|
|
struct bundle *bundle; /* Parent */
|
1998-04-03 19:21:56 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct mp_link {
|
1998-04-24 19:16:15 +00:00
|
|
|
u_int32_t seq; /* 12 or 24 bit incoming seq */
|
1999-08-05 10:32:16 +00:00
|
|
|
unsigned bandwidth; /* Our link bandwidth (or zero) */
|
1998-04-03 19:21:56 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct mp_header {
|
|
|
|
unsigned begin : 1;
|
|
|
|
unsigned end : 1;
|
|
|
|
u_int32_t seq;
|
|
|
|
};
|
|
|
|
|
1998-04-28 01:25:46 +00:00
|
|
|
#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 *);
|
1998-04-03 19:21:56 +00:00
|
|
|
extern void mp_Init(struct mp *, struct bundle *);
|
|
|
|
extern void mp_linkInit(struct mp_link *);
|
1998-04-28 01:25:46 +00:00
|
|
|
extern int mp_Up(struct mp *, struct datalink *);
|
1998-04-23 21:50:13 +00:00
|
|
|
extern void mp_Down(struct mp *);
|
1999-05-08 11:07:56 +00:00
|
|
|
extern struct mbuf *mp_Input(struct bundle *, struct link *, struct mbuf *);
|
2001-08-14 16:05:52 +00:00
|
|
|
extern int mp_FillPhysicalQueues(struct bundle *);
|
1999-08-05 10:32:16 +00:00
|
|
|
extern int mp_SetDatalinkBandwidth(struct cmdargs const *);
|
1998-04-23 03:23:03 +00:00
|
|
|
extern int mp_ShowStatus(struct cmdargs const *);
|
|
|
|
extern const char *mp_Enddisc(u_char, const char *, int);
|
|
|
|
extern int mp_SetEnddisc(struct cmdargs const *);
|
1998-05-23 17:05:28 +00:00
|
|
|
extern void mp_LinkLost(struct mp *, struct datalink *);
|
1999-08-05 10:32:16 +00:00
|
|
|
extern void mp_RestartAutoloadTimer(struct mp *);
|
|
|
|
extern void mp_CheckAutoloadTimer(struct mp *);
|
|
|
|
extern void mp_StopAutoloadTimer(struct mp *);
|
2001-08-14 16:05:52 +00:00
|
|
|
extern size_t mp_QueueLen(struct mp *);
|