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

 @(#) $Id: sccp.c,v 0.7.2.1 2000/09/11 14:08:18 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:08:18 $ by $Author: brian $

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

 $Log: sccp.c,v $
 Revision 0.7.2.1  2000/09/11 14:08:18  brian
 Remove and updated some files for better structure.  Most compile now...

 Revision 0.7  2000/09/11 07:20:41  brian
 Addeds MTP state machine and mtp and sccp socket glue code.

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

static char const ident[] = "$Name: Prerelease1 $($Revision: 0.7.2.1 $) $Date: 2000/09/11 14:08:18 $";

/*
 *  This file has all of the protocol-specific socket glue code for SCCP
 *  level sockets.
 */

#include <linux/types.h>
#include <linux/kernel.h>
#include <asm/system.h>
#include <asm/uaccess.h>
#include <linux/fcntl.h>
#include <linux/socket.h>
#include <linux/sockios.h>
#include <linux/in.h>
#include <linux/errno.h>
#include <linux/timer.h>
#include <linux/mm.h>
#include <linux/config.h>
#include <linux/inet.h>
#include <linux/netdevice.h>
#include <linux/poll.h>
#include <net/ip.h>
#include <net/protocol.h>
#include <linux/skbuff.h>
#include <net/sock.h>
#include "af_ss7.h"
#include "mtp.h"
#include "mtp_sm.h"
#include "mtp_route.h"
#include "mtp_parse.h"
#include "sccp.h"
#include "sccp_gtt.h"

static void sccp_close(struct sock *sk, long timeout)
{
}

static unsigned int sccp_poll(struct file * file, struct socket *sock, struct poll_table_struct *wait)
{
    struct sock *sk = sock->sk;
    unsigned int mask;

    poll_wait(file, sk->sleep, wait);
    mask = 0;

    if (sk->err || !skb_queue_empty(&sk->error_queue))
        mask |= POLLERR;
    if (sk->shutdown & RCV_SHUTDOWN)
        mask |= POLLHUP;
    if (!skb_queue_empty(&sk->receive_queue))
        mask |= POLLIN | POLLRDNORM;
    /* add support for class 2/3 sockets here */
    if (sock_writeable(sk))
        mask |= POLLOUT | POLLWRNORM | POLLWRBAND;
    else
        sk->socket->flags |= SO_NOSPACE;
    return mask;
}

static int sccp_ioctl(struct sock *sk, int cmd, unsigned long arg)
{
    return -ENOIOCTLCMD;    /* no ioctls for now, more later... */
}

static int sccp_setsockopt(struct sock *sk, int level, int optname, char *optval, int optlen)
{
    return -ENOPROTOOPT;    /* no sockops for now, more later... */
}

static int sccp_getsockopt(struct sock *sk, int level, int optname, char *optval, int *option)
{
    return -ENOPROTOOPT;    /* no sockops for now, more later... */
}

static int sccp_sendmsg(struct sock *sk, struct msghdr *msg, int len)
{
    return -EFAULT;
}

static int sccp_recvmsg(struct sock *sk, struct msghdr *msg, int len, int noblock, int flags, int *addr_len)
{
    return -EFAULT;
}

static int sccp_bind(struct sock *sk, struct sockaddr *uaddr, int addr_len)
{
    return -EFAULT;
}

static int sccp_backlog_rcv(struct sock *sk, struct sk_buff *skb)
{
    return -EFAULT;
}

static void sccp_hash(struct sock *sk)
{
    return;
}

static void sccp_unhash(struct sock *sk)
{
    return;
}

static int sccp_get_port(struct sock *sk, unsigned short snum)
{
    return -EFAULT;
}


struct proto sccp_prot = {
    (struct sock *)&sccp_prot,    /* sklist_next */
    (struct sock *)&sccp_prot,    /* sklist_prev */
    sccp_close,         /* close called from ss7_release */
    NULL,               /* connect */       /* for class 2&3 later */
    NULL,               /* accept */        /* for class 2&3 later */
    NULL,               /* retransmit */
    NULL,               /* write wakeup */
    NULL,               /* read wakeup */
    sccp_poll,
    sccp_ioctl,
    NULL,               /* init freshly created struct sock */
    NULL,               /* destroy struct sock */
    NULL,               /* shutdown */
    sccp_setsockopt,
    sccp_getsockopt,
    sccp_sendmsg,
    sccp_recvmsg,
    sccp_bind,          /* UDP doesn't do this? */
    sccp_backlog_rcv,
    sccp_hash,          /* put bound subsystem number in list */        /* GTT later */
    sccp_unhash,        /* remove subsystem number from bound list */   /* GTT later */
    sccp_get_port,      /* get_port check SSN bind available */         /* GTT later */
    128,                /* max_header */
    0,                  /* retransmits */
    "SS7/MTP",          /* name [32] */
    0,                  /* inuse */
    0                   /* highest inuse */
};


