1 /* $Id: isdn_net.h,v 1.19 2000/06/21 09:54:29 keil Exp $
3 * header for Linux ISDN subsystem, network related functions (linklevel).
5 * Copyright 1994-1999 by Fritz Elfert (fritz@isdn4linux.de)
6 * Copyright 1995,96 by Thinking Objects Software GmbH Wuerzburg
7 * Copyright 1995,96 by Michael Hipp (Michael.Hipp@student.uni-tuebingen.de)
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2, or (at your option)
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
25 /* Definitions for hupflags: */
26 #define ISDN_WAITCHARGE 1 /* did not get a charge info yet */
27 #define ISDN_HAVECHARGE 2 /* We know a charge info */
28 #define ISDN_CHARGEHUP 4 /* We want to use the charge mechanism */
29 #define ISDN_INHUP 8 /* Even if incoming, close after huptimeout */
30 #define ISDN_MANCHARGE 16 /* Charge Interval manually set */
33 * Definitions for Cisco-HDLC header.
36 typedef struct cisco_hdr
{
37 __u8 addr
; /* unicast/broadcast */
38 __u8 ctrl
; /* Always 0 */
39 __u16 type
; /* IP-typefield */
42 typedef struct cisco_slarp
{
43 __u32 code
; /* SLREQ/SLREPLY/KEEPALIVE */
46 __u32 ifaddr
; /* My interface address */
47 __u32 netmask
; /* My interface netmask */
50 __u32 my_seq
; /* Packet sequence number */
54 __u16 rel
; /* Always 0xffff */
55 __u16 t1
; /* Uptime in usec >> 16 */
56 __u16 t0
; /* Uptime in usec & 0xffff */
59 #define CISCO_ADDR_UNICAST 0x0f
60 #define CISCO_ADDR_BROADCAST 0x8f
61 #define CISCO_TYPE_INET 0x0800
62 #define CISCO_TYPE_SLARP 0x8035
63 #define CISCO_SLARP_REPLY 0
64 #define CISCO_SLARP_REQUEST 1
65 #define CISCO_SLARP_KEEPALIVE 2
67 extern char *isdn_net_new(char *, struct net_device
*);
68 extern char *isdn_net_newslave(char *);
69 extern int isdn_net_rm(char *);
70 extern int isdn_net_rmall(void);
71 extern int isdn_net_stat_callback(int, isdn_ctrl
*);
72 extern int isdn_net_setcfg(isdn_net_ioctl_cfg
*);
73 extern int isdn_net_getcfg(isdn_net_ioctl_cfg
*);
74 extern int isdn_net_addphone(isdn_net_ioctl_phone
*);
75 extern int isdn_net_getphones(isdn_net_ioctl_phone
*, char *);
76 extern int isdn_net_getpeer(isdn_net_ioctl_phone
*, isdn_net_ioctl_phone
*);
77 extern int isdn_net_delphone(isdn_net_ioctl_phone
*);
78 extern int isdn_net_find_icall(int, int, int, setup_parm
*);
79 extern void isdn_net_hangup(struct net_device
*);
80 extern void isdn_net_dial(void);
81 extern void isdn_net_autohup(void);
82 extern int isdn_net_force_hangup(char *);
83 extern int isdn_net_force_dial(char *);
84 extern isdn_net_dev
*isdn_net_findif(char *);
85 extern int isdn_net_rcv_skb(int, struct sk_buff
*);
86 extern void isdn_net_slarp_out(void);
87 extern int isdn_net_dial_req(isdn_net_local
*);
88 extern void isdn_net_writebuf_skb(isdn_net_local
*lp
, struct sk_buff
*skb
);
89 extern void isdn_net_write_super(isdn_net_local
*lp
, struct sk_buff
*skb
);
91 #define ISDN_NET_MAX_QUEUE_LENGTH 2
94 * is this particular channel busy?
96 static __inline__
int isdn_net_lp_busy(isdn_net_local
*lp
)
98 if (atomic_read(&lp
->frame_cnt
) < ISDN_NET_MAX_QUEUE_LENGTH
)
105 * For the given net device, this will get a non-busy channel out of the
106 * corresponding bundle. The returned channel is locked.
108 static __inline__ isdn_net_local
* isdn_net_get_locked_lp(isdn_net_dev
*nd
)
113 spin_lock_irqsave(&nd
->queue_lock
, flags
);
114 lp
= nd
->queue
; /* get lp on top of queue */
115 spin_lock_bh(&nd
->queue
->xmit_lock
);
116 while (isdn_net_lp_busy(nd
->queue
)) {
117 spin_unlock_bh(&nd
->queue
->xmit_lock
);
118 nd
->queue
= nd
->queue
->next
;
119 if (nd
->queue
== lp
) { /* not found -- should never happen */
123 spin_lock_bh(&nd
->queue
->xmit_lock
);
126 nd
->queue
= nd
->queue
->next
;
128 spin_unlock_irqrestore(&nd
->queue_lock
, flags
);
133 * add a channel to a bundle
135 static __inline__
void isdn_net_add_to_bundle(isdn_net_dev
*nd
, isdn_net_local
*nlp
)
140 spin_lock_irqsave(&nd
->queue_lock
, flags
);
143 nlp
->last
= lp
->last
;
144 lp
->last
->next
= nlp
;
149 spin_unlock_irqrestore(&nd
->queue_lock
, flags
);
152 * remove a channel from the bundle it belongs to
154 static __inline__
void isdn_net_rm_from_bundle(isdn_net_local
*lp
)
156 isdn_net_local
*master_lp
= lp
;
160 master_lp
= (isdn_net_local
*) lp
->master
->priv
;
162 spin_lock_irqsave(&master_lp
->netdev
->queue_lock
, flags
);
163 lp
->last
->next
= lp
->next
;
164 lp
->next
->last
= lp
->last
;
165 if (master_lp
->netdev
->queue
== lp
)
166 master_lp
->netdev
->queue
= lp
->next
;
167 lp
->next
= lp
->last
= lp
; /* (re)set own pointers */
168 spin_unlock_irqrestore(&master_lp
->netdev
->queue_lock
, flags
);