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

 @(#) sdti_ioctl.h,v 0.7.8.1 2001/12/11 13:16:05 brian Exp

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

     Copyright (C) 1997-2001 OpenSS7 Corporation.  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.

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

 U.S. GOVERNMENT RESTRICTED RIGHTS.  If you are licensing this Software on
 behalf of the U.S. Government ("Government"), the following provisions apply
 to you.  If the Software is supplied by the Department of Defense ("DoD"), it
 is classified as "Commercial Computer Software" under paragraph 252.227-7014
 of the DoD Supplement to the Federal Acquisition Regulations ("DFARS") (or any
 successor regulations) and the Government is acquiring only the license rights
 granted herein (the license rights customarily provided to non-Government
 users).  If the Software is supplied to any unit or agency of the Government
 other than DoD, it is classified as "Restricted Computer Software" and the
 Government's rights in the Software are defined in paragraph 52.227-19 of the
 Federal Acquisition Regulations ("FAR") (or any success regulations) or, in
 the cases of NASA, in paragraph 18.52.227-86 of the NASA Supplement to the FAR
 (or any successor regulations).

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

 Last Modified 2001/12/11 13:16:05 by brian

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

#ifndef __SDTI_IOCTL_H__
#define __SDTI_IOCTL_H__

#ident "SS7AlphaRelease(0.7.8.1) Copyright (C) 1997-2001 OpenSS7 Corporation"

#include <linux/ioctl.h>

#define SDT_IOC_MAGIC 't'

/*
 *  PROTOCOL VARIANT AND OPTIONS
 */

#define SDT_IOCGOPTIONS _IOR(  SDT_IOC_MAGIC, 0, lmi_option_t )
#define SDT_IOCSOPTIONS _IOW(  SDT_IOC_MAGIC, 1, lmi_option_t )

/*
 *  CONFIGURATION
 */
typedef struct sdt_config {
    sdt_ulong   t8;     /* T8 timeout                           */
    sdt_ulong   Tin;    /* AERM normal proving threshold        */
    sdt_ulong   Tie;    /* AERM emergency proving threshold     */
    sdt_ulong   T;      /* SUERM error threshold                */
    sdt_ulong   D;      /* SUERM error rate parameter           */
    sdt_ulong   Te;     /* EIM error threshold                  */
    sdt_ulong   De;     /* EIM correct decrement                */
    sdt_ulong   Ue;     /* EIM error increment                  */
} sdt_config_t;

#define SDT_IOCGCONFIG  _IOWR( SDT_IOC_MAGIC, 2, sdt_config_t )
#define SDT_IOCSCONFIG  _IOWR( SDT_IOC_MAGIC, 3, sdt_config_t )
#define SDT_IOCTCONFIG  _IOWR( SDT_IOC_MAGIC, 4, sdt_config_t )
#define SDT_IOCCCONFIG  _IOWR( SDT_IOC_MAGIC, 5, sdt_config_t )

/*
 *  STATE
 */

typedef struct sdt_statem {
    sdt_ulong   aerm_state;             /* AERM  state variable      */
    sdt_ulong     aborted_proving;      /* AERM  aborted proving     */
    sdt_long      Ca;                   /* AERM  error counter       */
    sdt_ulong     Ti;                   /* AERM  threshold           */
    sdt_ulong   suerm_state;            /* SUERM state variable      */
    sdt_long      Cs;                   /* SUERM error counter       */
    sdt_ulong     Ns;                   /* SUERM su counter          */
    sdt_ulong   eim_state;              /* EIM   state variable      */
    sdt_long      Ce;                   /* EIM   counter             */
    sdt_ulong     su_received;          /* EIM   su received flag    */
    sdt_ulong     interval_error;       /* EIM   interval error flag */
    sdt_ulong   daedt_state;            /* DAEDT state variable      */
    sdt_ulong   daedr_state;            /* DAEDR state variable      */
    sdt_ulong     octet_counting_mode;  /* receivers freewheeling    */
} sdt_statem_t;

#define SDT_STATE_IDLE          0x00
#define SDT_STATE_IN_SERVICE    0x01
#define SDT_STATE_MONITORING    SDT_STATE_IN_SERVICE

#define SDT_IOCGSTATEM  _IOR(  SDT_IOC_MAGIC, 6, sdt_statem_t )
#define SDT_IOCCMRESET  _IOR(  SDT_IOC_MAGIC, 7, sdt_statem_t )

/*
 *  STATISTICS
 */

typedef struct sdt_stats {
    lmi_sta_t   header;
    sdt_ulong   tx_bytes;
    sdt_ulong   tx_sus;
    sdt_ulong   tx_underruns;
    sdt_ulong   tx_aborts;
    sdt_ulong   tx_buffer_overflows;
    sdt_ulong   tx_sus_in_error;
    sdt_ulong   rx_bytes;
    sdt_ulong   rx_sus;
    sdt_ulong   rx_overruns;
    sdt_ulong   rx_aborts;
    sdt_ulong   rx_buffer_overflows;
    sdt_ulong   rx_sus_in_error;
    sdt_ulong   rx_sync_transitions;
    sdt_ulong   rx_bits_octet_counted;
    sdt_ulong   rx_crc_errors;
    sdt_ulong   rx_frame_errors;
    sdt_ulong   rx_frame_overflows;
    sdt_ulong   rx_frame_too_long;
    sdt_ulong   rx_frame_too_short;
    sdt_ulong   rx_residue_errors;
    sdt_ulong   carrier_cts_lost;
    sdt_ulong   carrier_dcd_lost;
    sdt_ulong   carrier_lost;
} sdt_stats_t;

#define SDT_IOCGSTATSP  _IOR(  SDT_IOC_MAGIC,  8, lmi_sta_t )
#define SDT_IOCSSTATSP  _IOWR( SDT_IOC_MAGIC,  9, lmi_sta_t )
#define SDT_IOCGSTATS   _IOR(  SDT_IOC_MAGIC, 10, sdt_stats_t )
#define SDT_IOCCSTATS   _IOW(  SDT_IOC_MAGIC, 11, sdt_stats_t )

/*
 *  EVENTS
 */
typedef struct sdt_notify {
    sdt_ulong   sdt_mask;
} sdt_notify_t;

#define SDT_EVT_TX_FAIL     0x00000001
#define SDT_EVT_RX_FAIL     0x00000002
#define SDT_EVT_CARRIER     0x00000004

#define SDT_IOCGNOTIFY  _IOR(  SDT_IOC_MAGIC, 12, sdt_notify_t )
#define SDT_IOCSNOTIFY  _IOW(  SDT_IOC_MAGIC, 13, sdt_notify_t )
#define SDT_IOCCNOTIFY  _IOW(  SDT_IOC_MAGIC, 14, sdt_notify_t )

#define SDT_IOC_FIRST    0
#define SDT_IOC_LAST    14
#define SDT_IOC_PRIVATE 32

#endif  __SDTI_IOCTL_H__
