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

 @(#) $Id: af_ss7.h,v 0.7 2000/09/11 14:07:08 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/09/11 14:07:08 $ by $Author: brian $

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

 $Log: af_ss7.h,v $
 Revision 0.7  2000/09/11 14:07:08  brian
 Added files for socket stuff and routing.

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

#ifndef __LINUX_AF_SS7_H__
#define __LINUX_AF_SS7_H__

/* 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_NTWK = 16,     /* A dummy one for MTP */
    SS7_PROTO_MAX  = 17      /* That's it folks! */
};

extern struct ss7mtp_cb *ss7mtp_all_cbs;

/* SS7 Address */

#ifndef AF_SS7
#define AF_SS7          24      /* SS7 sockets                  */
#define PF_SS7          AF_SS7
#endif

/*
 *  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_si;  /* user part for outgoing message or bind */
    unsigned char       ss7_mp;  /* message priority for all messages */
    unsigned char       ss7_ni;  /* network indicator for all messages */
    unsigned char       ss7_sls; /* signaling link selection for all messages */
    struct ss7_addr     ss7_dpc; /* destination point code on all messages */
    struct ss7_addr     ss7_opc; /* originating point code on all merssage */
    unsigned char       __pad[
                            __SOCK_SIZE__
                            - sizeof(sa_family_t)
                            - sizeof(unsigned char)
                            - sizeof(unsigned char)
                            - sizeof(unsigned char)
                            - sizeof(unsigned char)
                            - sizeof(struct ss7_addr)
                            - sizeof(struct ss7_addr)
                        ];
};
#define sss7_zero       __pad


#define SS7_PROT_LINK	2   /* SS7 Link Level */
#define SS7_PROT_NTWK	3   /* SS7 Network Level */
#define SS7_PROT_SCCP	4   /* SS7 Transport Level */

/*
 *  SOCK_LINK_RAW == SOCK_RAW
 *  ------------------------------------
 *  SS7 Level 2 is not normally accessed by applications as there is no
 *  application part which is defined to ride abov it.  (Perhaps with the
 *  exception of some Work In Progress SIGTRAN protocols such as M2UA/M2PA).
 *  Therfore, it takes a RAW socket to access the protocol level.
 *
 *  SOCK_PACKET
 *  ------------------------------------
 *  SS7 Level 2 is the link level and the appropriate layer to provide a
 *  packet socket.  This socket should have really been opened with
 *  packet_socket() instead of socket(), but we'll allow that.
 *
 *  SOCK_NTWK_NSEQ == SOCK_RDM
 *  ------------------------------------
 *  SS7 MTP is normally accessed by applications user parts such as ISUP, TUP,
 *  etc.  (This information is contained in the SS7 address sockaddr_ss7 much
 *  like a TCP port number is for IP.)  MTP provides reliable, sequenced
 *  end-to-end packet delivery or reliable but unsequenced packet delivery
 *  depending upon the user's use of the SLS (Signaling Link Selection) field.
 *  All messages with the same SLS are guaranteed in-sequence delivery,
 *  whereas different SLSs does not necessarily provide in-sequence delivery.
 *
 *  When SOCK_RDM is chosen, the MTP protocol layer will rotate the SLS field
 *  to ensure balancing of messages across links in a linkset.
 *
 *  SOCK_NTWK_ISEQ == SOCK_SEQPACKET
 *  ------------------------------------
 *  When SOCK_SEQPACKET is chosen, the socket user must provide a stream
 *  number which the MTP protocol layer will use to assign a consistent SLS
 *  value for a given stream.  There are conditions on the stream identifier
 *  which make it suitable for simple SLS selection, and there is no guarantee
 *  that the MTP will not just use the bottom 5 bits.
 *
 *  SOCK_NETWK_RAW == SOCK_RAW
 *  ------------------------------------
 *  For testing and other purposes, it is ncessary to gain access to the MTP
 *  and be able to provide the MTP routing label directly.  SOCK_RAW does
 *  this.
 *
 *  SOCK_SCCP_CC_0 == SOCK_DGRAM
 *  ------------------------------------
 *  These mappings really don't make total sense; however, there are four
 *  classes of SCCP transport service of which some correspond to the standard
 *  socket definitions here.
 *
 *  SOCK_DGRAM corresponds to SCCP Connection Class 0.  SCCP Connection Class
 *  0 is unsequenced connectionless delivery.  (Not necessarily unreliable.)
 *
 *  SOCK_SCCP_CC_1 == SOCK_RDM
 *  ------------------------------------
 *  SOCK_RDB corresponds to SCCP Connection Clase 1.  SCCP Connection Class 1
 *  is sequenced connectionless delivery.  (Again, not necessarily reliable.)
 *
 *  SOCK_SCCP_CC_2 == SOCK_SEQPACKET
 *  ------------------------------------
 *  SOCK_SEQPACKET corresponse to SCCP Connection Class 2. SCCP Connection
 *  Class 2 is sequenced connection-oriented delivery without flow control.
 *
 *  SOCK_SCCP_CC_3 == SOCK_STREAM
 *  ------------------------------------
 *  SOCK_STREAM corresponse to SCCP Connection Class 3.  SCCP Connection Class
 *  3 is sequenced connection-oriented delivery with flow control.
 *
 *  SOCK_SCCP_RAW == SOCK_RAW
 *  ------------------------------------
 *  Again, for testing it will be necesary to have direct access to the SCCP
 *  protocol layer to permit fabrication by the user of the SCCP headers.
 *
 */

#define SOCK_NTWK_RAW	    SOCK_RAW	    /* NTWK raw socket. */
#define SOCK_NTWK_NSEQ	    SOCK_RDM	    /* NTWK insequence. */
#define SOCK_NTWK_ISEQ	    SOCK_SEQPACKET  /* NTWK insequence. */
#define SOCK_SCCP_CC_0	    SOCK_DGRAM	    /* SCCP Class 0	*/
#define SOCK_SCCP_CC_1	    SOCK_RDM	    /* SCCP Class 1	*/
#define SOCK_SCCP_CC_2	    SOCK_SEQPACKET  /* SCCP Class 2	*/
#define SOCK_SCCP_CC_3	    SOCK_STREAM	    /* SCCP Class 3	*/

/*  SOCK_RAW	     *	direct access to protocol	    */
/*  SOCK_PACKET	     *	Linux link interface		    */
/*  SOCK_DGRAM	     *	unreliable, unsequenced, packet	    */
/*  SOCK_RDM	     *	reliable, unsequenced, packet	    */
/*  SOCK_SEQPACKET   *	reliable, sequenced, packet	    */
/*  SOCK_STREAM	     *	reliable, sequenced, stream	    */

/*
 *  Device private ioctl's for controlling SS7 link interfaces.  They
 *  should be allocated in decending order to keep out of the way of the
 *  actual device's ioctls.
 */
enum {
    SIOCSPRIV_f = SIOCDEVPRIVATE + 15,
    SIOCSPRIV_e = SIOCDEVPRIVATE + 14,
    SIOCSPRIV_d = SIOCDEVPRIVATE + 13,
    SIOCSPRIV_c = SIOCDEVPRIVATE + 12,
    SIOCSPRIV_b = SIOCDEVPRIVATE + 11,
    SIOCSPRIV_a = SIOCDEVPRIVATE + 10,
    SIOCSPRIV_9 = SIOCDEVPRIVATE + 9,
    SIOCSPRIV_8 = SIOCDEVPRIVATE + 8,
    SIOCSPRIV_7 = SIOCDEVPRIVATE + 7,
    SIOCSPRIV_6 = SIOCDEVPRIVATE + 6,
    SIOCSPRIV_5 = SIOCDEVPRIVATE + 5,
    SIOCSPRIV_4 = SIOCDEVPRIVATE + 4,
    SIOCSPRIV_3 = SIOCDEVPRIVATE + 3,
    SIOCSPRIV_2 = SIOCDEVPRIVATE + 2,
    SIOCSPRIV_1 = SIOCDEVPRIVATE + 1,
    SIOCSPRIV_0 = SIOCDEVPRIVATE
};


#endif  __LINUX_AF_SS7_H__

