]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - usr.sbin/ppp/physical.h
o Redesign the layering mechanism and make the aliasing code part of
[FreeBSD/FreeBSD.git] / usr.sbin / ppp / physical.h
1 /*
2  * Written by Eivind Eklund <eivind@yes.no>
3  *    for Yes Interactive
4  *
5  * Copyright (C) 1998, Yes Interactive.  All rights reserved.
6  *
7  * Redistribution and use in any form is permitted.  Redistribution in
8  * source form should include the above copyright and this set of
9  * conditions, because large sections american law seems to have been
10  * created by a bunch of jerks on drugs that are now illegal, forcing
11  * me to include this copyright-stuff instead of placing this in the
12  * public domain.  The name of of 'Yes Interactive' or 'Eivind Eklund'
13  * may not be used to endorse or promote products derived from this
14  * software without specific prior written permission.
15  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
16  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
17  * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
18  *
19  *  $Id: physical.h,v 1.8 1999/04/27 00:23:57 brian Exp $
20  *
21  */
22
23 struct datalink;
24 struct bundle;
25 struct iovec;
26 struct physical;
27 struct bundle;
28 struct ccp;
29 struct cmdargs;
30
31 #define TTY_DEVICE      1
32 #define TCP_DEVICE      2
33 #define EXEC_DEVICE     3
34
35 struct device {
36   int type;
37   const char *name;
38   int (*open)(struct physical *);
39   int (*raw)(struct physical *);
40   void (*offline)(struct physical *);
41   void (*cooked)(struct physical *);
42   void (*postclose)(struct physical *);
43   void (*restored)(struct physical *);
44   int (*speed)(struct physical *);
45   const char *(*openinfo)(struct physical *);
46 };
47
48 struct physical {
49   struct link link;
50   struct descriptor desc;
51   int type;                    /* What sort of PHYS_* link are we ? */
52   struct async async;          /* Our async state */
53   struct hdlc hdlc;            /* Our hdlc state */
54   int fd;                      /* File descriptor for this device */
55   int mbits;                   /* Current DCD status */
56   struct mbuf *out;            /* mbuf that suffered a short write */
57   int connect_count;
58   struct datalink *dl;         /* my owner */
59
60   struct {
61     u_char buf[MAX_MRU];       /* Our input data buffer */
62     size_t sz;
63   } input;
64
65   struct {
66     char full[40];             /* Our current device name */
67     char *base;
68   } name;
69
70   unsigned Utmp : 1;           /* Are we in utmp ? */
71   pid_t session_owner;         /* HUP this when closing the link */
72
73   struct {
74     unsigned rts_cts : 1;      /* Is rts/cts enabled ? */
75     unsigned parity;           /* What parity is enabled? (tty flags) */
76     unsigned speed;            /* tty speed */
77
78     char devlist[LINE_LEN];    /* NUL separated list of devices */
79     int ndev;                  /* number of devices in list */
80     struct {
81       unsigned required : 1;   /* Is cd *REQUIRED* on this device */
82       int delay;               /* Wait this many seconds after login script */
83     } cd;
84   } cfg;
85
86   struct termios ios;          /* To be able to reset from raw mode */
87
88   struct pppTimer Timer;       /* CD checks */
89
90   const struct device *handler; /* device specific handlers */
91 };
92
93 #define field2phys(fp, name) \
94   ((struct physical *)((char *)fp - (int)(&((struct physical *)0)->name)))
95
96 #define link2physical(l) \
97   ((l)->type == PHYSICAL_LINK ? field2phys(l, link) : NULL)
98
99 #define descriptor2physical(d) \
100   ((d)->type == PHYSICAL_DESCRIPTOR ? field2phys(d, desc) : NULL)
101
102 extern struct physical *physical_Create(struct datalink *, int);
103 extern int physical_Open(struct physical *, struct bundle *);
104 extern int physical_Raw(struct physical *);
105 extern int physical_GetSpeed(struct physical *);
106 extern int physical_SetSpeed(struct physical *, int);
107 extern int physical_SetParity(struct physical *, const char *);
108 extern int physical_SetRtsCts(struct physical *, int);
109 extern void physical_SetSync(struct physical *);
110 extern int physical_ShowStatus(struct cmdargs const *);
111 extern void physical_Offline(struct physical *);
112 extern void physical_Close(struct physical *);
113 extern void physical_Destroy(struct physical *);
114 extern struct physical *iov2physical(struct datalink *, struct iovec *, int *,
115                                      int, int);
116 extern int physical2iov(struct physical *, struct iovec *, int *, int, pid_t);
117 extern void physical_ChangedPid(struct physical *, pid_t);
118
119 extern int physical_IsSync(struct physical *);
120 extern const char *physical_GetDevice(struct physical *);
121 extern void physical_SetDeviceList(struct physical *, int, const char *const *);
122 extern void physical_SetDevice(struct physical *, const char *);
123
124 extern ssize_t physical_Read(struct physical *, void *, size_t);
125 extern ssize_t physical_Write(struct physical *, const void *, size_t);
126 extern int physical_doUpdateSet(struct descriptor *, fd_set *, fd_set *,
127                                 fd_set *, int *, int);
128 extern int physical_IsSet(struct descriptor *, const fd_set *);
129 extern void physical_Login(struct physical *, const char *);
130 extern int physical_RemoveFromSet(struct physical *, fd_set *, fd_set *,
131                                   fd_set *);
132 extern int physical_SetMode(struct physical *, int);
133 extern void physical_DeleteQueue(struct physical *);
134 extern void physical_SetupStack(struct physical *, int);