2 * Written by Eivind Eklund <eivind@yes.no>
5 * Copyright (C) 1998, Yes Interactive. All rights reserved.
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.
31 /* Device types (don't use zero, it'll be confused with NULL in physical2iov */
36 #define ETHER_DEVICE 5
40 /* Returns from awaitcarrier() */
41 #define CARRIER_PENDING 1
43 #define CARRIER_LOST 3
45 /* A cd ``necessity'' value */
48 #define CD_NOTREQUIRED 2
52 unsigned necessity : 2; /* A CD_ value */
53 int delay; /* Wait this many seconds after login script */
62 int (*awaitcarrier)(struct physical *);
63 int (*removefromset)(struct physical *, fd_set *, fd_set *, fd_set *);
64 int (*raw)(struct physical *);
65 void (*offline)(struct physical *);
66 void (*cooked)(struct physical *);
67 void (*stoptimer)(struct physical *);
68 void (*destroy)(struct physical *);
69 ssize_t (*read)(struct physical *, void *, size_t);
70 ssize_t (*write)(struct physical *, const void *, size_t);
71 void (*device2iov)(struct device *, struct iovec *, int *, int, int *, int *);
72 int (*speed)(struct physical *);
73 const char *(*openinfo)(struct physical *);
78 struct fdescriptor desc;
79 int type; /* What sort of PHYS_* link are we ? */
80 struct async async; /* Our async state */
81 struct hdlc hdlc; /* Our hdlc state */
82 int fd; /* File descriptor for this device */
83 struct mbuf *out; /* mbuf that suffered a short write */
85 struct datalink *dl; /* my owner */
88 u_char buf[MAX_MRU]; /* Our input data buffer */
93 char full[DEVICE_LEN]; /* Our current device name */
97 time_t Utmp; /* Are we in utmp ? */
98 pid_t session_owner; /* HUP this when closing the link */
100 struct device *handler; /* device specific handler */
103 unsigned rts_cts : 1; /* Is rts/cts enabled ? */
104 unsigned parity; /* What parity is enabled? (tty flags) */
105 unsigned speed; /* tty speed */
107 char devlist[LINE_LEN]; /* NUL separated list of devices */
108 int ndev; /* number of devices in list */
113 #define field2phys(fp, name) \
114 ((struct physical *)((char *)fp - (int)(&((struct physical *)0)->name)))
116 #define link2physical(l) \
117 ((l)->type == PHYSICAL_LINK ? field2phys(l, link) : NULL)
119 #define descriptor2physical(d) \
120 ((d)->type == PHYSICAL_DESCRIPTOR ? field2phys(d, desc) : NULL)
122 #define PHYSICAL_NOFORCE 1
123 #define PHYSICAL_FORCE_ASYNC 2
124 #define PHYSICAL_FORCE_SYNC 3
125 #define PHYSICAL_FORCE_SYNCNOACF 4
127 extern struct physical *physical_Create(struct datalink *, int);
128 extern int physical_Open(struct physical *, struct bundle *);
129 extern int physical_Raw(struct physical *);
130 extern int physical_GetSpeed(struct physical *);
131 extern int physical_SetSpeed(struct physical *, int);
132 extern int physical_SetParity(struct physical *, const char *);
133 extern int physical_SetRtsCts(struct physical *, int);
134 extern void physical_SetSync(struct physical *);
135 extern int physical_ShowStatus(struct cmdargs const *);
136 extern void physical_Offline(struct physical *);
137 extern void physical_Close(struct physical *);
138 extern void physical_Destroy(struct physical *);
139 extern struct physical *iov2physical(struct datalink *, struct iovec *, int *,
140 int, int, int *, int *);
141 extern int physical2iov(struct physical *, struct iovec *, int *, int, int *,
143 extern const char *physical_LockedDevice(struct physical *);
144 extern void physical_ChangedPid(struct physical *, pid_t);
146 extern int physical_IsSync(struct physical *);
147 extern u_short physical_DeviceMTU(struct physical *);
148 extern const char *physical_GetDevice(struct physical *);
149 extern void physical_SetDeviceList(struct physical *, int, const char *const *);
150 extern void physical_SetDevice(struct physical *, const char *);
152 extern ssize_t physical_Read(struct physical *, void *, size_t);
153 extern ssize_t physical_Write(struct physical *, const void *, size_t);
154 extern int physical_doUpdateSet(struct fdescriptor *, fd_set *, fd_set *,
155 fd_set *, int *, int);
156 extern int physical_IsSet(struct fdescriptor *, const fd_set *);
157 extern void physical_DescriptorRead(struct fdescriptor *, struct bundle *,
159 extern void physical_Login(struct physical *, const char *);
160 extern int physical_RemoveFromSet(struct physical *, fd_set *, fd_set *,
162 extern int physical_SetMode(struct physical *, int);
163 extern void physical_DeleteQueue(struct physical *);
164 extern void physical_SetupStack(struct physical *, const char *, int);
165 extern void physical_StopDeviceTimer(struct physical *);
166 extern int physical_MaxDeviceSize(void);
167 extern int physical_AwaitCarrier(struct physical *);
168 extern void physical_SetDescriptor(struct physical *);