physical.h revision 36285
136285Sbrian/*
236285Sbrian * Written by Eivind Eklund <eivind@yes.no>
336285Sbrian *    for Yes Interactive
436285Sbrian *
536285Sbrian * Copyright (C) 1998, Yes Interactive.  All rights reserved.
636285Sbrian *
736285Sbrian * Redistribution and use in any form is permitted.  Redistribution in
836285Sbrian * source form should include the above copyright and this set of
936285Sbrian * conditions, because large sections american law seems to have been
1036285Sbrian * created by a bunch of jerks on drugs that are now illegal, forcing
1136285Sbrian * me to include this copyright-stuff instead of placing this in the
1236285Sbrian * public domain.  The name of of 'Yes Interactive' or 'Eivind Eklund'
1336285Sbrian * may not be used to endorse or promote products derived from this
1436285Sbrian * software without specific prior written permission.
1536285Sbrian * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
1636285Sbrian * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
1736285Sbrian * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
1836285Sbrian *
1936285Sbrian *  $Id: physical.h,v 1.1.2.26 1998/05/15 23:58:26 brian Exp $
2036285Sbrian *
2136285Sbrian */
2236285Sbrian
2336285Sbrianstruct bundle;
2436285Sbrian
2536285Sbrianstruct physical {
2636285Sbrian  struct link link;
2736285Sbrian  struct descriptor desc;
2836285Sbrian  int type;                    /* What sort of PHYS_* link are we ? */
2936285Sbrian  struct async async;          /* Our async state */
3036285Sbrian  struct hdlc hdlc;            /* Our hdlc state */
3136285Sbrian  int fd;                      /* File descriptor for this device */
3236285Sbrian  int mbits;                   /* Current DCD status */
3336285Sbrian  unsigned dev_is_modem : 1;   /* Is the device an actual modem?
3436285Sbrian                                  Faked for sync devices, though...
3536285Sbrian                                  (Possibly this should be
3636285Sbrian                                  dev_is_not_tcp?) XXX-ML */
3736285Sbrian
3836285Sbrian  struct mbuf *out;            /* mbuf that suffered a short write */
3936285Sbrian  int connect_count;
4036285Sbrian  struct datalink *dl;         /* my owner */
4136285Sbrian
4236285Sbrian  struct {
4336285Sbrian    char full[40];
4436285Sbrian    char *base;
4536285Sbrian  } name;
4636285Sbrian
4736285Sbrian  unsigned Utmp : 1;           /* Are we in utmp ? */
4836285Sbrian
4936285Sbrian  /* XXX-ML Most of the below is device specific, and probably do not
5036285Sbrian      belong in the generic physical struct. It comes from modem.c. */
5136285Sbrian
5236285Sbrian  struct {
5336285Sbrian    unsigned rts_cts : 1;      /* Is rts/cts enabled? */
5436285Sbrian    unsigned parity;           /* What parity is enabled? (TTY flags) */
5536285Sbrian    unsigned speed;            /* Modem speed */
5636285Sbrian    char devlist[LINE_LEN];    /* Comma-separated list of devices */
5736285Sbrian  } cfg;
5836285Sbrian
5936285Sbrian  struct termios ios;          /* To be able to reset from raw mode */
6036285Sbrian
6136285Sbrian  struct pppTimer Timer;       /* CD checks */
6236285Sbrian};
6336285Sbrian
6436285Sbrian#define field2phys(fp, name) \
6536285Sbrian  ((struct physical *)((char *)fp - (int)(&((struct physical *)0)->name)))
6636285Sbrian
6736285Sbrian#define link2physical(l) \
6836285Sbrian  ((l)->type == PHYSICAL_LINK ? field2phys(l, link) : NULL)
6936285Sbrian
7036285Sbrian#define descriptor2physical(d) \
7136285Sbrian  ((d)->type == PHYSICAL_DESCRIPTOR ? field2phys(d, desc) : NULL)
7236285Sbrian
7336285Sbrianextern int physical_GetFD(struct physical *);
7436285Sbrianextern int physical_IsATTY(struct physical *);
7536285Sbrianextern int physical_IsSync(struct physical *);
7636285Sbrianextern const char *physical_GetDevice(struct physical *);
7736285Sbrianextern void physical_SetDeviceList(struct physical *, int, const char *const *);
7836285Sbrianextern int physical_SetSpeed(struct physical *, int);
7936285Sbrian
8036285Sbrian/*
8136285Sbrian * XXX-ML I'm not certain this is the right way to handle this, but we
8236285Sbrian * can solve that later.
8336285Sbrian */
8436285Sbrianextern void physical_SetSync(struct physical *);
8536285Sbrian
8636285Sbrian/*
8736285Sbrian * Can this be set?  (Might not be a relevant attribute for this
8836285Sbrian * device, for instance)
8936285Sbrian */
9036285Sbrianextern int physical_SetRtsCts(struct physical *, int);
9136285Sbrian
9236285Sbrianextern ssize_t physical_Read(struct physical *, void *, size_t);
9336285Sbrianextern ssize_t physical_Write(struct physical *, const void *, size_t);
9436285Sbrianextern int physical_UpdateSet(struct descriptor *, fd_set *, fd_set *,
9536285Sbrian                              fd_set *, int *, int);
9636285Sbrianextern int physical_IsSet(struct descriptor *, const fd_set *);
9736285Sbrianextern void physical_Login(struct physical *, const char *);
9836285Sbrianextern void physical_Logout(struct physical *);
9936285Sbrianextern int physical_RemoveFromSet(struct physical *, fd_set *, fd_set *,
10036285Sbrian                                  fd_set *);
10136285Sbrianextern int physical_SetMode(struct physical *, int);
102