kernel - Report actual real memory during kernel boot
[dragonfly.git] / usr.sbin / ppp / physical.h
blob237c3e783744716ba5833d5a06edfdbf2af45390
1 /*
2 * Written by Eivind Eklund <eivind@yes.no>
3 * for Yes Interactive
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.
19 * $FreeBSD: src/usr.sbin/ppp/physical.h,v 1.20.2.3 2002/09/01 02:12:29 brian Exp $
20 * $DragonFly: src/usr.sbin/ppp/physical.h,v 1.2 2003/06/17 04:30:00 dillon Exp $
24 struct datalink;
25 struct bundle;
26 struct iovec;
27 struct physical;
28 struct bundle;
29 struct ccp;
30 struct cmdargs;
32 /* Device types (don't use zero, it'll be confused with NULL in physical2iov */
33 #define I4B_DEVICE 1
34 #define TTY_DEVICE 2
35 #define TCP_DEVICE 3
36 #define UDP_DEVICE 4
37 #define ETHER_DEVICE 5
38 #define EXEC_DEVICE 6
39 #define ATM_DEVICE 7
40 #define NG_DEVICE 8
42 /* Returns from awaitcarrier() */
43 #define CARRIER_PENDING 1
44 #define CARRIER_OK 2
45 #define CARRIER_LOST 3
47 /* A cd ``necessity'' value */
48 #define CD_VARIABLE 0
49 #define CD_REQUIRED 1
50 #define CD_NOTREQUIRED 2
51 #define CD_DEFAULT 3
53 struct cd {
54 unsigned necessity : 2; /* A CD_ value */
55 int delay; /* Wait this many seconds after login script */
58 struct device {
59 int type;
60 const char *name;
61 u_short mtu;
62 struct cd cd;
64 int (*awaitcarrier)(struct physical *);
65 int (*removefromset)(struct physical *, fd_set *, fd_set *, fd_set *);
66 int (*raw)(struct physical *);
67 void (*offline)(struct physical *);
68 void (*cooked)(struct physical *);
69 void (*setasyncparams)(struct physical *, u_int32_t, u_int32_t);
70 void (*stoptimer)(struct physical *);
71 void (*destroy)(struct physical *);
72 ssize_t (*read)(struct physical *, void *, size_t);
73 ssize_t (*write)(struct physical *, const void *, size_t);
74 void (*device2iov)(struct device *, struct iovec *, int *, int, int *, int *);
75 int (*speed)(struct physical *);
76 const char *(*openinfo)(struct physical *);
77 int (*slot)(struct physical *);
80 struct physical {
81 struct link link;
82 struct fdescriptor desc;
83 int type; /* What sort of PHYS_* link are we ? */
84 struct async async; /* Our async state */
85 struct hdlc hdlc; /* Our hdlc state */
86 int fd; /* File descriptor for this device */
87 struct mbuf *out; /* mbuf that suffered a short write */
88 int connect_count;
89 struct datalink *dl; /* my owner */
91 struct {
92 u_char buf[MAX_MRU]; /* Our input data buffer */
93 size_t sz;
94 } input;
96 struct {
97 char full[DEVICE_LEN]; /* Our current device name */
98 char *base;
99 } name;
101 time_t Utmp; /* Are we in utmp ? */
102 pid_t session_owner; /* HUP this when closing the link */
104 struct device *handler; /* device specific handler */
106 struct {
107 unsigned rts_cts : 1; /* Is rts/cts enabled ? */
108 unsigned parity; /* What parity is enabled? (tty flags) */
109 unsigned speed; /* tty speed */
111 char devlist[LINE_LEN]; /* NUL separated list of devices */
112 int ndev; /* number of devices in list */
113 struct cd cd;
114 } cfg;
117 #define field2phys(fp, name) \
118 ((struct physical *)((char *)fp - (int)(&((struct physical *)0)->name)))
120 #define link2physical(l) \
121 ((l)->type == PHYSICAL_LINK ? field2phys(l, link) : NULL)
123 #define descriptor2physical(d) \
124 ((d)->type == PHYSICAL_DESCRIPTOR ? field2phys(d, desc) : NULL)
126 #define PHYSICAL_NOFORCE 1
127 #define PHYSICAL_FORCE_ASYNC 2
128 #define PHYSICAL_FORCE_SYNC 3
129 #define PHYSICAL_FORCE_SYNCNOACF 4
131 extern struct physical *physical_Create(struct datalink *, int);
132 extern int physical_Open(struct physical *, struct bundle *);
133 extern int physical_Raw(struct physical *);
134 extern int physical_GetSpeed(struct physical *);
135 extern int physical_SetSpeed(struct physical *, int);
136 extern int physical_SetParity(struct physical *, const char *);
137 extern int physical_SetRtsCts(struct physical *, int);
138 extern void physical_SetSync(struct physical *);
139 extern int physical_ShowStatus(struct cmdargs const *);
140 extern void physical_Offline(struct physical *);
141 extern void physical_Close(struct physical *);
142 extern void physical_Destroy(struct physical *);
143 extern struct physical *iov2physical(struct datalink *, struct iovec *, int *,
144 int, int, int *, int *);
145 extern int physical2iov(struct physical *, struct iovec *, int *, int, int *,
146 int *);
147 extern const char *physical_LockedDevice(struct physical *);
148 extern void physical_ChangedPid(struct physical *, pid_t);
150 extern int physical_IsSync(struct physical *);
151 extern u_short physical_DeviceMTU(struct physical *);
152 extern const char *physical_GetDevice(struct physical *);
153 extern void physical_SetDeviceList(struct physical *, int, const char *const *);
154 extern void physical_SetDevice(struct physical *, const char *);
156 extern ssize_t physical_Read(struct physical *, void *, size_t);
157 extern ssize_t physical_Write(struct physical *, const void *, size_t);
158 extern int physical_doUpdateSet(struct fdescriptor *, fd_set *, fd_set *,
159 fd_set *, int *, int);
160 extern int physical_IsSet(struct fdescriptor *, const fd_set *);
161 extern void physical_DescriptorRead(struct fdescriptor *, struct bundle *,
162 const fd_set *);
163 extern void physical_Login(struct physical *, const char *);
164 extern int physical_RemoveFromSet(struct physical *, fd_set *, fd_set *,
165 fd_set *);
166 extern int physical_SetMode(struct physical *, int);
167 extern void physical_DeleteQueue(struct physical *);
168 extern void physical_SetupStack(struct physical *, const char *, int);
169 extern void physical_StopDeviceTimer(struct physical *);
170 extern int physical_MaxDeviceSize(void);
171 extern int physical_AwaitCarrier(struct physical *);
172 extern void physical_SetDescriptor(struct physical *);
173 extern void physical_SetAsyncParams(struct physical *, u_int32_t, u_int32_t);
174 extern int physical_Slot(struct physical *);