linux/drivers/isdn/mISDN/layer2.h
<<
>>
Prefs
   1/*
   2 * Layer 2 defines
   3 *
   4 * Copyright 2008  by Karsten Keil <kkeil@novell.com>
   5 *
   6 * This program is free software; you can redistribute it and/or modify
   7 * it under the terms of the GNU General Public License version 2 as
   8 * published by the Free Software Foundation.
   9 *
  10 * This program is distributed in the hope that it will be useful,
  11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13 * GNU General Public License for more details.
  14 *
  15 */
  16
  17#include <linux/mISDNif.h>
  18#include <linux/skbuff.h>
  19#include "fsm.h"
  20
  21#define MAX_WINDOW      8
  22
  23struct manager {
  24        struct mISDNchannel     ch;
  25        struct mISDNchannel     bcast;
  26        u_long                  options;
  27        struct list_head        layer2;
  28        rwlock_t                lock;
  29        struct FsmInst          deact;
  30        struct FsmTimer         datimer;
  31        struct sk_buff_head     sendq;
  32        struct mISDNchannel     *up;
  33        u_int                   nextid;
  34        u_int                   lastid;
  35};
  36
  37struct teimgr {
  38        int                     ri;
  39        int                     rcnt;
  40        struct FsmInst          tei_m;
  41        struct FsmTimer         timer;
  42        int                     tval, nval;
  43        struct layer2           *l2;
  44        struct manager          *mgr;
  45};
  46
  47struct laddr {
  48        u_char  A;
  49        u_char  B;
  50};
  51
  52struct layer2 {
  53        struct list_head        list;
  54        struct mISDNchannel     ch;
  55        u_long                  flag;
  56        int                     id;
  57        struct mISDNchannel     *up;
  58        signed char             sapi;
  59        signed char             tei;
  60        struct laddr            addr;
  61        u_int                   maxlen;
  62        struct teimgr           *tm;
  63        u_int                   vs, va, vr;
  64        int                     rc;
  65        u_int                   window;
  66        u_int                   sow;
  67        struct FsmInst          l2m;
  68        struct FsmTimer         t200, t203;
  69        int                     T200, N200, T203;
  70        u_int                   next_id;
  71        u_int                   down_id;
  72        struct sk_buff          *windowar[MAX_WINDOW];
  73        struct sk_buff_head     i_queue;
  74        struct sk_buff_head     ui_queue;
  75        struct sk_buff_head     down_queue;
  76        struct sk_buff_head     tmp_queue;
  77};
  78
  79enum {
  80        ST_L2_1,
  81        ST_L2_2,
  82        ST_L2_3,
  83        ST_L2_4,
  84        ST_L2_5,
  85        ST_L2_6,
  86        ST_L2_7,
  87        ST_L2_8,
  88};
  89
  90#define L2_STATE_COUNT (ST_L2_8+1)
  91
  92extern struct layer2    *create_l2(struct mISDNchannel *, u_int,
  93                                u_long, int, int);
  94extern int              tei_l2(struct layer2 *, u_int, u_long arg);
  95
  96
  97/* from tei.c */
  98extern int              l2_tei(struct layer2 *, u_int, u_long arg);
  99extern void             TEIrelease(struct layer2 *);
 100extern int              TEIInit(u_int *);
 101extern void             TEIFree(void);
 102
 103#define MAX_L2HEADER_LEN 4
 104
 105#define RR      0x01
 106#define RNR     0x05
 107#define REJ     0x09
 108#define SABME   0x6f
 109#define SABM    0x2f
 110#define DM      0x0f
 111#define UI      0x03
 112#define DISC    0x43
 113#define UA      0x63
 114#define FRMR    0x87
 115#define XID     0xaf
 116
 117#define CMD     0
 118#define RSP     1
 119
 120#define LC_FLUSH_WAIT 1
 121
 122#define FLG_LAPB        0
 123#define FLG_LAPD        1
 124#define FLG_ORIG        2
 125#define FLG_MOD128      3
 126#define FLG_PEND_REL    4
 127#define FLG_L3_INIT     5
 128#define FLG_T200_RUN    6
 129#define FLG_ACK_PEND    7
 130#define FLG_REJEXC      8
 131#define FLG_OWN_BUSY    9
 132#define FLG_PEER_BUSY   10
 133#define FLG_DCHAN_BUSY  11
 134#define FLG_L1_ACTIV    12
 135#define FLG_ESTAB_PEND  13
 136#define FLG_PTP         14
 137#define FLG_FIXED_TEI   15
 138#define FLG_L2BLOCK     16
 139#define FLG_L1_NOTREADY 17
 140#define FLG_LAPD_NET    18
 141