/*****************************************************************************
 * Copyright (c) 1988-95 Digi International Inc., All Rights Reserved
 * 
 * This  software  contains  proprietary  and  confidential   information   of
 * Digi International  Inc.   By  accepting  transfer  of this copy, Recipient
 * agrees to retain this software in  confidence,  to  prevent  disclosure  to
 * others,  and  to make no  use of this software other than that for which it
 * was delivered.  This is an unpublished copyright work  Digi   International
 * Inc.    Except   as   permitted   by  federal  law,  17 USC 117, copying is
 * strictly prohibited.
 * 
 * Digi  International  Inc.  CONFIDENTIAL  -   (Digi    International    Inc.
 * Confidential  when   combined   with   the   aggregated  modules  for  this
 * product) OBJECT CODE ONLY SOURCE MATERIALS
 * 
 * (C) COPYRIGHT Digi International Inc. 1995
 * 
 * All Rights Reserved
 * 
 * US   Government   Users   Restricted   Rights   -   Use,   duplication   or
 * disclosure  restricted by GSA ADP Schedule Contract with Digi International
 * Inc.
 * 
 *****************************************************************************/

/*****************************************************************************
 *
 * $Id: iwan_proto.h,v 1.6 1999/05/14 21:02:35 gary Exp $
 *
 * Copyright (c) 1993-1994 Spider Systems Limited
 *
 * This Source Code is furnished under Licence, and may not be
 * copied or distributed without express written agreement.
 *
 * All rights reserved.  Made in Scotland.
 *
 * Authors: Duncan Walker
 *
 * iwan_proto.h of snet module
 *
 * SpiderISDN
 * Release 3.0.0 94/12/20
 * 
 * SpiderISDN Release 3 - Official Release.
 *
 *****************************************************************************/

/*
 * iwan_proto.h
 */

/*
    WAN primitive type values
    Values start at 2 to enable backward compatibility with
    release 1
*/
#define WAN_REG		  2
#define WAN_CTL           3
#define WAN_DAT           4
#define WAN_REP	          5

/*
    WAN_CTL type command values/events pairings
*/
#define WC_CONNECT        1
#define WC_CONCNF         2
#define WC_DISC           3
#define WC_DISCCNF        4

#define wconnect          0x01
#define wconcnf           0x02
#define wdisc             0x04
#define wdisccnf          0x08
#define wstatus           0x10

/*
    WAN_DAT type command values
*/
#define WC_TX		  1
#define WC_RX		  2

/*
    Values for wan_status field
*/
#define WAN_FAIL          0
#define WAN_SUCCESS       1

/*
    Values for wan_remtype field
*/
#define WAN_TYPE_ASC    0          /* Ascii length in octets       */
#define WAN_TYPE_BCD    1          /* BCD   length in semi octets  */
#define WAN_TYPE_DIGI   2          /* Proprietary methodology      */


/*
    WAN Registration message
*/
struct wan_reg {
    uint8  wan_type;           /* WAN_REG                  */
    uint8  wan_status;         /* Result status            */
    uint16 wan_spare;         
    uint32 wan_snid;           /* Subnetwork ID of stream  */
};

/*
    Values for wan_status field in wan_rep
*/
#define ISDN_IF_DOWN    0
#define ISDN_IF_UP      1
#define ISDN_INFO_TYPE	2

/*
    WAN Status Report message
*/
struct wan_rep {
    uint8  wan_type;           /* WAN_REP                  */
    uint8  wan_status;         /* Status being reported    */
    uint8  wan_diag;           /* Additional diagnoistic   */
};

/*
    WAN Connection Control message
*/
struct wan_ctl {
    uint8 wan_type;           /* WAN_CTL                        */
    uint8 wan_command;        /* WC_CONNECT/CONCNF/DISC/DISCCNF */
    uint8 wan_remtype;        /* Octets or semi octets          */
    uint8 wan_remsize;        /* Remote address length          */
    uint8 wan_remaddr[20];    /* Remote address                 */
    uint8 wan_status;         /* Result status                  */
    uint8 wan_diag;	      /* Extra Diagnostic		*/
};

/*
    Values for wan_priority field
*/
#define ISDN_PRIORITY_1   1
#define ISDN_PRIORITY_2   2

/*
    WAN Data messages - Transmit and Receive
*/
struct wan_msg {
    uint8 wan_type;           /* WAN_DAT                  */
    uint8 wan_priority;       /* Priority of data message */
};


/*
    Generic WAN protocol primitive
*/
union WAN_primitives {
    uint8          wan_type;    /* Variant type             */
    struct wan_reg wreg;        /* WAN Registration         */
    struct wan_rep wrep;        /* WAN Report Indications   */
    struct wan_ctl wctl;        /* WAN Connection Control   */
    struct wan_msg wmsg;        /* WAN Data Message         */
};


#define WAN_REG_SIZE sizeof(struct wan_reg)
#define WAN_REP_SIZE sizeof(struct wan_rep)
#define WAN_CTL_SIZE sizeof(struct wan_ctl)
#define WAN_MSG_SIZE sizeof(struct wan_msg)
