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