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

 @(#) $Id: ss7.h,v 0.7.2.3 2000/10/09 02:40:44 brian Exp $

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

 Copyright (C) 1997, 1998, 1999, 2000  Brian Bidulock <bidulock@dallas.net>

 All Rights Reserved.

 This program is free software; you can redistribute it and/or modify it under
 the terms of the GNU General Public License as published by the Free Software
 Foundation; either version 2 of the License, or (at your option) any later
 version.

 This program is distributed in the hope that it will be useful, but WITHOUT
 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
 details.

 You should have received a copy of the GNU General Public License along with
 this program; if not, write to the Free Software Foundation, Inc., 675 Mass
 Ave, Cambridge, MA 02139, USA.

 Last Modified $Date: 2000/10/09 02:40:44 $ by $Author: brian $

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

 $Log: ss7.h,v $
 Revision 0.7.2.3  2000/10/09 02:40:44  brian
 Pre-release 1.

 Revision 0.7.2.2  2000/09/24 06:30:52  brian
 Committing changes.

 Revision 0.7.2.1  2000/09/07 12:49:16  brian
 Got ss7link interface support for drivers compiling.

 Revision 0.7  2000/09/07 11:17:16  brian
 Initial import of OpenSS7 stack.

 Revision 1.2  2000/09/07 10:51:51  brian
 Got these files going.

 Revision 1.1.1.1  2000/09/05 11:00:20  brian
 Initial import of new OpenSS7 stack for Linux.

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

#ifndef __LINUX_SS7_H__
#define __LINUX_SS7_H__

#define SS7LINK_DESCRIPTION "SS7/LINK($Revision: 0.7.2.3 $): SS7 LINK LEVEL (L2) INTERFACE FOR NET4"
#define SS7LINK_COPYRIGHT   "Copyright (C) 1997-2000  Brian Bidulock.  All Rights Reserved."
#define SS7LINK_DEVICES     "Supporting various serial and T1 cards."
#define SS7LINK_AUTHOR      "Brian F. G. Bidulock <bidulock@dallas.net>"
#define SS7LINK_BANNER      SS7LINK_DESCRIPTION "\n" \
                            SS7LINK_COPYRIGHT "\n" \
                            SS7LINK_DEVICES "\n" \
                            SS7LINK_AUTHOR "\n"

/* Standard well-defined SS7 protocols */
enum {
    SS7_PROTO_SNMM = 0,      /* Signalling Network Managment */
    SS7_PROTO_SNTM = 1,      /* Signalling Network Test and Maintenance */
    SS7_PROTO_SNSM = 2,      /* Signalling Network Test and Maintenance Special */
    SS7_PROTO_SCCP = 3,      /* Signalling Connection Control Part */
    SS7_PROTO_TUP  = 4,      /* Telephone User Part */
    SS7_PROTO_ISUP = 5,      /* Integrated Services Digital Network User Part */
    SS7_PROTO_DUP1 = 6,      /* Data User Part (1) */
    SS7_PROTO_DUP2 = 7,      /* Data User Part (2) */
    SS7_PROTO_MTUP = 8,      /* Message Transfer Part Test User Part */
    SS7_PROTO_TUPE = 12,     /* Telephone User Part Extended */
    SS7_PROTO_TUPP = 15,     /* Telephone User Part Plus */
    SS7_PROTO_MAX  = 16      /* That's it folks! */
};

/* SS7 Address */

/*
 *  The ss7_addr is just an SS7 point code.  This point code can be
 *  anywhere between about 14 bits and 24 bits, but we pad it out into a 32
 *  bit address, anyway. SIGTRAN M3UA talks about a 24 bit normalized point
 *  code, but the compiler will just allocate 32 anyway, so I'll go with
 *  it.
 */

struct ss7_addr {
        __u32   s_addr;
};


struct sockaddr_ss7 {
    sa_family_t         ss7_family;
    unsigned char       ss7_user_part;  /* we will have to include GTT later for SCCP */
    unsigned char       ss7_sls;        /* signaling link to use */
    struct ss7_addr     ss7_addr;
    unsigned char       __pad[
                            __SOCK_SIZE__
                            - sizeof(sa_family_t)
                            - sizeof(struct ss7_addr)
                            - sizeof(unsigned char)
                            - sizeof(unsigned char)
                            ];
};
#define sss7_zero       __pad

struct ss7_route;

#define SS7_ROUTESET_TYPE_SP       0
#define SS7_ROUTESET_TYPE_CLUSTER  1

struct ss7_routeset
{
    struct ss7_addr addr;           /* local or remote address (check flags) */
    int flags;                      /* type of remote address */
    struct ss7_route* route;        /* routes in this routeset */
    struct ss7_routeset *list;      /* list of other routesets for this route */
    struct ss7_routeset *next;      /* next routeset in routing list */
};

struct ss7_route
{
    int priority;                   /* priority of route within routeset */
    struct ss7_routeset *routeset;  /* routesets that we belong to */
    struct ss7_route *set;          /* next route in routeset */
    struct ss7_linkset *linkset;    /* linkset for this route */
    struct ss7_route *list;         /* list of other routes for this linkset */
    struct ss7_route *next;         /* list of all routes */
};

struct ss7_iface;

#define SS7_LINKSET_TYPE_A  0
#define SS7_LINKSET_TYPE_B  1
#define SS7_LINKSET_TYPE_C  2
#define SS7_LINKSET_TYPE_D  3
#define SS7_LINKSET_TYPE_E  4
#define SS7_LINKSET_TYPE_F  5

struct ss7_linkset
{
    struct ss7_addr local;          /* local point code */
    struct ss7_addr adjacent;       /* point code at other end of link */
    int type;                       /* combined linkset type */
    int congestion;                 /* congestion status for this linkset */
    struct ss7_iface *link;         /* list of links in this linkset */
    struct ss7_route *route;        /* list of routes that we belong to */
    struct ss7_linkset *list;       /* list of other linksets in this combined linkset */
    struct ss7_linkset *next;       /* list of all linksets */
};

extern void ss7mtp_free_ifaddr(struct ss7_iface *iface);

/* af_ss7.c */
extern int  sysctl_ss7_transfer_function;
extern int  sysctl_ss7_dummy_sysctl_0;
extern int  sysctl_ss7_dummy_sysctl_1;
extern int  sysctl_ss7_dummy_sysctl_2;
extern int  sysctl_ss7_dummy_sysctl_3;
extern int  sysctl_ss7_dummy_sysctl_4;
extern int  sysctl_ss7_dummy_sysctl_5;



enum {
    /*
     *  These are abstract service primitives sent downwards from the SS7 NET
     *  protocol layer to the SS7 LINK interface.
     */
    SS7_L2_PDU = 0,
    SS7_L2_EMERGENCY,
    SS7_L2_EMERGENCY_CEASES,
    SS7_L2_START,
    SS7_L2_STOP,
    SS7_L2_RETRIEVE_BSNT,
    SS7_L2_RETRIEVAL_REQUEST_AND_FSNC,
    SS7_L2_RESUME,
    SS7_L2_CLEAR_BUFFERS,
    SS7_L2_LOCAL_PROCESSOR_OUTAGE,
    SS7_L2_CONGESTION_DISCARD,
    SS7_L2_CONGESTION_ACCEPT,
    SS7_L2_NO_CONGESTION,
    SS7_L2_LAST
};

enum {
    /*
     *  These are abstracts service primitives sent upwards from the SS7 LINK
     *  interface to the SS7 NET protocol level.
     */
    SS7_L3_PDU = 0,
    SS7_L3_LINK_CONGESTED,
    SS7_L3_LINK_CONGESTION_CEASED,
    SS7_L3_RETRIEVED_MESSAGES,
    SS7_L3_RETRIEVAL_COMPLETE,
    SS7_L3_RB_CLEARED,
    SS7_L3_BSNT,
    SS7_L3_IN_SERVICE,
    SS7_L3_OUT_OF_SERVICE,
    SS7_L3_REMOTE_PROCESSOR_OUTAGE,
    SS7_L3_REMOTE_PROCESSOR_RECOVERED,
    SS7_L3_RTB_CLEARED,
    SS7_L3_LAST
};

#endif  /* __LINUX_SS7_H__ */
