xref: /freebsd/usr.sbin/ppp/physical.h (revision 2764b86afdc99a30f4b1a4da2c04db8aa7aa785d)
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.1.2.18 1998/04/03 19:21:50 brian Exp $
20  *
21  */
22 
23 struct bundle;
24 
25 struct physical {
26   struct link link;
27   struct descriptor desc;
28   struct async async;          /* Our async state */
29   struct hdlc hdlc;            /* Our hdlc state */
30   int fd;                      /* File descriptor for this device */
31   int mbits;                   /* Current DCD status */
32   unsigned dev_is_modem : 1;   /* Is the device an actual modem?
33                                   Faked for sync devices, though...
34                                   (Possibly this should be
35                                   dev_is_not_tcp?) XXX-ML */
36 
37   struct mbuf *out;            /* mbuf that suffered a short write */
38   int connect_count;
39   struct datalink *dl;         /* my owner */
40 
41   struct {
42     char full[40];
43     char *base;
44   } name;
45 
46   unsigned Utmp : 1;           /* Are we in utmp ? */
47 
48   /* XXX-ML Most of the below is device specific, and probably do not
49       belong in the generic physical struct. It comes from modem.c. */
50 
51   struct {
52     unsigned is_dedicated : 1; /* Dedicated mode?  XXX-ML - not yet used */
53     unsigned is_direct : 1;    /* Direct mode?  XXX-ML - not yet used */
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 
63 #define field2phys(fp, name) \
64   ((struct physical *)((char *)fp - (int)(&((struct physical *)0)->name)))
65 
66 #define physical2link(p) (&(p)->link)
67 #define link2physical(l) \
68   ((l)->type == PHYSICAL_LINK ? field2phys(l, link) : NULL)
69 
70 #define physical2descriptor(p) (&(p)->desc)
71 #define descriptor2physical(d) \
72   ((d)->type == PHYSICAL_DESCRIPTOR ? field2phys(d, desc) : NULL)
73 
74 int Physical_GetFD(struct physical *);
75 int Physical_IsATTY(struct physical *);
76 int Physical_IsSync(struct physical *);
77 int Physical_IsDedicated(struct physical *);
78 int Physical_IsDirect(struct physical *);
79 const char *Physical_GetDevice(struct physical *);
80 
81 
82 void Physical_SetDeviceList(struct physical *, const char *);
83 int /* Was this speed OK? */
84 Physical_SetSpeed(struct physical *, int);
85 
86 /* XXX-ML I'm not certain this is the right way to handle this, but we
87    can solve that later. */
88 void Physical_SetSync(struct physical *);
89 
90 int /* Can this be set?  (Might not be a relevant attribute for this
91        device, for instance) */
92 Physical_SetRtsCts(struct physical *, int);
93 
94 void Physical_SetDedicated(struct physical *, int);
95 void Physical_SetDirect(struct physical *, int);
96 
97 void Physical_FD_SET(struct physical *, fd_set *);
98 int Physical_FD_ISSET(struct physical *, fd_set *);
99 
100 void Physical_DupAndClose(struct physical *);
101 ssize_t Physical_Read(struct physical *, void *, size_t);
102 ssize_t Physical_Write(struct physical *, const void *, size_t);
103 int Physical_UpdateSet(struct descriptor *, fd_set *, fd_set *, fd_set *,
104                        int *, int);
105 int Physical_IsSet(struct descriptor *, const fd_set *);
106 void Physical_DescriptorWrite(struct descriptor *, struct bundle *,
107                               const fd_set *);
108 
109 void Physical_Login(struct physical *, const char *);
110 void Physical_Logout(struct physical *);
111