1998-01-29 00:49:32 +00:00
|
|
|
/*
|
|
|
|
* Written by Eivind Eklund <eivind@yes.no>
|
|
|
|
* for Yes Interactive
|
|
|
|
*
|
|
|
|
* Copyright (C) 1998, Yes Interactive. All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in any form is permitted. Redistribution in
|
|
|
|
* source form should include the above copyright and this set of
|
|
|
|
* conditions, because large sections american law seems to have been
|
|
|
|
* created by a bunch of jerks on drugs that are now illegal, forcing
|
|
|
|
* me to include this copyright-stuff instead of placing this in the
|
|
|
|
* public domain. The name of of 'Yes Interactive' or 'Eivind Eklund'
|
|
|
|
* may not be used to endorse or promote products derived from this
|
|
|
|
* software without specific prior written permission.
|
|
|
|
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
|
|
|
|
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
|
|
|
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
*
|
1998-03-06 00:34:47 +00:00
|
|
|
* $Id: physical.h,v 1.1.2.12 1998/02/23 00:38:39 brian Exp $
|
1998-01-29 00:49:32 +00:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
struct physical {
|
1998-01-30 19:46:07 +00:00
|
|
|
struct link link;
|
1998-02-09 19:21:11 +00:00
|
|
|
struct descriptor desc;
|
1998-02-02 19:33:40 +00:00
|
|
|
struct async async; /* Our async state */
|
1998-02-18 19:35:59 +00:00
|
|
|
struct hdlc hdlc; /* Our hdlc state */
|
1998-01-30 19:46:07 +00:00
|
|
|
int fd; /* File descriptor for this device */
|
|
|
|
int mbits; /* Current DCD status */
|
1998-02-06 02:24:29 +00:00
|
|
|
unsigned abort : 1; /* Something's gone horribly wrong */
|
1998-01-30 19:46:07 +00:00
|
|
|
unsigned dev_is_modem : 1; /* Is the device an actual modem?
|
|
|
|
Faked for sync devices, though...
|
|
|
|
(Possibly this should be
|
|
|
|
dev_is_not_tcp?) XXX-ML */
|
1998-01-29 00:49:32 +00:00
|
|
|
|
1998-01-30 19:46:07 +00:00
|
|
|
struct mbuf *out;
|
|
|
|
int connect_count;
|
1998-01-29 00:49:32 +00:00
|
|
|
|
1998-03-06 00:34:47 +00:00
|
|
|
struct {
|
|
|
|
char full[40];
|
|
|
|
char *base;
|
|
|
|
} name;
|
|
|
|
|
1998-01-30 19:46:07 +00:00
|
|
|
/* XXX-ML Most of the below is device specific, and probably do not
|
1998-01-29 00:49:32 +00:00
|
|
|
belong in the generic physical struct. It comes from modem.c. */
|
1998-02-17 19:29:03 +00:00
|
|
|
|
|
|
|
struct {
|
1998-02-21 01:45:26 +00:00
|
|
|
unsigned is_dedicated : 1; /* Dedicated mode? XXX-ML - not yet used */
|
|
|
|
unsigned is_direct : 1; /* Direct mode? XXX-ML - not yet used */
|
1998-02-17 19:29:03 +00:00
|
|
|
unsigned rts_cts : 1; /* Is rts/cts enabled? */
|
|
|
|
unsigned int parity; /* What parity is enabled? (TTY flags) */
|
|
|
|
unsigned int speed; /* Modem speed */
|
1998-03-06 00:34:47 +00:00
|
|
|
char devlist[LINE_LEN]; /* Comma-separated list of devices */
|
1998-02-17 19:29:03 +00:00
|
|
|
} cfg;
|
|
|
|
|
1998-01-30 19:46:07 +00:00
|
|
|
struct termios ios; /* To be able to reset from raw mode */
|
1998-01-29 00:49:32 +00:00
|
|
|
};
|
|
|
|
|
1998-02-09 19:21:11 +00:00
|
|
|
#define field2phys(fp, name) \
|
|
|
|
((struct physical *)((char *)fp - (int)(&((struct physical *)0)->name)))
|
|
|
|
|
|
|
|
#define physical2link(p) (&(p)->link)
|
|
|
|
#define link2physical(l) \
|
|
|
|
((l)->type == PHYSICAL_LINK ? field2phys(l, link) : NULL)
|
|
|
|
|
|
|
|
#define physical2descriptor(p) (&(p)->desc)
|
|
|
|
#define descriptor2physical(d) \
|
|
|
|
((d)->type == PHYSICAL_DESCRIPTOR ? field2phys(d, desc) : NULL)
|
1998-01-30 19:46:07 +00:00
|
|
|
|
1998-01-29 00:49:32 +00:00
|
|
|
int Physical_GetFD(struct physical *);
|
|
|
|
int Physical_IsATTY(struct physical *);
|
|
|
|
int Physical_IsSync(struct physical *);
|
|
|
|
int Physical_IsDedicated(struct physical *phys);
|
|
|
|
int Physical_IsDirect(struct physical *phys);
|
|
|
|
const char *Physical_GetDevice(struct physical *);
|
|
|
|
|
|
|
|
|
1998-03-06 00:34:47 +00:00
|
|
|
void Physical_SetDeviceList(struct physical *, const char *);
|
1998-01-29 00:49:32 +00:00
|
|
|
int /* Was this speed OK? */
|
|
|
|
Physical_SetSpeed(struct physical *phys, int speed);
|
|
|
|
|
|
|
|
/* XXX-ML I'm not certain this is the right way to handle this, but we
|
|
|
|
can solve that later. */
|
|
|
|
void Physical_SetSync(struct physical *phys);
|
|
|
|
|
1998-01-30 19:46:07 +00:00
|
|
|
int /* Can this be set? (Might not be a relevant attribute for this
|
|
|
|
device, for instance) */
|
1998-01-29 00:49:32 +00:00
|
|
|
Physical_SetRtsCts(struct physical *phys, int enable);
|
|
|
|
|
|
|
|
void Physical_SetDedicated(struct physical *phys, int enable);
|
|
|
|
void Physical_SetDirect(struct physical *phys, int enable);
|
|
|
|
|
|
|
|
void Physical_FD_SET(struct physical *, fd_set *);
|
|
|
|
int Physical_FD_ISSET(struct physical *, fd_set *);
|
|
|
|
|
|
|
|
void Physical_DupAndClose(struct physical *);
|
|
|
|
ssize_t Physical_Read(struct physical *phys, void *buf, size_t nbytes);
|
|
|
|
ssize_t Physical_Write(struct physical *phys, const void *buf, size_t nbytes);
|
1998-02-06 02:22:28 +00:00
|
|
|
int Physical_ReportProtocolStatus(struct cmdargs const *);
|
1998-02-13 05:10:26 +00:00
|
|
|
int Physical_UpdateSet(struct descriptor *, fd_set *, fd_set *, fd_set *,
|
|
|
|
int *, int);
|
1998-02-09 19:21:11 +00:00
|
|
|
int Physical_IsSet(struct descriptor *, fd_set *);
|
1998-02-23 00:38:44 +00:00
|
|
|
void Physical_DescriptorWrite(struct descriptor *, struct bundle *,
|
|
|
|
const fd_set *);
|