xref: /freebsd/usr.sbin/ppp/physical.h (revision a8445737e740901f5f2c8d24c12ef7fc8b00134e)
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.3 1998/05/29 18:33:10 brian Exp $
20  *
21  */
22 
23 struct bundle;
24 
25 struct physical {
26   struct link link;
27   struct descriptor desc;
28   int type;                    /* What sort of PHYS_* link are we ? */
29   struct async async;          /* Our async state */
30   struct hdlc hdlc;            /* Our hdlc state */
31   int fd;                      /* File descriptor for this device */
32   int mbits;                   /* Current DCD status */
33   unsigned dev_is_modem : 1;   /* Is the device an actual modem?
34                                   Faked for sync devices, though...
35                                   (Possibly this should be
36                                   dev_is_not_tcp?) XXX-ML */
37 
38   struct mbuf *out;            /* mbuf that suffered a short write */
39   int connect_count;
40   struct datalink *dl;         /* my owner */
41 
42   struct {
43     char full[40];
44     char *base;
45   } name;
46 
47   unsigned Utmp : 1;           /* Are we in utmp ? */
48   pid_t session_owner;         /* HUP this when closing the link */
49 
50   /* XXX-ML Most of the below is device specific, and probably do not
51       belong in the generic physical struct. It comes from modem.c. */
52 
53   struct {
54     unsigned rts_cts : 1;      /* Is rts/cts enabled? */
55     unsigned parity;           /* What parity is enabled? (TTY flags) */
56     unsigned speed;            /* Modem speed */
57     char devlist[LINE_LEN];    /* Comma-separated list of devices */
58   } cfg;
59 
60   struct termios ios;          /* To be able to reset from raw mode */
61 
62   struct pppTimer Timer;       /* CD checks */
63 };
64 
65 #define field2phys(fp, name) \
66   ((struct physical *)((char *)fp - (int)(&((struct physical *)0)->name)))
67 
68 #define link2physical(l) \
69   ((l)->type == PHYSICAL_LINK ? field2phys(l, link) : NULL)
70 
71 #define descriptor2physical(d) \
72   ((d)->type == PHYSICAL_DESCRIPTOR ? field2phys(d, desc) : NULL)
73 
74 extern int physical_GetFD(struct physical *);
75 extern int physical_IsATTY(struct physical *);
76 extern int physical_IsSync(struct physical *);
77 extern const char *physical_GetDevice(struct physical *);
78 extern void physical_SetDeviceList(struct physical *, int, const char *const *);
79 extern int physical_SetSpeed(struct physical *, int);
80 
81 /*
82  * XXX-ML I'm not certain this is the right way to handle this, but we
83  * can solve that later.
84  */
85 extern void physical_SetSync(struct physical *);
86 
87 /*
88  * Can this be set?  (Might not be a relevant attribute for this
89  * device, for instance)
90  */
91 extern int physical_SetRtsCts(struct physical *, int);
92 
93 extern ssize_t physical_Read(struct physical *, void *, size_t);
94 extern ssize_t physical_Write(struct physical *, const void *, size_t);
95 extern int physical_UpdateSet(struct descriptor *, fd_set *, fd_set *,
96                               fd_set *, int *, int);
97 extern int physical_IsSet(struct descriptor *, const fd_set *);
98 extern void physical_Login(struct physical *, const char *);
99 extern void physical_Logout(struct physical *);
100 extern int physical_RemoveFromSet(struct physical *, fd_set *, fd_set *,
101                                   fd_set *);
102 extern int physical_SetMode(struct physical *, int);
103 extern void physical_DeleteQueue(struct physical *);
104