An ISDN driver that supports the EDSS1 and the 1TR6 ISDN interfaces.
EDSS1 is the "Euro-ISDN", 1TR6 is the soon obsolete german ISDN Interface. Obtained from: Dietmar Friede <dfriede@drnhh.neuhaus.de> and Juergen Krause <jkr@saarlink.de> This is only one part - the rest to follow in a couple of hours. This part is a benign import, since it doesn't affect anything else.
This commit is contained in:
parent
25db89ddf1
commit
46a237b729
1142
sys/gnu/i386/isa/nic3008.c
Normal file
1142
sys/gnu/i386/isa/nic3008.c
Normal file
File diff suppressed because it is too large
Load Diff
114
sys/gnu/i386/isa/nic3008.h
Normal file
114
sys/gnu/i386/isa/nic3008.h
Normal file
@ -0,0 +1,114 @@
|
||||
static char nic38hid[] = "@(#)$Id: nic3008.h,v 1.1 1995/01/25 14:06:18 jkr Exp jkr $";
|
||||
/*******************************************************************************
|
||||
* II - Version 0.1 $Revision: 1.1 $ $State: Exp $
|
||||
*
|
||||
* Copyright 1994 Dietmar Friede
|
||||
*******************************************************************************
|
||||
* Bug reports, patches, comments, suggestions should be sent to:
|
||||
*
|
||||
* jkr@saarlink.de or jkrause@guug.de
|
||||
*
|
||||
*******************************************************************************
|
||||
* $Log: nic3008.h,v $
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
/*
|
||||
* This file defines the NICCY 3008 Interface.
|
||||
* Copyright Dr. Neuhaus GmbH, Hamburg and Dietmar Friede
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma pack (1)
|
||||
|
||||
typedef struct {
|
||||
u_short type; /* Message Subtype/Type */
|
||||
u_char source;
|
||||
u_char dest;
|
||||
u_short number; /* laufende Nachrichten-Nummer */
|
||||
u_short timeoutval; /* Wert f<>r Timeout */
|
||||
u_char priority; /* Nachrichten-Priorit„t */
|
||||
u_char more_data; /* Nachricht vollst„ndig? */
|
||||
u_short data_len; /* Datenmenge */
|
||||
u_char buf_valid; /* im aux. buf.? */
|
||||
u_char reserved[1];
|
||||
u_short add_info; /* Maske */
|
||||
u_char data[0x30];/* Datenfeld */
|
||||
} mbx_type;
|
||||
|
||||
/* ------------------------------------------------------------------------ */
|
||||
|
||||
typedef struct {
|
||||
/* Offset 0x0000 ---------------------------------------------------------- */
|
||||
u_char msg_flg[8]; /* Messages in MBX i */
|
||||
u_char card_number; /* Kartennummer of Applikation */
|
||||
u_char card_state; /* Kartenstatus */
|
||||
u_short mainloop_cnt; /* NICCY's M'loop,68000-Notation*/
|
||||
u_char watchdog_cnt; /* Applikation "lebt"? */
|
||||
u_char hw_config; /* Steckmodule? */
|
||||
u_char jmp_config; /* Karten-Jumper? */
|
||||
u_char ram_config; /* Karten-Speicher? */
|
||||
/* Offset 0x0010 -----------------------------------------------------------*/
|
||||
char niccy_ver[0x0E]; /* "NICCY V x.yyy\c" */
|
||||
u_char int_flg_pc; /* Will PC Interrupts? */
|
||||
u_char int_flg_nic; /* Will NICCY Interrupts? */
|
||||
/* Offset 0x0020 -----------------------------------------------------------*/
|
||||
u_short buf_ptr[8]; /* Pointer to aux. buf. ... */
|
||||
/* Offset 0x0030 -----------------------------------------------------------*/
|
||||
u_short buf_len[8]; /* Size of aux. buf. ... */
|
||||
/* Offset 0x0040 -----------------------------------------------------------*/
|
||||
/* 0x40 Bytes f<>r die */
|
||||
/* frei verf<72>gbar */
|
||||
u_char old_flg[8]; /* Messages in MBX i */
|
||||
u_char irq_level; /* welcher IRQ (als Bitmaske */
|
||||
u_char res[7]; /* FREI */
|
||||
/* Offset 0x0050 -----------------------------------------------------------*/
|
||||
u_char api_area_int_nr; /*SW-Int des API wenn API_ACTIVE*/
|
||||
u_char api_area_PLCI[2]; /* PLCI w„hrend ApiManufacturer */
|
||||
u_char capi_version[6]; /* Versionsnummer der CAPI */
|
||||
u_char api_area[0x27]; /* FREI */
|
||||
/* Offset 0x0080 -----------------------------------------------------------*/
|
||||
u_char api_active; /* Flag ob CAPI aktiv ist */
|
||||
u_char ext_hw_config; /* Bit 0: UART 16550 */
|
||||
/* Bit 1..7: reserved */
|
||||
u_char dpr_hw_id[0x0E]; /* Hardware ID */
|
||||
/* Offset 0x0090 -----------------------------------------------------------*/
|
||||
u_char dpr_listen_req;/* Anzahl Listen Request's */
|
||||
u_char dpr_state_b1; /* state B1 channel */
|
||||
/* 0x00 : channel ist frei */
|
||||
/* 0x01 : Verbindungsaufb. Req */
|
||||
/* 0x02 : Verbindungsaufb. Act */
|
||||
/* 0x03 : Verbindung besteht */
|
||||
/* 0x04 : eintreffender Ruf */
|
||||
/* 0x05 : Verbindung angenommen */
|
||||
/* 0x06 : Verbindungsabb. Req */
|
||||
/* 0x07 : Verbindungsabb. laeuft*/
|
||||
/* 0x08 : Verbindung getrennt */
|
||||
u_char dpr_state_b2; /* state B2 channel (siehe oben)*/
|
||||
u_char dpr_state_ic1; /* state of Intercomm-Channel */
|
||||
u_char dpr_state_ic2; /* ----------- " -------------- */
|
||||
u_char state_res[0x04];
|
||||
u_char dpr_si_b1; /* Service Indicator auf B1 */
|
||||
u_char dpr_si_b2; /* Service Indicator auf B2 */
|
||||
u_char dpr_state_res_0[0x05];
|
||||
/* Offset 0x00A0 -----------------------------------------------------------*/
|
||||
u_char dpr_state_hscx; /* state of HSCX */
|
||||
u_char dpr_state_itac; /* state of ITAC */
|
||||
u_char dpr_state_arcofi;/* state of ARCOFI */
|
||||
u_char dpr_state_modem; /* state of Aufsteckmodem */
|
||||
u_char dpr_state_com; /* state of COM */
|
||||
u_char dpr_state_res[0x0B];
|
||||
/* Offset 0x00B0 -----------------------------------------------------------*/
|
||||
u_char dpr_state_ia_tel;/* state of internal Appl. */
|
||||
u_char dpr_state_ia_com;/* state of internal Appl. */
|
||||
u_char dpr_state_ia_mod;/* state of internal Appl. */
|
||||
u_char dpr_state_res_1[0x0D];
|
||||
/* Offset 0x00C0 -----------------------------------------------------------*/
|
||||
u_char dpr_state_dcp[0x10];/* state of D-channel Prot */
|
||||
/* Offset 0x00D0 -----------------------------------------------------------*/
|
||||
u_char reserved[0x130];
|
||||
/* Offset 0x0200 -----------------------------------------------------------*/
|
||||
mbx_type dpr_mbx[8]; /* the mailboxes ... */
|
||||
} dpr_type;
|
||||
|
||||
#pragma pack ()
|
1209
sys/gnu/i386/isa/nic3009.c
Normal file
1209
sys/gnu/i386/isa/nic3009.c
Normal file
File diff suppressed because it is too large
Load Diff
79
sys/gnu/i386/isa/nic3009.h
Normal file
79
sys/gnu/i386/isa/nic3009.h
Normal file
@ -0,0 +1,79 @@
|
||||
static char nic39hid[] = "@(#)$Id: nic3009.h,v 1.1 1995/01/25 14:06:18 jkr Exp jkr $";
|
||||
/*******************************************************************************
|
||||
* II - Version 0.1 $Revision: 1.1 $ $State: Exp $
|
||||
*
|
||||
* Copyright 1994 Dietmar Friede
|
||||
*******************************************************************************
|
||||
* Bug reports, patches, comments, suggestions should be sent to:
|
||||
*
|
||||
* jkr@saarlink.de or jkrause@guug.de
|
||||
*
|
||||
*******************************************************************************
|
||||
* $Log: nic3009.h,v $
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
/*
|
||||
* This file defines the NICCY 3009 Interface. Copyright Dr. Neuhaus GmbH,
|
||||
* Hamburg and Dietmar Friede
|
||||
*
|
||||
*/
|
||||
|
||||
#define NO_MORE_DATA 0x00 /* der Message folgen keine Daten */
|
||||
#define MORE_DATA 0x01 /* der Message folgen weitere Daten */
|
||||
|
||||
#define DPR_LEN 0x800 /* 2 kBytes gross */
|
||||
#define DPR_VAR_AREA_LEN 0x100 /* davon fuer allg. Variablen */
|
||||
|
||||
#define DPR_MBX_LEN (DPR_LEN-DPR_VAR_AREA_LEN)/2 /* 0x380 lang */
|
||||
#define DPR_MBX_FLAG_LEN 2 /* zwei Bytes MBX-Zustand... */
|
||||
#define DPR_MSG_HDR_LEN 10 /* Msg-Laenge ohne Datafield */
|
||||
#define DATAFIELD_LEN (DPR_MBX_LEN-DPR_MBX_FLAG_LEN-DPR_MSG_HDR_LEN)
|
||||
#define MAX_B3_LEN (2048+2) /* Daten und Network-Header */
|
||||
|
||||
#pragma pack (1)
|
||||
typedef struct
|
||||
{
|
||||
u_char msg_flag; /* Signalisierung NICCY / PC */
|
||||
u_char progress; /* NICCY-interne Verwendung ! */
|
||||
u_char type;
|
||||
u_char subtype;
|
||||
u_short number;
|
||||
u_char more_data;
|
||||
u_char reserved;
|
||||
u_short data_len;
|
||||
u_short plci;
|
||||
u_char data[DATAFIELD_LEN];
|
||||
} mbx_type;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
mbx_type up_mbx; /* Offset 0x000-0x37F */
|
||||
mbx_type dn_mbx; /* Offset 0x380-0x6FF */
|
||||
u_char card_number; /* Offset 0x700 */
|
||||
u_char card_state; /* Offset 0x701 */
|
||||
u_short mainloop_cnt; /* Offset 0x702-0x703 */
|
||||
u_char watchdog_cnt; /* Offset 0x704 */
|
||||
u_char hw_config; /* Offset 0x705 */
|
||||
u_char int_flg_pc; /* Offset 0x706 */
|
||||
u_char int_flg_nic; /* Offset 0x707 */
|
||||
u_char api_area[64]; /* Offset 0x708-0x747 */
|
||||
u_char api_active; /* Offset 0x748 */
|
||||
u_char tei; /* Offset 0x749 */
|
||||
u_char state_b1; /* Offset 0x74A */
|
||||
u_char state_b2; /* Offset 0x74B */
|
||||
u_char si_b1; /* Offset 0x74C */
|
||||
u_char si_b2; /* Offset 0x74D */
|
||||
u_short calls_in; /* Offset 0x74E-0x74F */
|
||||
u_short calls_out; /* Offset 0x750-0x751 */
|
||||
u_char ram_config; /* Offset 0x752 */
|
||||
u_char spv_request_flag; /* Offset 0x753 */
|
||||
u_char dcp_state_b1; /* Offset 0x754 */
|
||||
u_char dcp_state_b2; /* Offset 0x755 */
|
||||
u_char dc_protocol; /* Offset 0x756 */
|
||||
u_char poll_flag; /* Offset 0x757 */
|
||||
u_char debug[DPR_LEN - 0x758 - 4]; /* Offset 0x758-0x7FB */
|
||||
u_short signal_niccy_to_pc; /* Offset 0x7FC-0x7FD */
|
||||
u_short signal_pc_to_niccy; /* Offset 0x7FE-0x7FF */
|
||||
} dpr_type;
|
||||
#pragma pack ()
|
158
sys/gnu/i386/isa/niccyreg.h
Normal file
158
sys/gnu/i386/isa/niccyreg.h
Normal file
@ -0,0 +1,158 @@
|
||||
static char nicregh_id[] = "@(#)$Id: niccyreg.h,v 1.1 1995/01/25 14:06:18 jkr Exp jkr $";
|
||||
/*******************************************************************************
|
||||
* II - Version 0.1 $Revision: 1.1 $ $State: Exp $
|
||||
*
|
||||
* Copyright 1994 Dietmar Friede
|
||||
*******************************************************************************
|
||||
* Bug reports, patches, comments, suggestions should be sent to:
|
||||
*
|
||||
* jkr@saarlink.de or jkrause@guug.de
|
||||
*
|
||||
*******************************************************************************
|
||||
* $Log: niccyreg.h,v $
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
/*
|
||||
* This file defines the NICCY 3008 Interface.
|
||||
* Copyright Dr. Neuhaus GmbH, Hamburg and Dietmar Friede
|
||||
*
|
||||
*/
|
||||
|
||||
#define MBX_MU 0
|
||||
#define MBX_MD 1
|
||||
#define MBX_DU 2
|
||||
#define MBX_DD 3
|
||||
#define MBX_B1U 4
|
||||
#define MBX_B1D 5
|
||||
#define MBX_B2U 6
|
||||
#define MBX_B2D 7
|
||||
|
||||
#define MBX_xU 0x55
|
||||
#define MBX_xD 0xAA
|
||||
|
||||
/* -------------------------------------------------------------------- */
|
||||
|
||||
#define MU_INIT_CNF 0x00
|
||||
#define MU_INIT_IND 0x01
|
||||
#define MU_RESET_CNF 0x02
|
||||
#define MU_HANDSET_IND 0x03
|
||||
#define MU_DNL_MOD_CNF 0x04
|
||||
/* reserved: 0x05 */
|
||||
#define MU_DNL_MOD_IND 0x06
|
||||
#define MU_DISC_MOD_CNF 0x07
|
||||
#define MU_LIST_MOD_CNF 0x08
|
||||
#define MU_LIST_MOD_DATA 0x09
|
||||
/* reserved: 0x0A to 0x0B */
|
||||
#define MU_HW_CONFIG_CNF 0x0C
|
||||
#define MU_HW_ID_CNF 0x0D
|
||||
#define MU_SET_CLOCK_CNF 0x0E
|
||||
#define MU_GET_CLOCK_CNF 0x0F
|
||||
#define MU_ACT_IA_CNF 0x10
|
||||
#define MU_ACT_IA_IND 0x11
|
||||
#define MU_DEACT_IA_CNF 0x12
|
||||
#define MU_DEACT_IA_IND 0x13
|
||||
#define MU_POLL_CNF 0x14
|
||||
#define MU_POLL_IND 0x15
|
||||
/* reserved: 0x16 to 0x1D */
|
||||
#define MU_MANUFACT_CNF 0x1E
|
||||
#define MU_MANUFACT_IND 0x1F
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
#define MD_INIT_REQ 0x20
|
||||
#define MD_INIT_RSP 0x21
|
||||
#define MD_RESET_REQ 0x22
|
||||
#define MD_HANDSET_RSP 0x23
|
||||
#define MD_DNL_MOD_REQ 0x24
|
||||
#define MD_DNL_MOD_DATA 0x25
|
||||
#define MD_DNL_MOD_RSP 0x26
|
||||
#define MD_DISC_MOD_REQ 0x27
|
||||
#define MD_LIST_MOD_REQ 0x28
|
||||
/* reserved: 0x29 to 0x2B */
|
||||
#define MD_HW_CONFIG_REQ 0x2C
|
||||
#define MD_HW_ID_REQ 0x2D
|
||||
#define MD_SET_CLOCK_REQ 0x2E
|
||||
#define MD_GET_CLOCK_REQ 0x2F
|
||||
#define MD_ACT_IA_REQ 0x30
|
||||
#define MD_ACT_IA_RSP 0x31
|
||||
#define MD_DEACT_IA_REQ 0x32
|
||||
#define MD_DEACT_IA_RSP 0x33
|
||||
#define MD_POLL_REQ 0x34
|
||||
#define MD_POLL_RSP 0x35
|
||||
#define MD_STATE_IND 0x37
|
||||
#define MD_MANUFACT_REQ 0x3E
|
||||
#define MD_MANUFACT_RSP 0x3F
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
#define DU_CONN_CNF 0x40
|
||||
#define DU_CONN_IND 0x41
|
||||
#define DU_CONN_ACT_IND 0x42
|
||||
#define DU_DISC_CNF 0x43
|
||||
#define DU_DISC_IND 0x44
|
||||
#define DU_DATA_CNF 0x45
|
||||
#define DU_DATA_IND 0x46
|
||||
#define DU_LISTEN_CNF 0x47
|
||||
#define DU_GET_PAR_CNF 0x48
|
||||
#define DU_INFO_CNF 0x49
|
||||
#define DU_INFO_IND 0x4A
|
||||
#define DU_CONN_INFO_CNF 0x4B
|
||||
#define DU_REL_PLCI_CNF 0x4C
|
||||
/* reserved: 0x4C to 0x5E */
|
||||
#define DU_STR_NOT_COMP 0x5F
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
#define DD_CONN_REQ 0x60
|
||||
#define DD_CONN_RSP 0x61
|
||||
#define DD_CONN_ACT_RSP 0x62
|
||||
#define DD_DISC_REQ 0x63
|
||||
#define DD_DISC_RSP 0x64
|
||||
#define DD_DATA_REQ 0x65
|
||||
#define DD_DATA_RSP 0x66
|
||||
#define DD_LISTEN_REQ 0x67
|
||||
#define DD_GET_PAR_REQ 0x68
|
||||
#define DD_INFO_REQ 0x69
|
||||
#define DD_INFO_RSP 0x6A
|
||||
#define DD_CONN_INFO_REQ 0x6B
|
||||
#define DD_REL_PLCI_REQ 0x6C
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
#define BD_SEL_PROT_REQ 0xA0
|
||||
#define BD_LIST_B3_REQ 0xA1
|
||||
#define BD_CONN_B3_REQ 0xA2
|
||||
#define BD_CONN_B3_RSP 0xA3
|
||||
#define BD_C_B3_ACT_RSP 0xA4
|
||||
#define BD_DISC_B3_REQ 0xA5
|
||||
#define BD_DISC_B3_RSP 0xA6
|
||||
#define BD_GET_P_B3_REQ 0xA7
|
||||
#define BD_DATA_B3_REQ 0xA8
|
||||
#define BD_DATA_B3_RSP 0xA9
|
||||
#define BD_RESET_B3_REQ 0xAA
|
||||
#define BD_RESET_B3_RSP 0xAB
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
|
||||
#define NICCY_DEBUG _IOWR('N',1,dbg_type)
|
||||
#define NICCY_RESET _IOWR('N',2,int)
|
||||
#define NICCY_LOAD _IOWR('N',3,struct head)
|
||||
#define NICCY_SET_CLOCK _IOWR('N',4,time_str_t)
|
||||
#define NICCY_SPY _IOWR('N',5,int)
|
||||
|
||||
struct head
|
||||
{
|
||||
u_long len;
|
||||
u_long sig;
|
||||
char nam[8];
|
||||
char ver[5];
|
||||
u_char typ;
|
||||
u_short status;
|
||||
u_long d_len;
|
||||
u_char *data;
|
||||
};
|
||||
|
||||
typedef char time_str_t[14];
|
||||
typedef u_char dbg_type[10000];
|
245
sys/gnu/isdn/if_ii.c
Normal file
245
sys/gnu/isdn/if_ii.c
Normal file
@ -0,0 +1,245 @@
|
||||
static char _if_iiid[] = "@(#)$Id: if_ii.c,v 1.1 1995/01/25 14:06:18 jkr Exp jkr $";
|
||||
/*******************************************************************************
|
||||
* II - Version 0.1 $Revision: 1.1 $ $State: Exp $
|
||||
*
|
||||
* Copyright 1994 Dietmar Friede
|
||||
*******************************************************************************
|
||||
* Bug reports, patches, comments, suggestions should be sent to:
|
||||
*
|
||||
* jkr@saarlink.de or jkrause@guug.de
|
||||
*
|
||||
*******************************************************************************
|
||||
* $Log: if_ii.c,v $
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
/*
|
||||
* Copyright (c) 1994 Dietmar Friede (dietmar@friede.de) All rights reserved.
|
||||
* FSF/FSAG GNU Copyright applies
|
||||
*
|
||||
* A high level ip isdn driver.
|
||||
*
|
||||
* Uses loop driver as template. Small - and simple - is beautiful.
|
||||
*/
|
||||
|
||||
#include "param.h"
|
||||
#include "systm.h"
|
||||
#include "mbuf.h"
|
||||
#include "socket.h"
|
||||
#include "errno.h"
|
||||
#include "ioctl.h"
|
||||
#include "protosw.h"
|
||||
|
||||
#include "net/if.h"
|
||||
#include "net/if_types.h"
|
||||
#include "net/netisr.h"
|
||||
#include "net/route.h"
|
||||
|
||||
#ifdef INET
|
||||
#include "netinet/in.h"
|
||||
#include "netinet/in_systm.h"
|
||||
#include "netinet/in_var.h"
|
||||
#include "netinet/ip.h"
|
||||
#endif
|
||||
|
||||
#include "ii.h"
|
||||
#include "isdn/isdn_ioctl.h"
|
||||
|
||||
#define IIMTU 1500
|
||||
|
||||
static struct ifnet ii_if[NII];
|
||||
static int applnr[NII];
|
||||
static int next_if = 0;
|
||||
int iioutput(), ii_ioctl();
|
||||
|
||||
int
|
||||
iiattach(int ap)
|
||||
{
|
||||
register struct ifnet *ifp;
|
||||
|
||||
if (next_if >= NII)
|
||||
return -1;
|
||||
|
||||
applnr[next_if] = ap;
|
||||
ifp = &ii_if[next_if];
|
||||
ifp->if_unit = next_if;
|
||||
ifp->if_name = "ii";
|
||||
ifp->if_mtu = IIMTU;
|
||||
ifp->if_flags = IFF_SIMPLEX | IFF_POINTOPOINT ;
|
||||
ifp->if_ioctl = ii_ioctl;
|
||||
ifp->if_output = iioutput;
|
||||
ifp->if_type = IFT_ISDNBASIC;
|
||||
ifp->if_hdrlen = 0;
|
||||
ifp->if_addrlen = 0;
|
||||
ifp->if_snd.ifq_maxlen = IFQ_MAXLEN;
|
||||
if_attach(ifp);
|
||||
/* ifp->if_flags |= IFF_RUNNING; */
|
||||
return next_if++;
|
||||
}
|
||||
|
||||
int
|
||||
iioutput(struct ifnet * ifp, struct mbuf * m, struct sockaddr * dst)
|
||||
{
|
||||
int s, isr;
|
||||
register struct ifqueue *ifq = 0;
|
||||
|
||||
if (dst->sa_family != AF_INET)
|
||||
{
|
||||
m_freem(m);
|
||||
return EAFNOSUPPORT;
|
||||
}
|
||||
s = splhigh();
|
||||
if (IF_QFULL(&ifp->if_snd))
|
||||
{
|
||||
IF_DROP(&ifp->if_snd);
|
||||
m_freem(m);
|
||||
ifp->if_oerrors++;
|
||||
isdn_output(applnr[ifp->if_unit]);
|
||||
splx(s);
|
||||
return (ENOBUFS);
|
||||
}
|
||||
IF_ENQUEUE(&ifp->if_snd, m);
|
||||
|
||||
ifp->if_opackets++;
|
||||
ifp->if_obytes += m->m_pkthdr.len;
|
||||
|
||||
isdn_output(applnr[ifp->if_unit]);
|
||||
splx(s);
|
||||
return (0);
|
||||
}
|
||||
|
||||
int
|
||||
ii_input(int no, int len, char *buf)
|
||||
{
|
||||
int error = 0;
|
||||
struct mbuf *m;
|
||||
struct ifnet *ifp = &(ii_if[no]);
|
||||
int s;
|
||||
|
||||
s = splhigh();
|
||||
MGETHDR(m, M_DONTWAIT, MT_DATA);
|
||||
if (m == 0)
|
||||
{
|
||||
splx(s);
|
||||
return (0);
|
||||
}
|
||||
|
||||
if (len >= MHLEN)
|
||||
{
|
||||
MCLGET(m, M_DONTWAIT);
|
||||
if ((m->m_flags & M_EXT) == 0)
|
||||
{
|
||||
(void) m_free(m);
|
||||
splx(s);
|
||||
return (0);
|
||||
}
|
||||
}
|
||||
bcopy((caddr_t) buf, mtod(m, caddr_t), len);
|
||||
m->m_pkthdr.rcvif = ifp;
|
||||
m->m_pkthdr.len = len;
|
||||
m->m_len = len;
|
||||
|
||||
if (IF_QFULL(&ipintrq))
|
||||
{
|
||||
IF_DROP(&ipintrq);
|
||||
ifp->if_ierrors++;
|
||||
m_freem(m);
|
||||
splx(s);
|
||||
return(0);
|
||||
}
|
||||
IF_ENQUEUE(&ipintrq, m);
|
||||
ifp->if_ipackets++;
|
||||
schednetisr(NETISR_IP);
|
||||
splx(s);
|
||||
return(len);
|
||||
}
|
||||
|
||||
int
|
||||
ii_connect(int no)
|
||||
{
|
||||
struct ifnet *ifp = &ii_if[no];
|
||||
ifp->if_flags |= IFF_RUNNING;
|
||||
}
|
||||
|
||||
int
|
||||
ii_disconnect(int no)
|
||||
{
|
||||
struct ifnet *ifp = &ii_if[no];
|
||||
ifp->if_flags &= ~IFF_RUNNING;
|
||||
}
|
||||
|
||||
int
|
||||
ii_out(int no, char *buf, int len)
|
||||
{
|
||||
struct ifnet *ifp = &ii_if[no];
|
||||
struct mbuf *m0, *m;
|
||||
int l;
|
||||
|
||||
IF_DEQUEUE(&ifp->if_snd, m);
|
||||
if (m == 0)
|
||||
{
|
||||
return (0);
|
||||
}
|
||||
/*
|
||||
* Copy the mbuf chain into the transmit buf
|
||||
*/
|
||||
l = 0;
|
||||
for (m0 = m; m != 0; m = m->m_next)
|
||||
{
|
||||
if((l+= m->m_len) > len)
|
||||
{
|
||||
m_freem(m0);
|
||||
return(0);
|
||||
}
|
||||
bcopy(mtod(m, caddr_t), buf, m->m_len);
|
||||
buf += m->m_len;
|
||||
}
|
||||
m_freem(m0);
|
||||
|
||||
return (l);
|
||||
}
|
||||
|
||||
/*
|
||||
* Process an ioctl request.
|
||||
*/
|
||||
int
|
||||
ii_ioctl(ifp, cmd, data)
|
||||
register struct ifnet *ifp;
|
||||
int cmd;
|
||||
caddr_t data;
|
||||
{
|
||||
struct ifaddr *ifa = (struct ifaddr *) data;
|
||||
struct ifreq *ifr = (struct ifreq *) data;
|
||||
int s;
|
||||
|
||||
switch (cmd)
|
||||
{
|
||||
case SIOCSIFDSTADDR:
|
||||
case SIOCAIFADDR:
|
||||
case SIOCSIFADDR:
|
||||
if (ifa->ifa_addr->sa_family != AF_INET)
|
||||
return(EAFNOSUPPORT);
|
||||
ifp->if_flags |= IFF_UP;
|
||||
/* FALLTHROUGH */
|
||||
case SIOCSIFFLAGS:
|
||||
s= splhigh();
|
||||
if((!(ifp->if_flags & IFF_UP)) && (ifp->if_flags & IFF_RUNNING))
|
||||
{
|
||||
isdn_disconnect(applnr[ifp->if_unit],0);
|
||||
ifp->if_flags &= ~IFF_RUNNING;
|
||||
}
|
||||
break;
|
||||
case SIOCSIFMTU:
|
||||
ifr->ifr_metric = ifp->if_mtu;
|
||||
break;
|
||||
case SIOCGIFMTU:
|
||||
if(ifr->ifr_metric < 2048)
|
||||
return(EAFNOSUPPORT);
|
||||
ifp->if_mtu = ifr->ifr_metric;
|
||||
break;
|
||||
default:
|
||||
printf("IIO %x",cmd);
|
||||
return(EINVAL);
|
||||
}
|
||||
return(0);
|
||||
}
|
171
sys/gnu/isdn/iispy.c
Normal file
171
sys/gnu/isdn/iispy.c
Normal file
@ -0,0 +1,171 @@
|
||||
static char _ispyid[] = "@(#)$Id: iispy.c,v 1.1 1995/01/25 14:06:18 jkr Exp jkr $";
|
||||
/*******************************************************************************
|
||||
* II - Version 0.1 $Revision: 1.1 $ $State: Exp $
|
||||
*
|
||||
* Copyright 1994 Dietmar Friede
|
||||
*******************************************************************************
|
||||
* Bug reports, patches, comments, suggestions should be sent to:
|
||||
*
|
||||
* jkr@saarlink.de or jkrause@guug.de
|
||||
*
|
||||
*******************************************************************************
|
||||
* $Log: iispy.c,v $
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
#include "ispy.h"
|
||||
#if NISPY > 0
|
||||
|
||||
#include "param.h"
|
||||
#include "buf.h"
|
||||
#include "systm.h"
|
||||
#include "ioctl.h"
|
||||
#include "tty.h"
|
||||
#include "proc.h"
|
||||
#include "user.h"
|
||||
#include "uio.h"
|
||||
#include "kernel.h"
|
||||
/*#include "malloc.h"*/
|
||||
|
||||
#include "isdn/isdn_ioctl.h"
|
||||
|
||||
int ispyattach();
|
||||
|
||||
int nispy = NISPY;
|
||||
int ispy_applnr;
|
||||
static int next_if =0;
|
||||
static unsigned long ispy_cnt, ispy_out;
|
||||
static char dir;
|
||||
#define ISPY_SIZE 260
|
||||
#define OPEN 1
|
||||
#define READ_WAIT 2
|
||||
#define ISPYBUF 16
|
||||
#define ISPYMASK (ISPYBUF-1)
|
||||
/* ISPYBUF has to be a power of 2 */
|
||||
|
||||
static
|
||||
struct ispy_data
|
||||
{
|
||||
struct ispy_buf
|
||||
{
|
||||
unsigned long cnt;
|
||||
struct timeval stamp;
|
||||
char ibuf[ISPY_SIZE];
|
||||
unsigned char dir;
|
||||
int ilen;
|
||||
} b[ISPYBUF];
|
||||
int state;
|
||||
} ispy_data[NISPY];
|
||||
|
||||
int
|
||||
ispyattach(int ap)
|
||||
{
|
||||
struct ispy_data *ispy;
|
||||
if(next_if >= NISPY)
|
||||
return(-1);
|
||||
ispy= &ispy_data[next_if];
|
||||
ispy->state= 0;
|
||||
ispy_applnr= ap;
|
||||
return(next_if++);
|
||||
}
|
||||
|
||||
int
|
||||
ispy_input(int no, int len, char *buf, int out)
|
||||
{
|
||||
struct ispy_data *ispy= &ispy_data[no];
|
||||
struct ispy_buf *b= &ispy->b[ispy_cnt&ISPYMASK];
|
||||
|
||||
if(len > ISPY_SIZE)
|
||||
return(0);
|
||||
if(len)
|
||||
{
|
||||
b->cnt= ispy_cnt++;
|
||||
b->stamp= time;
|
||||
b->dir= out;
|
||||
bcopy(buf, b->ibuf, len);
|
||||
}
|
||||
b->ilen= len;
|
||||
if(ispy->state & READ_WAIT)
|
||||
{
|
||||
ispy->state &= ~READ_WAIT;
|
||||
wakeup((caddr_t) &ispy->state);
|
||||
}
|
||||
return(len);
|
||||
}
|
||||
|
||||
int
|
||||
ispyopen(dev_t dev, int flag)
|
||||
{
|
||||
int err;
|
||||
struct ispy_data *ispy;
|
||||
|
||||
if (minor(dev)>NISPY)
|
||||
return (ENXIO);
|
||||
|
||||
ispy= &ispy_data[minor(dev)];
|
||||
|
||||
if(ispy->state&OPEN) return(EBUSY);
|
||||
ispy->state |= OPEN;
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
int
|
||||
ispyclose(dev_t dev, int flag)
|
||||
{
|
||||
struct ispy_data *ispy= &ispy_data[minor(dev)];
|
||||
|
||||
if(ispy->state & READ_WAIT)
|
||||
wakeup((caddr_t) &ispy->state);
|
||||
ispy->state = 0;
|
||||
return (0);
|
||||
}
|
||||
|
||||
int
|
||||
ispyioctl (dev, cmd, data, flag)
|
||||
dev_t dev;
|
||||
caddr_t data;
|
||||
int cmd, flag;
|
||||
{
|
||||
int unit = minor(dev);
|
||||
|
||||
switch (cmd) {
|
||||
default:
|
||||
return (ENOTTY);
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
|
||||
int
|
||||
ispyread(dev_t dev, struct uio * uio)
|
||||
{
|
||||
int x;
|
||||
int error = 0;
|
||||
struct ispy_data *ispy= &ispy_data[minor(dev)];
|
||||
struct ispy_buf *b;
|
||||
|
||||
if((ispy_cnt-ispy_out) > ISPYBUF)
|
||||
ispy_out= ispy_cnt - ISPYBUF;
|
||||
b= &ispy->b[ispy_out&ISPYMASK];
|
||||
ispy_out++;
|
||||
while(b->ilen == 0)
|
||||
{
|
||||
ispy->state |= READ_WAIT;
|
||||
if(error= tsleep((caddr_t) &ispy->state, TTIPRI | PCATCH, "ispy", 0 ))
|
||||
return(error);
|
||||
}
|
||||
|
||||
x = splhigh();
|
||||
if(b->ilen)
|
||||
{
|
||||
error = uiomove((char *) &b->dir, 1, uio);
|
||||
if(error == 0)
|
||||
error = uiomove((char *) &b->cnt
|
||||
,sizeof(unsigned long)+sizeof(struct timeval)+b->ilen, uio);
|
||||
b->ilen= 0;
|
||||
}
|
||||
splx(x);
|
||||
return error;
|
||||
}
|
||||
|
||||
#endif
|
234
sys/gnu/isdn/iitel.c
Normal file
234
sys/gnu/isdn/iitel.c
Normal file
@ -0,0 +1,234 @@
|
||||
static char _itelid[] = "@(#)$Id: iitel.c,v 1.1 1995/01/25 14:06:18 jkr Exp jkr $";
|
||||
/*******************************************************************************
|
||||
* II - Version 0.1 $Revision: 1.1 $ $State: Exp $
|
||||
*
|
||||
* Copyright 1994 Dietmar Friede
|
||||
*******************************************************************************
|
||||
* Bug reports, patches, comments, suggestions should be sent to:
|
||||
*
|
||||
* jkr@saarlink.de or jkrause@guug.de
|
||||
*
|
||||
*******************************************************************************
|
||||
* $Log: iitel.c,v $
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
#include "itel.h"
|
||||
#if NITEL > 0
|
||||
|
||||
#include "param.h"
|
||||
#include "buf.h"
|
||||
#include "systm.h"
|
||||
#include "ioctl.h"
|
||||
#include "tty.h"
|
||||
#include "proc.h"
|
||||
#include "user.h"
|
||||
#include "uio.h"
|
||||
#include "kernel.h"
|
||||
#include "malloc.h"
|
||||
|
||||
#include "isdn/isdn_ioctl.h"
|
||||
|
||||
int itelattach();
|
||||
|
||||
int nitel = NITEL;
|
||||
static int applnr[NITEL];
|
||||
static int next_if =0;
|
||||
#define ITEL_SIZE 1024
|
||||
#define OPEN 1
|
||||
#define CONNECT 2
|
||||
#define READ_WAIT 4
|
||||
#define WRITE_WAIT 8
|
||||
#define min(a,b) ((a)<(b)?(a):(b))
|
||||
|
||||
static
|
||||
struct itel_data
|
||||
{
|
||||
char ibuf[ITEL_SIZE];
|
||||
char obuf[ITEL_SIZE];
|
||||
int state;
|
||||
int ilen, olen;
|
||||
} itel_data[NITEL];
|
||||
|
||||
int
|
||||
itelattach(int ap)
|
||||
{
|
||||
struct itel_data *itel;
|
||||
if(next_if >= NITEL)
|
||||
return(-1);
|
||||
itel= &itel_data[next_if];
|
||||
itel->ilen= itel->olen= 0;
|
||||
itel->state= 0;
|
||||
applnr[next_if]= ap;
|
||||
return(next_if++);
|
||||
}
|
||||
|
||||
int
|
||||
itel_input(int no, int len, char *buf)
|
||||
{
|
||||
struct itel_data *itel= &itel_data[no];
|
||||
|
||||
if(itel->ilen || ( len > ITEL_SIZE))
|
||||
return(0);
|
||||
if(len)
|
||||
bcopy(buf, itel->ibuf, len);
|
||||
itel->ilen= len;
|
||||
if(itel->state & READ_WAIT)
|
||||
{
|
||||
itel->state &= ~READ_WAIT;
|
||||
wakeup((caddr_t) itel->ibuf);
|
||||
}
|
||||
return(len);
|
||||
}
|
||||
|
||||
int
|
||||
itel_out(int no, char *buf, int len)
|
||||
{
|
||||
struct itel_data *itel= &itel_data[no];
|
||||
int l;
|
||||
|
||||
if((itel->state & CONNECT) == 0)
|
||||
return(0);
|
||||
if((l= itel->olen) && (itel->olen <= len))
|
||||
bcopy(itel->obuf, buf, l);
|
||||
|
||||
itel->olen= 0;
|
||||
if(itel->state & WRITE_WAIT)
|
||||
{
|
||||
itel->state &= ~WRITE_WAIT;
|
||||
wakeup((caddr_t) itel->obuf);
|
||||
}
|
||||
return(l);
|
||||
}
|
||||
|
||||
void
|
||||
itel_connect(int no)
|
||||
{
|
||||
itel_data[no].state |= CONNECT;
|
||||
}
|
||||
|
||||
void
|
||||
itel_disconnect(int no)
|
||||
{
|
||||
struct itel_data *itel= &itel_data[no];
|
||||
int s;
|
||||
|
||||
s= itel->state;
|
||||
if(itel->state &= OPEN)
|
||||
{
|
||||
itel->ilen= itel->olen= 0;
|
||||
if(s & READ_WAIT)
|
||||
wakeup((caddr_t) itel->ibuf);
|
||||
if(s & WRITE_WAIT)
|
||||
wakeup((caddr_t) itel->obuf);
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
itelopen(dev_t dev, int flag)
|
||||
{
|
||||
int err;
|
||||
struct itel_data *itel;
|
||||
|
||||
if (minor(dev)>NITEL)
|
||||
return (ENXIO);
|
||||
|
||||
itel= &itel_data[minor(dev)];
|
||||
if((itel->state & CONNECT) == 0)
|
||||
return(EIO);
|
||||
|
||||
if(itel->state&OPEN) return(0);
|
||||
itel->ilen= itel->olen= 0;
|
||||
itel->state |= OPEN;
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
int
|
||||
itelclose(dev_t dev, int flag)
|
||||
{
|
||||
struct itel_data *itel= &itel_data[minor(dev)];
|
||||
|
||||
if(itel->state & READ_WAIT)
|
||||
wakeup((caddr_t) itel->ibuf);
|
||||
if(itel->state & WRITE_WAIT)
|
||||
wakeup((caddr_t) itel->obuf);
|
||||
itel_data[minor(dev)].state &= CONNECT;
|
||||
return (0);
|
||||
}
|
||||
|
||||
int
|
||||
itelioctl (dev, cmd, data, flag)
|
||||
dev_t dev;
|
||||
caddr_t data;
|
||||
int cmd, flag;
|
||||
{
|
||||
int unit = minor(dev);
|
||||
|
||||
switch (cmd) {
|
||||
default:
|
||||
return (ENOTTY);
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
|
||||
int
|
||||
itelread(dev_t dev, struct uio * uio)
|
||||
{
|
||||
int x;
|
||||
int error = 0;
|
||||
struct itel_data *itel= &itel_data[minor(dev)];
|
||||
|
||||
if((itel->state & CONNECT) == 0)
|
||||
return(EIO);
|
||||
|
||||
while((itel->ilen == 0) && (itel->state & CONNECT))
|
||||
{
|
||||
itel->state |= READ_WAIT;
|
||||
sleep((caddr_t) itel->ibuf, PZERO | PCATCH);
|
||||
}
|
||||
|
||||
x = splhigh();
|
||||
if(itel->ilen)
|
||||
{
|
||||
error = uiomove(itel->ibuf, itel->ilen, uio);
|
||||
itel->ilen= 0;
|
||||
} else error= EIO;
|
||||
splx(x);
|
||||
return error;
|
||||
}
|
||||
|
||||
int
|
||||
itelwrite(dev_t dev, struct uio * uio)
|
||||
{
|
||||
int x;
|
||||
int error = 0;
|
||||
struct itel_data *itel= &itel_data[minor(dev)];
|
||||
|
||||
if((itel->state & CONNECT) == 0)
|
||||
return(EIO);
|
||||
|
||||
while(itel->olen && (itel->state & CONNECT))
|
||||
{
|
||||
itel->state |= WRITE_WAIT;
|
||||
sleep((caddr_t) itel->obuf, PZERO | PCATCH);
|
||||
}
|
||||
|
||||
x = splhigh();
|
||||
if((itel->state & CONNECT) == 0)
|
||||
{
|
||||
splx(x);
|
||||
return(0);
|
||||
}
|
||||
|
||||
if(itel->olen == 0)
|
||||
{
|
||||
itel->olen= min(ITEL_SIZE, uio->uio_resid);
|
||||
error = uiomove(itel->obuf, itel->olen, uio);
|
||||
isdn_output(applnr[minor(dev)]);
|
||||
}
|
||||
splx(x);
|
||||
return error;
|
||||
}
|
||||
|
||||
#endif
|
306
sys/gnu/isdn/iitty.c
Normal file
306
sys/gnu/isdn/iitty.c
Normal file
@ -0,0 +1,306 @@
|
||||
static char _ittyid[] = "@(#)$Id: iitty.c,v 1.1 1995/01/25 14:06:18 jkr Exp jkr $";
|
||||
/*******************************************************************************
|
||||
* II - Version 0.1 $Revision: 1.1 $ $State: Exp $
|
||||
*
|
||||
* Copyright 1994 Dietmar Friede
|
||||
*******************************************************************************
|
||||
* Bug reports, patches, comments, suggestions should be sent to:
|
||||
*
|
||||
* jkr@saarlink.de or jkrause@guug.de
|
||||
*
|
||||
*******************************************************************************
|
||||
* $Log: iitty.c,v $
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
#include "ity.h"
|
||||
#if NITY > 0
|
||||
|
||||
#include "param.h"
|
||||
#include "systm.h"
|
||||
#include "ioctl.h"
|
||||
#include "select.h"
|
||||
#include "tty.h"
|
||||
#include "proc.h"
|
||||
#include "user.h"
|
||||
#include "conf.h"
|
||||
#include "file.h"
|
||||
#include "uio.h"
|
||||
#include "kernel.h"
|
||||
#include "syslog.h"
|
||||
#include "types.h"
|
||||
|
||||
#include "isdn/isdn_ioctl.h"
|
||||
|
||||
int ityattach(), itystart(), ityparam();
|
||||
|
||||
int nity = NITY;
|
||||
int itydefaultrate = 64000;
|
||||
short ity_addr[NITY];
|
||||
struct tty ity_tty[NITY];
|
||||
static int applnr[NITY];
|
||||
static int next_if= 0;
|
||||
|
||||
#define UNIT(x) (minor(x)&0x3f)
|
||||
#define OUTBOUND(x) ((minor(x)&0x80)==0x80)
|
||||
|
||||
int
|
||||
ityattach(int ap)
|
||||
{
|
||||
if(next_if >= NITY)
|
||||
return(-1);
|
||||
|
||||
applnr[next_if]= ap;
|
||||
return(next_if++);
|
||||
}
|
||||
|
||||
/* ARGSUSED */
|
||||
ityopen(dev_t dev, int flag, int mode, struct proc * p)
|
||||
{
|
||||
register struct tty *tp;
|
||||
register int unit;
|
||||
int error = 0;
|
||||
|
||||
unit = UNIT(dev);
|
||||
if (unit >= next_if)
|
||||
return (ENXIO);
|
||||
|
||||
tp = &ity_tty[unit];
|
||||
tp->t_oproc = itystart;
|
||||
tp->t_param = ityparam;
|
||||
tp->t_dev = dev;
|
||||
if ((tp->t_state & TS_ISOPEN) == 0)
|
||||
{
|
||||
tp->t_state |= TS_WOPEN;
|
||||
ttychars(tp);
|
||||
if (tp->t_ispeed == 0)
|
||||
{
|
||||
tp->t_iflag = TTYDEF_IFLAG;
|
||||
tp->t_oflag = TTYDEF_OFLAG;
|
||||
tp->t_cflag = TTYDEF_CFLAG;
|
||||
tp->t_lflag = TTYDEF_LFLAG;
|
||||
tp->t_ispeed = tp->t_ospeed = itydefaultrate;
|
||||
}
|
||||
ityparam(tp, &tp->t_termios);
|
||||
ttsetwater(tp);
|
||||
} else if (tp->t_state & TS_XCLUDE && p->p_ucred->cr_uid != 0)
|
||||
return (EBUSY);
|
||||
(void) spltty();
|
||||
|
||||
if(OUTBOUND(dev)) tp->t_cflag |= CLOCAL;
|
||||
|
||||
while ((flag & O_NONBLOCK) == 0 && (tp->t_cflag & CLOCAL) == 0 &&
|
||||
(tp->t_state & TS_CARR_ON) == 0)
|
||||
{
|
||||
tp->t_state |= TS_WOPEN;
|
||||
if (error = ttysleep(tp, (caddr_t) & tp->t_rawq, TTIPRI | PCATCH,
|
||||
ttopen, 0))
|
||||
break;
|
||||
}
|
||||
(void) spl0();
|
||||
if (error == 0)
|
||||
error = (*linesw[tp->t_line].l_open) (dev, tp);
|
||||
return (error);
|
||||
}
|
||||
|
||||
/* ARGSUSED */
|
||||
ityclose(dev, flag, mode, p)
|
||||
dev_t dev;
|
||||
int flag, mode;
|
||||
struct proc *p;
|
||||
{
|
||||
register struct tty *tp;
|
||||
register ity;
|
||||
register int unit;
|
||||
|
||||
unit = UNIT(dev);
|
||||
ity = ity_addr[unit];
|
||||
if(tp = &ity_tty[unit])
|
||||
(*linesw[tp->t_line].l_close) (tp, flag);
|
||||
ttyclose(tp);
|
||||
isdn_disconnect(applnr[unit],0);
|
||||
return (0);
|
||||
}
|
||||
|
||||
ityread(dev, uio, flag)
|
||||
dev_t dev;
|
||||
struct uio *uio;
|
||||
{
|
||||
register struct tty *tp = &ity_tty[UNIT(dev)];
|
||||
|
||||
return ((*linesw[tp->t_line].l_read) (tp, uio, flag));
|
||||
}
|
||||
|
||||
itywrite(dev, uio, flag)
|
||||
dev_t dev;
|
||||
struct uio *uio;
|
||||
{
|
||||
int unit = UNIT(dev);
|
||||
register struct tty *tp = &ity_tty[unit];
|
||||
|
||||
return ((*linesw[tp->t_line].l_write) (tp, uio, flag));
|
||||
}
|
||||
|
||||
ity_input(int no, int len, char *buf)
|
||||
{
|
||||
register struct tty *tp = &ity_tty[no];
|
||||
int i;
|
||||
|
||||
if (tp->t_state & TS_ISOPEN)
|
||||
for(i= 0; i<len; i++)
|
||||
(*linesw[tp->t_line].l_rint)(buf[i], tp);
|
||||
else len= 0;
|
||||
return(len);
|
||||
}
|
||||
|
||||
itystart(struct tty *tp)
|
||||
{
|
||||
int s, unit;
|
||||
|
||||
unit = UNIT(tp->t_dev);
|
||||
|
||||
s = splhigh();
|
||||
if (tp->t_state & (TS_TIMEOUT | TS_TTSTOP))
|
||||
{
|
||||
splx(s);
|
||||
return;
|
||||
}
|
||||
if (tp->t_outq.c_cc <= tp->t_lowat)
|
||||
{
|
||||
if (tp->t_state & TS_ASLEEP)
|
||||
{
|
||||
tp->t_state &= ~TS_ASLEEP;
|
||||
wakeup((caddr_t) & tp->t_outq);
|
||||
}
|
||||
selwakeup(&tp->t_wsel);
|
||||
}
|
||||
if (tp->t_outq.c_cc)
|
||||
{
|
||||
if(OUTBOUND(tp->t_dev) && (tp->t_cflag & CLOCAL) &&
|
||||
((tp->t_state & TS_CARR_ON) == 0))
|
||||
isdn_msg(applnr[unit]);
|
||||
else isdn_output(applnr[unit]);
|
||||
tp->t_state |= TS_BUSY;
|
||||
}
|
||||
splx(s);
|
||||
}
|
||||
|
||||
ity_out(int no, char *buf, int len)
|
||||
{
|
||||
struct tty *tp = &ity_tty[no];
|
||||
int i;
|
||||
|
||||
if(tp == NULL)
|
||||
return(0);
|
||||
if(tp->t_outq.c_cc)
|
||||
{
|
||||
for (i = 0; i < len && tp->t_outq.c_cc; ++i)
|
||||
buf[i]= getc(&tp->t_outq);
|
||||
return(i);
|
||||
}
|
||||
tp->t_state &=~ (TS_BUSY|TS_FLUSH);
|
||||
if (tp->t_line)
|
||||
(*linesw[tp->t_line].l_start)(tp);
|
||||
else
|
||||
itystart(tp);
|
||||
return(0);
|
||||
}
|
||||
|
||||
ity_connect(int no)
|
||||
{
|
||||
struct tty *tp = &ity_tty[no];
|
||||
|
||||
if(tp == NULL)
|
||||
return;
|
||||
if(OUTBOUND(tp->t_dev)) tp->t_cflag &= ~CLOCAL;
|
||||
(*linesw[tp->t_line].l_modem) (tp, 1);
|
||||
tp->t_state |= TS_CARR_ON;
|
||||
tp->t_state &=~ (TS_BUSY|TS_FLUSH);
|
||||
if (tp->t_line)
|
||||
(*linesw[tp->t_line].l_start)(tp);
|
||||
else
|
||||
itystart(tp);
|
||||
}
|
||||
|
||||
ity_disconnect(int no)
|
||||
{
|
||||
struct tty *tp = &ity_tty[no];
|
||||
if(tp) (*linesw[tp->t_line].l_modem) (tp, 0);
|
||||
}
|
||||
|
||||
ityioctl(dev, cmd, data, flag,p)
|
||||
dev_t dev;
|
||||
int cmd;
|
||||
caddr_t data;
|
||||
int flag;
|
||||
struct proc *p;
|
||||
{
|
||||
register struct tty *tp;
|
||||
register int unit = UNIT(dev);
|
||||
register int error;
|
||||
|
||||
tp = &ity_tty[unit];
|
||||
error = (*linesw[tp->t_line].l_ioctl) (tp, cmd, data, flag,p);
|
||||
if (error >= 0)
|
||||
return (error);
|
||||
error = ttioctl(tp, cmd, data, flag);
|
||||
if (error >= 0)
|
||||
return (error);
|
||||
|
||||
switch (cmd)
|
||||
{
|
||||
default:
|
||||
return (ENOTTY);
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
|
||||
ityparam(tp, t)
|
||||
register struct tty *tp;
|
||||
register struct termios *t;
|
||||
{
|
||||
register ity;
|
||||
register int cfcr, cflag = t->c_cflag;
|
||||
int unit = UNIT(tp->t_dev);
|
||||
int ospeed = t->c_ospeed;
|
||||
|
||||
/* check requested parameters */
|
||||
if (ospeed < 0 || (t->c_ispeed && t->c_ispeed != t->c_ospeed))
|
||||
return (EINVAL);
|
||||
/* and copy to tty */
|
||||
tp->t_ispeed = t->c_ispeed;
|
||||
tp->t_ospeed = t->c_ospeed;
|
||||
tp->t_cflag = cflag;
|
||||
|
||||
if (ospeed == 0)
|
||||
{
|
||||
isdn_disconnect(applnr[unit],0);
|
||||
return (0);
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*
|
||||
* Stop output on a line.
|
||||
*/
|
||||
/* ARGSUSED */
|
||||
itystop(struct tty *tp, int flag)
|
||||
{
|
||||
register int s;
|
||||
|
||||
s = splhigh();
|
||||
if (tp->t_state & TS_BUSY)
|
||||
{
|
||||
if ((tp->t_state & TS_TTSTOP) == 0)
|
||||
tp->t_state |= TS_FLUSH;
|
||||
}
|
||||
splx(s);
|
||||
}
|
||||
|
||||
int
|
||||
ityselect(dev_t dev, int rw, struct proc *p)
|
||||
{
|
||||
return (ttselect(dev, rw, p));
|
||||
}
|
||||
|
||||
#endif
|
626
sys/gnu/isdn/isdn.c
Normal file
626
sys/gnu/isdn/isdn.c
Normal file
@ -0,0 +1,626 @@
|
||||
static char _isdnid[] = "@(#)$Id: isdn.c,v 1.1 1995/01/25 14:06:18 jkr Exp jkr $";
|
||||
/*******************************************************************************
|
||||
* II - Version 0.1 $Revision: 1.1 $ $State: Exp $
|
||||
*
|
||||
* Copyright 1994 Dietmar Friede
|
||||
*******************************************************************************
|
||||
* Bug reports, patches, comments, suggestions should be sent to:
|
||||
*
|
||||
* jkr@saarlink.de or jkrause@guug.de
|
||||
*
|
||||
*******************************************************************************
|
||||
* $Log: isdn.c,v $
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
/*
|
||||
* Copyright (c) 1994 Dietmar Friede (dietmar@friede.de) All rights reserved.
|
||||
* FSF/FSAG GNU Copyright applies
|
||||
*
|
||||
* An intermediate level for ISDN Drivers.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "isdn.h"
|
||||
#include "ii.h"
|
||||
#include "ity.h"
|
||||
#include "itel.h"
|
||||
#include "ispy.h"
|
||||
#if NISDN > 0
|
||||
|
||||
#define TYPNR 4
|
||||
#define N_ISDN_APPL (NII + NITY + NITEL + NISPY)
|
||||
|
||||
#include "param.h"
|
||||
#include "ioctl.h"
|
||||
#include "kernel.h"
|
||||
#include "systm.h"
|
||||
|
||||
#include "isdn/isdn_ioctl.h"
|
||||
|
||||
isdn_appl_t isdn_appl[N_ISDN_APPL];
|
||||
isdn_ctrl_t isdn_ctrl[N_ISDN_CTRL];
|
||||
int Isdn_Appl, Isdn_Ctrl, Isdn_Typ;
|
||||
|
||||
int isdn_input(), isdn_output();
|
||||
int ii_input(), ii_out(), ii_connect(), ii_disconnect();
|
||||
int ity_input(), ity_out(), ity_connect(), ity_disconnect();
|
||||
int itel_input(), itel_out(), itel_connect(), itel_disconnect();
|
||||
int ispy_input();
|
||||
int isdn_stat();
|
||||
|
||||
void isdn_disconnect();
|
||||
static int o_flags, r_flags, bufind[TYPNR];
|
||||
static char buffer[TYPNR][257];
|
||||
static u_char appl_list[TYPNR];
|
||||
|
||||
typedef u_char prot[2];
|
||||
static u_char prot_size[2] = {0, 2};
|
||||
static prot passiv[6] = {{0}, {3, 3}};
|
||||
static prot activ[6] = {{0}, {1, 3}};
|
||||
static void passout();
|
||||
|
||||
u_short isdn_state= 0;
|
||||
static isdn_timeout= 0;
|
||||
extern int hz;
|
||||
|
||||
int
|
||||
isdn_get_prot_size(int ap)
|
||||
{
|
||||
return (prot_size[isdn_appl[ap].prot]);
|
||||
}
|
||||
|
||||
char *
|
||||
isdn_get_prot(int ap, int dir)
|
||||
{
|
||||
if(dir)
|
||||
return(activ[isdn_appl[ap].prot]);
|
||||
return(passiv[isdn_appl[ap].prot]);
|
||||
}
|
||||
|
||||
int
|
||||
isdn_set_prot(int ap, int dir, char *p)
|
||||
{
|
||||
char *pr;
|
||||
int i, l;
|
||||
if ((l = isdn_get_prot_size(ap)) == 0)
|
||||
return (0);
|
||||
if (dir)
|
||||
pr = passiv[isdn_appl[ap].prot];
|
||||
else
|
||||
pr = activ[isdn_appl[ap].prot];
|
||||
for (i = 0; i < l; i++, pr++, p++)
|
||||
*p = *pr;
|
||||
return (l);
|
||||
}
|
||||
|
||||
void
|
||||
isdn_attach()
|
||||
{
|
||||
isdn_appl_t *appl;
|
||||
int i, an;
|
||||
|
||||
appl_list[0]= Isdn_Typ= an= 0;
|
||||
|
||||
for(i= 0 ; i<NII; i++,an++)
|
||||
{
|
||||
appl = &isdn_appl[an];
|
||||
appl->ctrl = -1;
|
||||
appl->state = 0;
|
||||
appl->appl = an;
|
||||
appl->typ = Isdn_Typ;
|
||||
appl->drivno = iiattach(an);
|
||||
appl->PassUp = ii_input;
|
||||
appl->PassDown = ii_out;
|
||||
appl->Connect = ii_connect;
|
||||
appl->DisConn = ii_disconnect;
|
||||
}
|
||||
|
||||
appl_list[1]= an;
|
||||
Isdn_Typ= 1;
|
||||
for(i= 0 ; i<NITY; i++,an++)
|
||||
{
|
||||
appl = &isdn_appl[an];
|
||||
appl->ctrl = -1;
|
||||
appl->state = 0;
|
||||
appl->appl = an;
|
||||
appl->typ = Isdn_Typ;
|
||||
appl->drivno = ityattach(an);
|
||||
appl->PassUp = ity_input;
|
||||
appl->PassDown = ity_out;
|
||||
appl->Connect = ity_connect;
|
||||
appl->DisConn = ity_disconnect;
|
||||
}
|
||||
|
||||
appl_list[2]= an;
|
||||
Isdn_Typ= 2;
|
||||
for(i= 0 ; i<NITEL; i++,an++)
|
||||
{
|
||||
appl = &isdn_appl[an];
|
||||
appl->ctrl = -1;
|
||||
appl->state = 0;
|
||||
appl->appl = an;
|
||||
appl->typ = Isdn_Typ;
|
||||
appl->drivno = itelattach(an);
|
||||
appl->PassUp = itel_input;
|
||||
appl->PassDown = itel_out;
|
||||
appl->Connect = itel_connect;
|
||||
appl->DisConn = itel_disconnect;
|
||||
}
|
||||
|
||||
appl_list[3]= an;
|
||||
Isdn_Typ= 3;
|
||||
for(i= 0 ; i<NISPY; i++,an++)
|
||||
{
|
||||
appl = &isdn_appl[an];
|
||||
appl->ctrl = -1;
|
||||
appl->state = 0;
|
||||
appl->appl = an;
|
||||
appl->typ = Isdn_Typ;
|
||||
appl->drivno = ispyattach(an);
|
||||
appl->PassUp = ispy_input;
|
||||
}
|
||||
Isdn_Appl= an;
|
||||
}
|
||||
|
||||
int
|
||||
isdn_ctrl_attach(int n)
|
||||
{
|
||||
int c = Isdn_Ctrl;
|
||||
|
||||
if(Isdn_Ctrl == 0) isdn_attach();
|
||||
if ((Isdn_Ctrl += n) <= N_ISDN_CTRL)
|
||||
return (c);
|
||||
Isdn_Ctrl = c;
|
||||
return (-1);
|
||||
}
|
||||
|
||||
/*
|
||||
* isdnopen() New open on device.
|
||||
*
|
||||
* I forbid all but one open per application. The only programs opening the
|
||||
* isdn device are the ISDN-daemon
|
||||
*/
|
||||
int
|
||||
isdnopen(dev_t dev, int flag)
|
||||
{
|
||||
int err;
|
||||
|
||||
if (minor(dev)>Isdn_Typ)
|
||||
return (ENXIO);
|
||||
|
||||
/* Card busy ? */
|
||||
if (o_flags & (1 << minor(dev)))
|
||||
return (EBUSY);
|
||||
|
||||
o_flags |= (1 << minor(dev));
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
int
|
||||
isdnclose(dev_t dev, int flag)
|
||||
{
|
||||
o_flags &= ~(1 << minor(dev));
|
||||
return (0);
|
||||
}
|
||||
|
||||
int
|
||||
isdnread(dev_t dev, struct uio * uio)
|
||||
{
|
||||
int x;
|
||||
int error = 0;
|
||||
int unit= minor(dev);
|
||||
|
||||
r_flags &= ~(1 << unit);
|
||||
|
||||
x = splhigh();
|
||||
if(bufind[unit] == 0)
|
||||
{
|
||||
r_flags |= (1 << unit);
|
||||
error= tsleep((caddr_t) buffer[unit], PZERO + 1, "isdnin", hz);
|
||||
}
|
||||
if(bufind[unit])
|
||||
{
|
||||
buffer[unit][bufind[unit]++]= 0;
|
||||
error = uiomove(buffer[unit], bufind[unit], uio);
|
||||
bufind[unit] = 0;
|
||||
}
|
||||
splx(x);
|
||||
return error;
|
||||
}
|
||||
|
||||
int
|
||||
isdnioctl(dev_t dev, int cmd, caddr_t data, int flag)
|
||||
{
|
||||
int err, x, i;
|
||||
isdn_appl_t *appl;
|
||||
isdn_ctrl_t *ctrl;
|
||||
short *val = (short *) data;
|
||||
unsigned ab, an, cn;
|
||||
|
||||
err = 0;
|
||||
ab= appl_list[minor(dev)];
|
||||
|
||||
switch (cmd)
|
||||
{
|
||||
case ISDN_LISTEN:
|
||||
{
|
||||
listen_t *s= (listen_t *) data;
|
||||
|
||||
an= ab;
|
||||
if (s->ctrl >= Isdn_Ctrl)
|
||||
return (ENODEV);
|
||||
cn= s->ctrl;
|
||||
ctrl = &isdn_ctrl[cn];
|
||||
|
||||
x = splhigh();
|
||||
while(isdn_state)
|
||||
{
|
||||
err = tsleep((caddr_t) ctrl, PZERO | PCATCH, "slisten", 2);
|
||||
if (err != EWOULDBLOCK)
|
||||
{
|
||||
splx(x);
|
||||
return (err);
|
||||
}
|
||||
}
|
||||
|
||||
isdn_state = 0xffff;
|
||||
while((err = (*ctrl->listen) (s->ctrl, minor(dev) | 0x30
|
||||
, s->inf_mask ,s->subadr_mask ,s->si_mask)) == EBUSY)
|
||||
{
|
||||
err = tsleep((caddr_t) ctrl, PZERO | PCATCH, "blisten", 2);
|
||||
if (err != EWOULDBLOCK)
|
||||
{
|
||||
splx(x);
|
||||
return (err);
|
||||
}
|
||||
}
|
||||
|
||||
if (err)
|
||||
{
|
||||
splx(x);
|
||||
return (err);
|
||||
}
|
||||
while (isdn_state == 0xffff)
|
||||
{
|
||||
err = tsleep((caddr_t) ctrl, PZERO | PCATCH, "ilisten", 2);
|
||||
if (err != EWOULDBLOCK)
|
||||
{
|
||||
splx(x);
|
||||
return (err);
|
||||
}
|
||||
}
|
||||
splx(x);
|
||||
err= isdn_state;
|
||||
isdn_state= 0;
|
||||
return (err); /* tricky but it works */
|
||||
}
|
||||
break;
|
||||
|
||||
case ISDN_DIAL:
|
||||
{
|
||||
dial_t *d= (dial_t*)data;
|
||||
telno_t *t= &d->telno;
|
||||
|
||||
an = d->appl + ab;
|
||||
cn = d->ctrl;
|
||||
|
||||
if (an >= Isdn_Appl || cn >= Isdn_Ctrl)
|
||||
return (ENODEV);
|
||||
|
||||
appl = &isdn_appl[an];
|
||||
|
||||
if (ISBUSY(appl->ctrl) || appl->state)
|
||||
return (EBUSY);
|
||||
|
||||
appl->state= 1;
|
||||
x = splhigh();
|
||||
|
||||
while((err = (*isdn_ctrl[cn].connect) (cn, an
|
||||
,d->b_channel, d->inf_mask, d->out_serv
|
||||
,d->out_serv_add, d->src_subadr, t->length
|
||||
,t->no, d->spv)) == EBUSY)
|
||||
{
|
||||
err = tsleep((caddr_t) appl, PZERO | PCATCH, "idial", 2);
|
||||
if (err != EWOULDBLOCK)
|
||||
{
|
||||
splx(x);
|
||||
return (err);
|
||||
}
|
||||
}
|
||||
if(err) appl->state= 0;
|
||||
splx(x);
|
||||
return(err);
|
||||
}
|
||||
break;
|
||||
case ISDN_HANGUP:
|
||||
cn = data[0];
|
||||
if (cn >= Isdn_Ctrl)
|
||||
return (ENODEV);
|
||||
x = splhigh();
|
||||
|
||||
while((err = (*isdn_ctrl[cn].disconnect) (cn, data[1])) == EBUSY)
|
||||
{
|
||||
err = tsleep((caddr_t) data, PZERO | PCATCH, "ihang", 2);
|
||||
if (err != EWOULDBLOCK)
|
||||
{
|
||||
splx(x);
|
||||
return (err);
|
||||
}
|
||||
}
|
||||
splx(x);
|
||||
break;
|
||||
case ISDN_ACCEPT:
|
||||
cn = data[0];
|
||||
an = data[1] + ab;
|
||||
if (cn >= Isdn_Ctrl)
|
||||
return (ENODEV);
|
||||
x = splhigh();
|
||||
while((err = (*isdn_ctrl[cn].accept) (cn, an, data[2])) == EBUSY)
|
||||
{
|
||||
err = tsleep((caddr_t) data, PZERO | PCATCH, "iaccept", 2);
|
||||
if (err != EWOULDBLOCK)
|
||||
{
|
||||
splx(x);
|
||||
return (err);
|
||||
}
|
||||
}
|
||||
splx(x);
|
||||
break;
|
||||
case ISDN_SET_PARAM:
|
||||
{
|
||||
isdn_param *p = (isdn_param *) data;
|
||||
|
||||
an = p->appl + ab;
|
||||
if (an >= Isdn_Appl)
|
||||
return (ENODEV);
|
||||
appl = &isdn_appl[an];
|
||||
bcopy(p, appl, sizeof(isdn_param));
|
||||
appl->appl+= ab;
|
||||
}
|
||||
break;
|
||||
case ISDN_GET_PARAM:
|
||||
{
|
||||
isdn_param *p = (isdn_param *) data;
|
||||
an = p->appl + ab;
|
||||
if (an >= Isdn_Appl)
|
||||
return (ENODEV);
|
||||
appl = &isdn_appl[an];
|
||||
bcopy(appl, p, sizeof(isdn_param));
|
||||
}
|
||||
break;
|
||||
default:
|
||||
err = ENODEV;
|
||||
}
|
||||
|
||||
return (err);
|
||||
}
|
||||
|
||||
void
|
||||
isdn_start_out(int cn)
|
||||
{
|
||||
isdn_ctrl_t *ctrl = &isdn_ctrl[cn];
|
||||
isdn_appl_t *appl = &isdn_appl[ctrl->appl];
|
||||
int x;
|
||||
|
||||
x= splhigh();
|
||||
if (ctrl->o_len == 0)
|
||||
{
|
||||
int l;
|
||||
l = isdn_set_prot(ctrl->appl, ctrl->islisten, ctrl->o_buf);
|
||||
ctrl->o_len = (*appl->PassDown) (appl->drivno, ctrl->o_buf+l,2048-l);
|
||||
|
||||
if (ctrl->o_len == 0)
|
||||
{
|
||||
splx(x);
|
||||
return;
|
||||
}
|
||||
ctrl->o_len+= l;
|
||||
(*ctrl->output) (cn);
|
||||
}
|
||||
|
||||
splx(x);
|
||||
}
|
||||
|
||||
int
|
||||
isdn_stat(int cn)
|
||||
{
|
||||
isdn_ctrl_t *ctrl = &isdn_ctrl[cn];
|
||||
return((*ctrl->state) (cn));
|
||||
}
|
||||
|
||||
int
|
||||
isdn_output(int an)
|
||||
{
|
||||
isdn_appl_t *appl = &isdn_appl[an];
|
||||
|
||||
if (ISFREE(appl->ctrl))
|
||||
{
|
||||
int l;
|
||||
char buf[10];
|
||||
|
||||
if(appl->state)
|
||||
return(0);
|
||||
|
||||
l = sprintf(buf,"d %d", an-appl_list[appl->typ]);
|
||||
passout(appl->typ,l,buf);
|
||||
return(0);
|
||||
}
|
||||
isdn_start_out(appl->ctrl);
|
||||
return (0);
|
||||
}
|
||||
|
||||
int
|
||||
isdn_msg(int an)
|
||||
{
|
||||
isdn_appl_t *appl = &isdn_appl[an];
|
||||
|
||||
if (ISFREE(appl->ctrl))
|
||||
{
|
||||
int l;
|
||||
char buf[256];
|
||||
|
||||
l = sprintf(buf,"M %d", an-appl_list[appl->typ]);
|
||||
l += (*appl->PassDown) (appl->drivno, buf+l,256-l);
|
||||
passout(appl->typ,l,buf);
|
||||
return(0);
|
||||
}
|
||||
return (1);
|
||||
}
|
||||
|
||||
int
|
||||
isdn_input(int an, int len, char *buf, int dir)
|
||||
{
|
||||
int l;
|
||||
char *p;
|
||||
isdn_appl_t *appl = &isdn_appl[an];
|
||||
|
||||
if (l = isdn_get_prot_size(an))
|
||||
{
|
||||
p= isdn_get_prot(an,dir);
|
||||
if((p[0] != buf[0]) || (p[1] != buf[1]))
|
||||
return(0);
|
||||
len -= l;
|
||||
buf += l;
|
||||
}
|
||||
return ((*appl->PassUp) (appl->drivno, len, buf, dir));
|
||||
}
|
||||
|
||||
void
|
||||
isdn_accept_con_ind(int an, int cn, char serv, char serv_add, char subadr, char nl, char *num)
|
||||
{
|
||||
int l;
|
||||
char buf[32];
|
||||
|
||||
an&= 0xf;
|
||||
l = sprintf(buf, "a %d %d %d %d %c %d %d %s", an, cn ,serv, serv_add
|
||||
, subadr,(u_char) num[0], nl, num + 1);
|
||||
passout(an,l,buf);
|
||||
}
|
||||
|
||||
void
|
||||
isdn_info(int an, int typ, int len, char *data)
|
||||
{
|
||||
int l;
|
||||
char buf[64];
|
||||
u_short no;
|
||||
|
||||
if(an < Isdn_Appl)
|
||||
no= isdn_appl[an].typ;
|
||||
else no= an&0xf;
|
||||
|
||||
if(no > Isdn_Typ) no= 3;
|
||||
|
||||
if(len>48) len= 48;
|
||||
data[len]= 0;
|
||||
l = sprintf(buf,"i %d %d %d %s", an, typ, len, data);
|
||||
passout(no,l,buf);
|
||||
}
|
||||
|
||||
static void
|
||||
isdn_check()
|
||||
{
|
||||
int i;
|
||||
|
||||
isdn_timeout= 0;
|
||||
for(i= 0; i < Isdn_Ctrl; i++)
|
||||
{
|
||||
int an;
|
||||
isdn_ctrl_t *ctrl = &isdn_ctrl[i];
|
||||
|
||||
if((an= ctrl->appl) < Isdn_Appl)
|
||||
{
|
||||
isdn_appl_t *appl = &isdn_appl[an];
|
||||
|
||||
if(appl->timeout)
|
||||
{
|
||||
isdn_timeout= 1;
|
||||
if(time.tv_sec > (ctrl->lastact + (appl->timeout)))
|
||||
{
|
||||
isdn_disconnect(an,0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(isdn_timeout)
|
||||
{
|
||||
timeout(isdn_check,0,hz/2);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
isdn_conn_ind(int an, int cn, int dial)
|
||||
{
|
||||
isdn_appl_t *appl = &isdn_appl[an];
|
||||
int l;
|
||||
char buf[10];
|
||||
|
||||
if (appl->Connect)
|
||||
(*appl->Connect) (appl->drivno);
|
||||
|
||||
l = sprintf(buf,"C %d %d %d", an-appl_list[appl->typ], cn, dial);
|
||||
passout(appl->typ,l,buf);
|
||||
if((isdn_timeout == 0) && appl->timeout)
|
||||
{
|
||||
isdn_timeout= 1;
|
||||
timeout(isdn_check,0,hz/2);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
isdn_disconn_ind(int an)
|
||||
{
|
||||
isdn_appl_t *appl = &isdn_appl[an];
|
||||
int l;
|
||||
char buf[10];
|
||||
|
||||
if(( an < 0) || (an >= Isdn_Appl))
|
||||
return;
|
||||
|
||||
appl->state= 0;
|
||||
if (appl->DisConn)
|
||||
(*appl->DisConn) (appl->drivno);
|
||||
l = sprintf(buf,"D %d", an-appl_list[appl->typ]);
|
||||
passout(appl->typ,l,buf);
|
||||
}
|
||||
|
||||
void
|
||||
isdn_disconnect(int an, int rea)
|
||||
{
|
||||
isdn_appl_t *appl = &isdn_appl[an];
|
||||
|
||||
if (ISBUSY(appl->ctrl))
|
||||
{
|
||||
int x;
|
||||
x = splhigh();
|
||||
(*isdn_ctrl[appl->ctrl].disconnect)(appl->ctrl,rea);
|
||||
splx(x);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
passout(int unit, int l, char *buf)
|
||||
{
|
||||
int x;
|
||||
|
||||
x = splhigh();
|
||||
if ((bufind[unit] + l) >= 256)
|
||||
{
|
||||
splx(x);
|
||||
return;
|
||||
}
|
||||
bcopy(buf,&buffer[unit][bufind[unit]],l);
|
||||
bufind[unit] += l;
|
||||
buffer[unit][bufind[unit]++]= 0;
|
||||
if (r_flags & (1<<unit))
|
||||
{
|
||||
r_flags &= ~(1 << unit);
|
||||
wakeup((caddr_t) buffer[unit]);
|
||||
}
|
||||
splx(x);
|
||||
}
|
||||
|
||||
#endif /* NISDN > 0 */
|
136
sys/gnu/isdn/isdn_ioctl.h
Normal file
136
sys/gnu/isdn/isdn_ioctl.h
Normal file
@ -0,0 +1,136 @@
|
||||
static char _isdn_ioctl_id[] = "@(#)$Id: isdn_ioctl.h,v 1.1 1995/01/25 14:06:18 jkr Exp jkr $";
|
||||
/*******************************************************************************
|
||||
* II - Version 0.1 $Revision: 1.1 $ $State: Exp $
|
||||
*
|
||||
* Copyright 1994 Dietmar Friede
|
||||
*******************************************************************************
|
||||
* Bug reports, patches, comments, suggestions should be sent to:
|
||||
*
|
||||
* jkr@saarlink.de or jkrause@guug.de
|
||||
*
|
||||
*******************************************************************************
|
||||
* $Log: isdn_ioctl.h,v $
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
|
||||
#pragma pack (1)
|
||||
typedef struct
|
||||
{
|
||||
u_char protokoll;
|
||||
u_char length;
|
||||
u_short data_length;
|
||||
u_char link_addr_a;
|
||||
u_char link_addr_b;
|
||||
u_char modulo_mode;
|
||||
u_char window_size;
|
||||
u_char xid;
|
||||
} dlpd_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
u_char protokoll;
|
||||
u_char length;
|
||||
u_short lic, hic, ltc, htc, loc, hoc;
|
||||
u_char modulo_mode;
|
||||
}ncpd_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
u_char length;
|
||||
u_short lic, hic, ltc, htc, loc, hoc;
|
||||
u_char modulo_mode;
|
||||
}ncpi_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
u_char stat;
|
||||
u_char length;
|
||||
u_char no[124];
|
||||
} telno_t;
|
||||
|
||||
#pragma pack ()
|
||||
|
||||
typedef struct
|
||||
{
|
||||
short appl;
|
||||
dlpd_t dlpd;
|
||||
ncpd_t ncpd;
|
||||
u_long timeout;
|
||||
u_char prot;
|
||||
int (*PassUp)(); /* pass data from isdn interface upstream to appl. */
|
||||
int (*PassUpInfo)(); /* pass info from isdn interface upstream to appl. */
|
||||
int (*PassDown)(); /* get data from application */
|
||||
int (*Connect)(); /* Connect Indikation */
|
||||
int (*DisConn)(); /* Disconnect Indikation */
|
||||
short drivno; /* Number of the high level Driver */
|
||||
char ctrl;
|
||||
char typ;
|
||||
short state;
|
||||
short listen_state;
|
||||
u_long send_err;
|
||||
} isdn_appl_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
char ctrl;
|
||||
char islisten;
|
||||
short unit;
|
||||
short appl;
|
||||
int (*connect)();
|
||||
int (*listen)();
|
||||
int (*accept)();
|
||||
int (*disconnect)();
|
||||
int (*output)();
|
||||
int (*state)();
|
||||
short o_len;
|
||||
char *o_buf;
|
||||
time_t lastact;
|
||||
u_long send_err;
|
||||
u_long rcv_err;
|
||||
} isdn_ctrl_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
short appl;
|
||||
dlpd_t dlpd;
|
||||
ncpd_t ncpd;
|
||||
u_long timeout;
|
||||
u_char prot;
|
||||
} isdn_param;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
short appl;
|
||||
short ctrl;
|
||||
u_char b_channel;
|
||||
u_long inf_mask;
|
||||
u_char out_serv;
|
||||
u_char out_serv_add;
|
||||
u_char src_subadr;
|
||||
u_char spv;
|
||||
telno_t telno;
|
||||
} dial_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
short appl;
|
||||
short ctrl;
|
||||
u_long inf_mask;
|
||||
u_short subadr_mask;
|
||||
u_short si_mask;
|
||||
} listen_t;
|
||||
|
||||
#define ISBUSY(x) (((x) & 0x80) == 0)
|
||||
#define ISFREE(x) (((x) & 0x80) == 0x80)
|
||||
#define TELNO_VALID 1
|
||||
#define TELNO_PROMISC 2
|
||||
|
||||
#define N_ISDN_CTRL 2
|
||||
|
||||
#define ISDN_DIAL _IOWR('I',1,dial_t)
|
||||
#define ISDN_LISTEN _IOWR('I',2,listen_t)
|
||||
#define ISDN_ACCEPT _IOWR('I',3,int)
|
||||
#define ISDN_HANGUP _IOWR('I',4,int)
|
||||
#define ISDN_SET_PARAM _IOWR('I',8,isdn_param)
|
||||
#define ISDN_GET_PARAM _IOWR('I',9,isdn_param)
|
1467
sys/gnu/scsi/nic5000.c
Normal file
1467
sys/gnu/scsi/nic5000.c
Normal file
File diff suppressed because it is too large
Load Diff
53
sys/gnu/scsi/scsi_nic.h
Normal file
53
sys/gnu/scsi/scsi_nic.h
Normal file
@ -0,0 +1,53 @@
|
||||
static char rcsid[] = "@(#)$Id: scsi_nic.h,v 1.1 1995/01/25 14:06:18 jkr Exp jkr $";
|
||||
/*******************************************************************************
|
||||
* II - Version 0.1 $Revision: 1.1 $ $State: Exp $
|
||||
*
|
||||
* Copyright 1994 Dietmar Friede
|
||||
*******************************************************************************
|
||||
* Bug reports, patches, comments, suggestions should be sent to:
|
||||
*
|
||||
* jkr@saarlink.de or jkrause@guug.de
|
||||
*
|
||||
*******************************************************************************
|
||||
* $Log: scsi_nic.h,v $
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
/*
|
||||
* This file defines the NICCY 5000 Interface.
|
||||
* Copyright Dr. Neuhaus GmbH, Hamburg and Dietmar Friede
|
||||
*
|
||||
*/
|
||||
#define GET_MSG_COMMAND 0x08
|
||||
#define PUT_MSG_COMMAND 0x0a
|
||||
|
||||
#pragma pack (1)
|
||||
struct scsi_msg
|
||||
{
|
||||
u_char op_code;
|
||||
u_char dummy;
|
||||
u_char len[3];
|
||||
u_char control;
|
||||
};
|
||||
|
||||
typedef struct
|
||||
{
|
||||
unsigned char Type;
|
||||
unsigned char SubType;
|
||||
unsigned short Number ;
|
||||
unsigned char MoreData ;
|
||||
unsigned char Reserved[1] ;
|
||||
unsigned short DataLen ;
|
||||
unsigned short PLCI;
|
||||
} Header;
|
||||
|
||||
#define SNIC_BUF_SIZE 2048+15
|
||||
|
||||
typedef struct
|
||||
{
|
||||
Header h;
|
||||
unsigned char Data[SNIC_BUF_SIZE];
|
||||
} Buffer;
|
||||
|
||||
#pragma pack ()
|
||||
|
Loading…
Reference in New Issue
Block a user