/*****************************************************************************

 @(#) lmi.h,v 0.7 2000/12/03 06:23:23 brian Exp

 -----------------------------------------------------------------------------

     Copyright (C) 2000  Brian Bidulock.  All Rights Reserved.


                                  PUBLIC LICENSE

     This license is provided without fee, provided that the above copy-
     right notice and this public license must be retained on all copies,
     extracts, compilations and derivative works.  Use or distribution of
     this work in a manner that restricts its use except as provided here
     will render this license void.

     The author(s) hereby waive any and all other restrictions in respect
     of their copyright in this software and its associated documentation.
     The authors(s) of this software place in the public domain any novel
     methods or processes which are embodied in this software.

     The author(s) undertook to write it for the sake of the advancement
     of the Arts and Sciences, but it is provided as is, and the author(s)
     will not take any responsibility in it.

 -----------------------------------------------------------------------------

 Last Modified 2000/12/03 06:23:23 by brian

 lmi.h,v
 Revision 0.7  2000/12/03 06:23:23  brian
 Added LMI files (used to be smi files).

 Revision 0.7.2.2  2000/12/02 13:07:11  brian
 A lot of work on interactions between sdl and sdt and sl.  Allows one
 module to act as direct driver for another.

 Revision 0.7.2.1  2000/11/27 13:05:54  brian
 That's starting to look better: at least for sdt.  This will
 be an autopushed module.  Have to work autopush into sdt yet
 and rework this as a module.

 Revision 0.7  2000/11/25 07:21:20  brian
 Added SS7 stack management interface.

 *****************************************************************************/

#ifndef __LMI_H__
#define __LMI_H__

#define LMI_PROTO_BASE       0L

#define LMI_DSTR_FIRST       1L + LMI_PROTO_BASE
#define LMI_INFO_REQ         1L + LMI_PROTO_BASE
#define LMI_ATTACH_REQ       2L + LMI_PROTO_BASE
#define LMI_DETACH_REQ       3L + LMI_PROTO_BASE
#define LMI_ENABLE_REQ       4L + LMI_PROTO_BASE
#define LMI_DISABLE_REQ      5L + LMI_PROTO_BASE
#define LMI_DSTR_LAST        5L + LMI_PROTO_BASE

#define LMI_USTR_LAST       -1L - LMI_PROTO_BASE
#define LMI_INFO_ACK        -1L - LMI_PROTO_BASE
#define LMI_OK_ACK          -2L - LMI_PROTO_BASE
#define LMI_ERROR_ACK       -3L - LMI_PROTO_BASE
#define LMI_ENABLE_CON      -4L - LMI_PROTO_BASE
#define LMI_DISABLE_CON     -5L - LMI_PROTO_BASE
#define LMI_ERROR_IND       -6L - LMI_PROTO_BASE
#define LMI_STATS_IND       -7L - LMI_PROTO_BASE
#define LMI_EVENT_IND       -8L - LMI_PROTO_BASE
#define LMI_USTR_FIRST      -8L - LMI_PROTO_BASE

#define LMI_UNATTACHED       1L     /* No PPA attached, awating LMI_ATTACH_REQ      */
#define LMI_ATTACH_PENDING   2L     /* Waiting for attach                           */
#define LMI_UNUSABLE         3L     /* Device cannot be used, STREAM in hung state  */
#define LMI_DISABLED         4L     /* PPA attached, awaiting LMI_ENABLE_REQ        */
#define LMI_ENABLE_PENDING   5L     /* Waiting to send LMI_ENABLE_CON               */
#define LMI_ENABLED          6L     /* Ready for use, awaiting primtiive exchange   */
#define LMI_DISABLE_PENDING  7L     /* Waiting to send LMI_DISABLE_CON              */
#define LMI_DETACH_PENDING   8L     /* Waiting for detach                           */

/*
 *  LMI_ERROR_ACK and LMI_ERROR_IND reason codes
 */
#define LMI_UNSPEC          0 << 16 /* Unknown or unspecified                   */
#define LMI_BADADDRESS      1 << 16 /* Address was invalid                      */
#define LMI_BADADDRTYPE     2 << 16 /* Invalid address type                     */
#define LMI_BADDIAL         3 << 16 /* (not used)                               */
#define LMI_BADDIALTYPE     4 << 16 /* (not used)                               */
#define LMI_BADDISPOSAL     5 << 16 /* Invalid disposal parameter               */
#define LMI_BADFRAME        6 << 16 /* Defective SDU received                   */
#define LMI_BADPPA          7 << 16 /* Invalid PPA identifier                   */
#define LMI_BADPRIM         8 << 16 /* Unregognized primitive                   */
#define LMI_DISC            9 << 16 /* Disconnected                             */
#define LMI_EVENT          10 << 16 /* Protocol-specific event ocurred          */
#define LMI_FATALERR       11 << 16 /* Device has become unusable               */
#define LMI_INITFAILED     12 << 16 /* Link initialization failed               */
#define LMI_NOTSUPP        13 << 16 /* Primitive not supported by this device   */
#define LMI_OUTSTATE       14 << 16 /* Primitive was issued from invalid state  */
#define LMI_PROTOSHORT     15 << 16 /* M_PROTO block too short                  */
#define LMI_SYSERR         16 << 16 /* UNIX system error                        */
#define LMI_WRITEFAIL      17 << 16 /* Unitdata request failed                  */
#define LMI_CRCERR         18 << 16 /* CRC or FCS error                         */
#define LMI_DLE_EOT        19 << 16 /* DLE EOT detected                         */
#define LMI_FORMAT         20 << 16 /* Format error detected                    */
#define LMI_HDLC_ABORT     21 << 16 /* Aborted frame detected                   */
#define LMI_OVERRUN        22 << 16 /* Input overrun                            */
#define LMI_TOOSHORT       23 << 16 /* Frame too short                          */
#define LMI_INCOMPLETE     24 << 16 /* Partial frame received                   */
#define LMI_BUSY           25 << 16 /* Telephone was busy                       */
#define LMI_NOANSWER       26 << 16 /* Connection went unanswered               */
#define LMI_CALLREJECT     27 << 16 /* Connection rejected                      */
#define LMI_HDLC_IDLE      28 << 16 /* HDLC line went idle                      */
#define LMI_HDLC_NOTIDLE   29 << 16 /* HDLC link no longer idle                 */
#define LMI_QUIESCENT      30 << 16 /* Line being reassigned                    */
#define LMI_RESUMED        31 << 16 /* Line has been reassigned                 */
#define LMI_DSRTIMEOUT     32 << 16 /* Did not see DSR in time                  */
#define LMI_LAN_COLLISIONS 33 << 16 /* LAN excessive collisions                 */
#define LMI_LAN_REFUSED    34 << 16 /* LAN message refused                      */
#define LMI_LAN_NOSTATION  35 << 16 /* LAN no such station                      */
#define LMI_LOSTCTS        36 << 16 /* Lost Clear to Send signal                */
#define LMI_DEVERR         64 << 16 /* Start of device-specific error codes     */

typedef   signed long  lmi_long;
typedef unsigned long  lmi_ulong;
typedef unsigned short lmi_ushort;
typedef unsigned char  lmi_uchar;

/*
 *  LOCAL MANAGEMENT PRIMITIVES
 */

/* LMI_INFO_REQ, M_PROTO or M_PCPROTO */

typedef struct {
    lmi_long    lmi_primitive;  /* LMI_INFO_REQ */
} lmi_info_req_t;

/* LMI_INFO_ACK, M_PROTO or M_PCPROTO */

typedef struct {
    lmi_long    lmi_primitive;  /* LMI_INFO_ACK */
    lmi_ulong   lmi_version;
    lmi_ulong   lmi_state;
    lmi_ulong   lmi_max_sdu;
    lmi_ulong   lmi_min_sdu;
    lmi_ulong   lmi_header_len;
    lmi_ulong   lmi_ppa_style;
    lmi_uchar   lmi_ppa_addr[0];
} lmi_info_ack_t;

/*
 *  LMI provider style.
 *
 *  The LMI provider style which determines whether a provider requires an
 *  LMI_ATTACH_REQ to inform the provider which PPA user messages should be
 *  sent/received on.
 */
#define LMI_STYLE1  0x00    /* PPA is implicitly bound by open(2) */
#define LMI_STYLE2  0x01    /* PPA must be explicitly bound via STD_ATTACH_REQ */

/* LMI_ATTACH_REQ, M_PROTO or M_PCPROTO */

typedef struct {
    lmi_long    lmi_primitive;  /* LMI_ATTACH_REQ */
    lmi_uchar   sl_ppa_addr[0];
} lmi_attach_req_t;

/* LMI_DETACH_REQ, M_PROTO or M_PCPROTO */

typedef struct {
    lmi_long    lmi_primitive;  /* LMI_DETACH_REQ */
} lmi_detach_req_t;

/* LMI_ENABLE_REQ, M_PROTO or M_PCPROTO */

typedef struct {
    lmi_long    lmi_primitive;  /* LMI_ENABLE_REQ */
} sl_enable_req_t;

/* LMI_DISABLE_REQ, M_PROTO or M_PCPROTO */

typedef struct {
    lmi_long    lmi_primitive;  /* LMI_DISABLE_REQ */
} sl_disable_req_t;

/* LMI_OK_ACK, M_PROTO or M_PCPROTO */

typedef struct {
    lmi_long    lmi_primitive;  /* LMI_OK_ACK */
    lmi_ulong   lmi_correct_primitive;
    lmi_ulong   lmi_state;
} lmi_ok_ack_t;

/* LMI_ERROR_ACK, M_CTL */

typedef struct {
    lmi_long    lmi_primitive;  /* LMI_ERROR_ACK */
    lmi_ulong   lmi_errno;
    lmi_ulong   lmi_reason;
    lmi_ulong   lmi_error_primitive;
    lmi_ulong   lmi_state;
} lmi_error_ack_t;

/* LMI_ENABLE_CON, M_PROTO or M_PCPROTO */

typedef struct {
    lmi_long     lmi_primitive; /* LMI_ENABLE_CON */
    lmi_ulong    lmi_state;
} lmi_enable_con_t;

/* LMI_DISABLE_CON, M_PROTO or M_PCPROTO */

typedef struct {
    lmi_long     lmi_primitive; /* LMI_DISABLE_CON */
    lmi_ulong    lmi_state;
} lmi_disable_con_t;

/* LMI_ERROR_IND, M_PROTO or M_PCPROTO */

typedef struct {
    lmi_long    lmi_primitive;  /* LMI_ERROR_IND */
    lmi_ulong   lmi_errno;
    lmi_ulong   lmi_reason;
    lmi_ulong   lmi_state;
} lmi_error_ind_t;

/* LMI_STATS_IND, M_PROTO */

typedef struct {
    lmi_ulong   lmi_primitive;  /* LMI_STATS_IND */
    lmi_ulong   lmi_interval;
    lmi_ulong   lmi_timestamp;
} lmi_stats_ind_t;

/* LMI_EVENT_IND, M_PROTO */

typedef struct {
    lmi_ulong   lmi_primitive;  /* LMI_EVENT_IND */
    lmi_ulong   lmi_objectid;
    lmi_ulong   lmi_timestamp;
    lmi_ulong   lmi_severity;
} lmi_event_ind_t;


union LMI_primitive {
    lmi_ulong           lmi_primitive;
    lmi_ok_ack_t        ok_ack;
    lmi_error_ack_t     error_ack;
    lmi_error_ind_t     error_ind;
    lmi_stats_ind_t     stats_ind;
    lmi_notify_req_t    notify_req;
    lmi_event_ind_t     event_ind;
};



#endif  __LMI_H__
