OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [linux/] [linux-2.4/] [net/] [sctp/] [endpointola.c] - Diff between revs 1275 and 1765

Only display areas with differences | Details | Blame | View Log

Rev 1275 Rev 1765
/* SCTP kernel reference Implementation
/* SCTP kernel reference Implementation
 * Copyright (c) 1999-2000 Cisco, Inc.
 * Copyright (c) 1999-2000 Cisco, Inc.
 * Copyright (c) 1999-2001 Motorola, Inc.
 * Copyright (c) 1999-2001 Motorola, Inc.
 * Copyright (c) 2001-2002 International Business Machines, Corp.
 * Copyright (c) 2001-2002 International Business Machines, Corp.
 * Copyright (c) 2001 Intel Corp.
 * Copyright (c) 2001 Intel Corp.
 * Copyright (c) 2001 Nokia, Inc.
 * Copyright (c) 2001 Nokia, Inc.
 * Copyright (c) 2001 La Monte H.P. Yarroll
 * Copyright (c) 2001 La Monte H.P. Yarroll
 *
 *
 * This file is part of the SCTP kernel reference Implementation
 * This file is part of the SCTP kernel reference Implementation
 *
 *
 * This abstraction represents an SCTP endpoint.
 * This abstraction represents an SCTP endpoint.
 *
 *
 * This file is part of the implementation of the add-IP extension,
 * This file is part of the implementation of the add-IP extension,
 * based on <draft-ietf-tsvwg-addip-sctp-02.txt> June 29, 2001,
 * based on <draft-ietf-tsvwg-addip-sctp-02.txt> June 29, 2001,
 * for the SCTP kernel reference Implementation.
 * for the SCTP kernel reference Implementation.
 *
 *
 * The SCTP reference implementation is free software;
 * The SCTP reference implementation is free software;
 * you can redistribute it and/or modify it under the terms of
 * you can redistribute it and/or modify it under the terms of
 * the GNU General Public License as published by
 * the GNU General Public License as published by
 * the Free Software Foundation; either version 2, or (at your option)
 * the Free Software Foundation; either version 2, or (at your option)
 * any later version.
 * any later version.
 *
 *
 * The SCTP reference implementation is distributed in the hope that it
 * The SCTP reference implementation is distributed in the hope that it
 * will be useful, but WITHOUT ANY WARRANTY; without even the implied
 * will be useful, but WITHOUT ANY WARRANTY; without even the implied
 *                 ************************
 *                 ************************
 * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 * See the GNU General Public License for more details.
 * See the GNU General Public License for more details.
 *
 *
 * You should have received a copy of the GNU General Public License
 * You should have received a copy of the GNU General Public License
 * along with GNU CC; see the file COPYING.  If not, write to
 * along with GNU CC; see the file COPYING.  If not, write to
 * the Free Software Foundation, 59 Temple Place - Suite 330,
 * the Free Software Foundation, 59 Temple Place - Suite 330,
 * Boston, MA 02111-1307, USA.
 * Boston, MA 02111-1307, USA.
 *
 *
 * Please send any bug reports or fixes you make to the
 * Please send any bug reports or fixes you make to the
 * email address(es):
 * email address(es):
 *    lksctp developers <lksctp-developers@lists.sourceforge.net>
 *    lksctp developers <lksctp-developers@lists.sourceforge.net>
 *
 *
 * Or submit a bug report through the following website:
 * Or submit a bug report through the following website:
 *    http://www.sf.net/projects/lksctp
 *    http://www.sf.net/projects/lksctp
 *
 *
 * Written or modified by:
 * Written or modified by:
 *    La Monte H.P. Yarroll <piggy@acm.org>
 *    La Monte H.P. Yarroll <piggy@acm.org>
 *    Karl Knutson <karl@athena.chicago.il.us>
 *    Karl Knutson <karl@athena.chicago.il.us>
 *    Jon Grimm <jgrimm@austin.ibm.com>
 *    Jon Grimm <jgrimm@austin.ibm.com>
 *    Daisy Chang <daisyc@us.ibm.com>
 *    Daisy Chang <daisyc@us.ibm.com>
 *    Dajiang Zhang <dajiang.zhang@nokia.com>
 *    Dajiang Zhang <dajiang.zhang@nokia.com>
 *
 *
 * Any bugs reported given to us we will try to fix... any fixes shared will
 * Any bugs reported given to us we will try to fix... any fixes shared will
 * be incorporated into the next SCTP release.
 * be incorporated into the next SCTP release.
 */
 */
 
 
#include <linux/types.h>
#include <linux/types.h>
#include <linux/sched.h>
#include <linux/sched.h>
#include <linux/slab.h>
#include <linux/slab.h>
#include <linux/in.h>
#include <linux/in.h>
#include <linux/random.h>       /* get_random_bytes() */
#include <linux/random.h>       /* get_random_bytes() */
#include <linux/crypto.h>
#include <linux/crypto.h>
#include <net/sock.h>
#include <net/sock.h>
#include <net/ipv6.h>
#include <net/ipv6.h>
#include <net/sctp/sctp.h>
#include <net/sctp/sctp.h>
#include <net/sctp/sm.h>
#include <net/sctp/sm.h>
 
 
/* Forward declarations for internal helpers. */
/* Forward declarations for internal helpers. */
static void sctp_endpoint_bh_rcv(struct sctp_endpoint *ep);
static void sctp_endpoint_bh_rcv(struct sctp_endpoint *ep);
 
 
/* Create a sctp_endpoint with all that boring stuff initialized.
/* Create a sctp_endpoint with all that boring stuff initialized.
 * Returns NULL if there isn't enough memory.
 * Returns NULL if there isn't enough memory.
 */
 */
struct sctp_endpoint *sctp_endpoint_new(struct sock *sk, int gfp)
struct sctp_endpoint *sctp_endpoint_new(struct sock *sk, int gfp)
{
{
        struct sctp_endpoint *ep;
        struct sctp_endpoint *ep;
 
 
        /* Build a local endpoint. */
        /* Build a local endpoint. */
        ep = t_new(struct sctp_endpoint, gfp);
        ep = t_new(struct sctp_endpoint, gfp);
        if (!ep)
        if (!ep)
                goto fail;
                goto fail;
        if (!sctp_endpoint_init(ep, sk, gfp))
        if (!sctp_endpoint_init(ep, sk, gfp))
                goto fail_init;
                goto fail_init;
        ep->base.malloced = 1;
        ep->base.malloced = 1;
        SCTP_DBG_OBJCNT_INC(ep);
        SCTP_DBG_OBJCNT_INC(ep);
        return ep;
        return ep;
 
 
fail_init:
fail_init:
        kfree(ep);
        kfree(ep);
fail:
fail:
        return NULL;
        return NULL;
}
}
 
 
/*
/*
 * Initialize the base fields of the endpoint structure.
 * Initialize the base fields of the endpoint structure.
 */
 */
struct sctp_endpoint *sctp_endpoint_init(struct sctp_endpoint *ep,
struct sctp_endpoint *sctp_endpoint_init(struct sctp_endpoint *ep,
                                         struct sock *sk, int gfp)
                                         struct sock *sk, int gfp)
{
{
        struct sctp_opt *sp = sctp_sk(sk);
        struct sctp_opt *sp = sctp_sk(sk);
        memset(ep, 0, sizeof(struct sctp_endpoint));
        memset(ep, 0, sizeof(struct sctp_endpoint));
 
 
        /* Initialize the base structure. */
        /* Initialize the base structure. */
        /* What type of endpoint are we?  */
        /* What type of endpoint are we?  */
        ep->base.type = SCTP_EP_TYPE_SOCKET;
        ep->base.type = SCTP_EP_TYPE_SOCKET;
 
 
        /* Initialize the basic object fields. */
        /* Initialize the basic object fields. */
        atomic_set(&ep->base.refcnt, 1);
        atomic_set(&ep->base.refcnt, 1);
        ep->base.dead = 0;
        ep->base.dead = 0;
        ep->base.malloced = 1;
        ep->base.malloced = 1;
 
 
        /* Create an input queue.  */
        /* Create an input queue.  */
        sctp_inq_init(&ep->base.inqueue);
        sctp_inq_init(&ep->base.inqueue);
 
 
        /* Set its top-half handler */
        /* Set its top-half handler */
        sctp_inq_set_th_handler(&ep->base.inqueue,
        sctp_inq_set_th_handler(&ep->base.inqueue,
                                (void (*)(void *))sctp_endpoint_bh_rcv, ep);
                                (void (*)(void *))sctp_endpoint_bh_rcv, ep);
 
 
        /* Initialize the bind addr area */
        /* Initialize the bind addr area */
        sctp_bind_addr_init(&ep->base.bind_addr, 0);
        sctp_bind_addr_init(&ep->base.bind_addr, 0);
        ep->base.addr_lock = RW_LOCK_UNLOCKED;
        ep->base.addr_lock = RW_LOCK_UNLOCKED;
 
 
        /* Remember who we are attached to.  */
        /* Remember who we are attached to.  */
        ep->base.sk = sk;
        ep->base.sk = sk;
        sock_hold(ep->base.sk);
        sock_hold(ep->base.sk);
 
 
        /* Create the lists of associations.  */
        /* Create the lists of associations.  */
        INIT_LIST_HEAD(&ep->asocs);
        INIT_LIST_HEAD(&ep->asocs);
 
 
        /* Set up the base timeout information.  */
        /* Set up the base timeout information.  */
        ep->timeouts[SCTP_EVENT_TIMEOUT_NONE] = 0;
        ep->timeouts[SCTP_EVENT_TIMEOUT_NONE] = 0;
        ep->timeouts[SCTP_EVENT_TIMEOUT_T1_COOKIE] =
        ep->timeouts[SCTP_EVENT_TIMEOUT_T1_COOKIE] =
                SCTP_DEFAULT_TIMEOUT_T1_COOKIE;
                SCTP_DEFAULT_TIMEOUT_T1_COOKIE;
        ep->timeouts[SCTP_EVENT_TIMEOUT_T1_INIT] =
        ep->timeouts[SCTP_EVENT_TIMEOUT_T1_INIT] =
                SCTP_DEFAULT_TIMEOUT_T1_INIT;
                SCTP_DEFAULT_TIMEOUT_T1_INIT;
        ep->timeouts[SCTP_EVENT_TIMEOUT_T2_SHUTDOWN] =
        ep->timeouts[SCTP_EVENT_TIMEOUT_T2_SHUTDOWN] =
                SCTP_MSECS_TO_JIFFIES(sp->rtoinfo.srto_initial);
                SCTP_MSECS_TO_JIFFIES(sp->rtoinfo.srto_initial);
        ep->timeouts[SCTP_EVENT_TIMEOUT_T3_RTX] = 0;
        ep->timeouts[SCTP_EVENT_TIMEOUT_T3_RTX] = 0;
        ep->timeouts[SCTP_EVENT_TIMEOUT_T4_RTO] = 0;
        ep->timeouts[SCTP_EVENT_TIMEOUT_T4_RTO] = 0;
 
 
        /* sctpimpguide-05 Section 2.12.2
        /* sctpimpguide-05 Section 2.12.2
         * If the 'T5-shutdown-guard' timer is used, it SHOULD be set to the
         * If the 'T5-shutdown-guard' timer is used, it SHOULD be set to the
         * recommended value of 5 times 'RTO.Max'.
         * recommended value of 5 times 'RTO.Max'.
         */
         */
        ep->timeouts[SCTP_EVENT_TIMEOUT_T5_SHUTDOWN_GUARD]
        ep->timeouts[SCTP_EVENT_TIMEOUT_T5_SHUTDOWN_GUARD]
                = 5 * SCTP_MSECS_TO_JIFFIES(sp->rtoinfo.srto_max);
                = 5 * SCTP_MSECS_TO_JIFFIES(sp->rtoinfo.srto_max);
 
 
        ep->timeouts[SCTP_EVENT_TIMEOUT_HEARTBEAT] =
        ep->timeouts[SCTP_EVENT_TIMEOUT_HEARTBEAT] =
                SCTP_DEFAULT_TIMEOUT_HEARTBEAT;
                SCTP_DEFAULT_TIMEOUT_HEARTBEAT;
        ep->timeouts[SCTP_EVENT_TIMEOUT_SACK] =
        ep->timeouts[SCTP_EVENT_TIMEOUT_SACK] =
                SCTP_DEFAULT_TIMEOUT_SACK;
                SCTP_DEFAULT_TIMEOUT_SACK;
        ep->timeouts[SCTP_EVENT_TIMEOUT_AUTOCLOSE] =
        ep->timeouts[SCTP_EVENT_TIMEOUT_AUTOCLOSE] =
                sp->autoclose * HZ;
                sp->autoclose * HZ;
 
 
        /* Use SCTP specific send buffer space queues.  */
        /* Use SCTP specific send buffer space queues.  */
        sk->sk_write_space = sctp_write_space;
        sk->sk_write_space = sctp_write_space;
        sk->sk_use_write_queue = 1;
        sk->sk_use_write_queue = 1;
 
 
        /* Initialize the secret key used with cookie. */
        /* Initialize the secret key used with cookie. */
        get_random_bytes(&ep->secret_key[0], SCTP_SECRET_SIZE);
        get_random_bytes(&ep->secret_key[0], SCTP_SECRET_SIZE);
        ep->last_key = ep->current_key = 0;
        ep->last_key = ep->current_key = 0;
        ep->key_changed_at = jiffies;
        ep->key_changed_at = jiffies;
 
 
        ep->debug_name = "unnamedEndpoint";
        ep->debug_name = "unnamedEndpoint";
        return ep;
        return ep;
}
}
 
 
/* Add an association to an endpoint.  */
/* Add an association to an endpoint.  */
void sctp_endpoint_add_asoc(struct sctp_endpoint *ep,
void sctp_endpoint_add_asoc(struct sctp_endpoint *ep,
                            struct sctp_association *asoc)
                            struct sctp_association *asoc)
{
{
        struct sock *sk = ep->base.sk;
        struct sock *sk = ep->base.sk;
 
 
        /* Now just add it to our list of asocs */
        /* Now just add it to our list of asocs */
        list_add_tail(&asoc->asocs, &ep->asocs);
        list_add_tail(&asoc->asocs, &ep->asocs);
 
 
        /* Increment the backlog value for a TCP-style listening socket. */
        /* Increment the backlog value for a TCP-style listening socket. */
        if (sctp_style(sk, TCP) && sctp_sstate(sk, LISTENING))
        if (sctp_style(sk, TCP) && sctp_sstate(sk, LISTENING))
                sk->sk_ack_backlog++;
                sk->sk_ack_backlog++;
}
}
 
 
/* Free the endpoint structure.  Delay cleanup until
/* Free the endpoint structure.  Delay cleanup until
 * all users have released their reference count on this structure.
 * all users have released their reference count on this structure.
 */
 */
void sctp_endpoint_free(struct sctp_endpoint *ep)
void sctp_endpoint_free(struct sctp_endpoint *ep)
{
{
        ep->base.dead = 1;
        ep->base.dead = 1;
        sctp_endpoint_put(ep);
        sctp_endpoint_put(ep);
}
}
 
 
/* Final destructor for endpoint.  */
/* Final destructor for endpoint.  */
void sctp_endpoint_destroy(struct sctp_endpoint *ep)
void sctp_endpoint_destroy(struct sctp_endpoint *ep)
{
{
        SCTP_ASSERT(ep->base.dead, "Endpoint is not dead", return);
        SCTP_ASSERT(ep->base.dead, "Endpoint is not dead", return);
 
 
        ep->base.sk->sk_state = SCTP_SS_CLOSED;
        ep->base.sk->sk_state = SCTP_SS_CLOSED;
 
 
        /* Unlink this endpoint, so we can't find it again! */
        /* Unlink this endpoint, so we can't find it again! */
        sctp_unhash_endpoint(ep);
        sctp_unhash_endpoint(ep);
 
 
        /* Free up the HMAC transform. */
        /* Free up the HMAC transform. */
        if (sctp_sk(ep->base.sk)->hmac)
        if (sctp_sk(ep->base.sk)->hmac)
                sctp_crypto_free_tfm(sctp_sk(ep->base.sk)->hmac);
                sctp_crypto_free_tfm(sctp_sk(ep->base.sk)->hmac);
 
 
        /* Cleanup. */
        /* Cleanup. */
        sctp_inq_free(&ep->base.inqueue);
        sctp_inq_free(&ep->base.inqueue);
        sctp_bind_addr_free(&ep->base.bind_addr);
        sctp_bind_addr_free(&ep->base.bind_addr);
 
 
        /* Remove and free the port */
        /* Remove and free the port */
        if (ep->base.sk->prev != NULL)
        if (ep->base.sk->prev != NULL)
                sctp_put_port(ep->base.sk);
                sctp_put_port(ep->base.sk);
 
 
        /* Give up our hold on the sock. */
        /* Give up our hold on the sock. */
        if (ep->base.sk)
        if (ep->base.sk)
                sock_put(ep->base.sk);
                sock_put(ep->base.sk);
 
 
        /* Finally, free up our memory. */
        /* Finally, free up our memory. */
        if (ep->base.malloced) {
        if (ep->base.malloced) {
                kfree(ep);
                kfree(ep);
                SCTP_DBG_OBJCNT_DEC(ep);
                SCTP_DBG_OBJCNT_DEC(ep);
        }
        }
}
}
 
 
/* Hold a reference to an endpoint. */
/* Hold a reference to an endpoint. */
void sctp_endpoint_hold(struct sctp_endpoint *ep)
void sctp_endpoint_hold(struct sctp_endpoint *ep)
{
{
        atomic_inc(&ep->base.refcnt);
        atomic_inc(&ep->base.refcnt);
}
}
 
 
/* Release a reference to an endpoint and clean up if there are
/* Release a reference to an endpoint and clean up if there are
 * no more references.
 * no more references.
 */
 */
void sctp_endpoint_put(struct sctp_endpoint *ep)
void sctp_endpoint_put(struct sctp_endpoint *ep)
{
{
        if (atomic_dec_and_test(&ep->base.refcnt))
        if (atomic_dec_and_test(&ep->base.refcnt))
                sctp_endpoint_destroy(ep);
                sctp_endpoint_destroy(ep);
}
}
 
 
/* Is this the endpoint we are looking for?  */
/* Is this the endpoint we are looking for?  */
struct sctp_endpoint *sctp_endpoint_is_match(struct sctp_endpoint *ep,
struct sctp_endpoint *sctp_endpoint_is_match(struct sctp_endpoint *ep,
                                               const union sctp_addr *laddr)
                                               const union sctp_addr *laddr)
{
{
        struct sctp_endpoint *retval;
        struct sctp_endpoint *retval;
 
 
        sctp_read_lock(&ep->base.addr_lock);
        sctp_read_lock(&ep->base.addr_lock);
        if (ep->base.bind_addr.port == laddr->v4.sin_port) {
        if (ep->base.bind_addr.port == laddr->v4.sin_port) {
                if (sctp_bind_addr_match(&ep->base.bind_addr, laddr,
                if (sctp_bind_addr_match(&ep->base.bind_addr, laddr,
                                         sctp_sk(ep->base.sk))) {
                                         sctp_sk(ep->base.sk))) {
                        retval = ep;
                        retval = ep;
                        goto out;
                        goto out;
                }
                }
        }
        }
 
 
        retval = NULL;
        retval = NULL;
 
 
out:
out:
        sctp_read_unlock(&ep->base.addr_lock);
        sctp_read_unlock(&ep->base.addr_lock);
        return retval;
        return retval;
}
}
 
 
/* Find the association that goes with this chunk.
/* Find the association that goes with this chunk.
 * We do a linear search of the associations for this endpoint.
 * We do a linear search of the associations for this endpoint.
 * We return the matching transport address too.
 * We return the matching transport address too.
 */
 */
struct sctp_association *__sctp_endpoint_lookup_assoc(
struct sctp_association *__sctp_endpoint_lookup_assoc(
        const struct sctp_endpoint *ep,
        const struct sctp_endpoint *ep,
        const union sctp_addr *paddr,
        const union sctp_addr *paddr,
        struct sctp_transport **transport)
        struct sctp_transport **transport)
{
{
        int rport;
        int rport;
        struct sctp_association *asoc;
        struct sctp_association *asoc;
        struct list_head *pos;
        struct list_head *pos;
 
 
        rport = paddr->v4.sin_port;
        rport = paddr->v4.sin_port;
 
 
        list_for_each(pos, &ep->asocs) {
        list_for_each(pos, &ep->asocs) {
                asoc = list_entry(pos, struct sctp_association, asocs);
                asoc = list_entry(pos, struct sctp_association, asocs);
                if (rport == asoc->peer.port) {
                if (rport == asoc->peer.port) {
                        sctp_read_lock(&asoc->base.addr_lock);
                        sctp_read_lock(&asoc->base.addr_lock);
                        *transport = sctp_assoc_lookup_paddr(asoc, paddr);
                        *transport = sctp_assoc_lookup_paddr(asoc, paddr);
                        sctp_read_unlock(&asoc->base.addr_lock);
                        sctp_read_unlock(&asoc->base.addr_lock);
 
 
                        if (*transport)
                        if (*transport)
                                return asoc;
                                return asoc;
                }
                }
        }
        }
 
 
        *transport = NULL;
        *transport = NULL;
        return NULL;
        return NULL;
}
}
 
 
/* Lookup association on an endpoint based on a peer address.  BH-safe.  */
/* Lookup association on an endpoint based on a peer address.  BH-safe.  */
struct sctp_association *sctp_endpoint_lookup_assoc(
struct sctp_association *sctp_endpoint_lookup_assoc(
        const struct sctp_endpoint *ep,
        const struct sctp_endpoint *ep,
        const union sctp_addr *paddr,
        const union sctp_addr *paddr,
        struct sctp_transport **transport)
        struct sctp_transport **transport)
{
{
        struct sctp_association *asoc;
        struct sctp_association *asoc;
 
 
        sctp_local_bh_disable();
        sctp_local_bh_disable();
        asoc = __sctp_endpoint_lookup_assoc(ep, paddr, transport);
        asoc = __sctp_endpoint_lookup_assoc(ep, paddr, transport);
        sctp_local_bh_enable();
        sctp_local_bh_enable();
 
 
        return asoc;
        return asoc;
}
}
 
 
/* Look for any peeled off association from the endpoint that matches the
/* Look for any peeled off association from the endpoint that matches the
 * given peer address.
 * given peer address.
 */
 */
int sctp_endpoint_is_peeled_off(struct sctp_endpoint *ep,
int sctp_endpoint_is_peeled_off(struct sctp_endpoint *ep,
                                const union sctp_addr *paddr)
                                const union sctp_addr *paddr)
{
{
        struct list_head *pos;
        struct list_head *pos;
        struct sctp_sockaddr_entry *addr;
        struct sctp_sockaddr_entry *addr;
        struct sctp_bind_addr *bp;
        struct sctp_bind_addr *bp;
 
 
        sctp_read_lock(&ep->base.addr_lock);
        sctp_read_lock(&ep->base.addr_lock);
        bp = &ep->base.bind_addr;
        bp = &ep->base.bind_addr;
        list_for_each(pos, &bp->address_list) {
        list_for_each(pos, &bp->address_list) {
                addr = list_entry(pos, struct sctp_sockaddr_entry, list);
                addr = list_entry(pos, struct sctp_sockaddr_entry, list);
                if (sctp_has_association(&addr->a, paddr)) {
                if (sctp_has_association(&addr->a, paddr)) {
                        sctp_read_unlock(&ep->base.addr_lock);
                        sctp_read_unlock(&ep->base.addr_lock);
                        return 1;
                        return 1;
                }
                }
        }
        }
        sctp_read_unlock(&ep->base.addr_lock);
        sctp_read_unlock(&ep->base.addr_lock);
 
 
        return 0;
        return 0;
}
}
 
 
/* Do delayed input processing.  This is scheduled by sctp_rcv().
/* Do delayed input processing.  This is scheduled by sctp_rcv().
 * This may be called on BH or task time.
 * This may be called on BH or task time.
 */
 */
static void sctp_endpoint_bh_rcv(struct sctp_endpoint *ep)
static void sctp_endpoint_bh_rcv(struct sctp_endpoint *ep)
{
{
        struct sctp_association *asoc;
        struct sctp_association *asoc;
        struct sock *sk;
        struct sock *sk;
        struct sctp_transport *transport;
        struct sctp_transport *transport;
        struct sctp_chunk *chunk;
        struct sctp_chunk *chunk;
        struct sctp_inq *inqueue;
        struct sctp_inq *inqueue;
        sctp_subtype_t subtype;
        sctp_subtype_t subtype;
        sctp_state_t state;
        sctp_state_t state;
        int error = 0;
        int error = 0;
 
 
        if (ep->base.dead)
        if (ep->base.dead)
                return;
                return;
 
 
        asoc = NULL;
        asoc = NULL;
        inqueue = &ep->base.inqueue;
        inqueue = &ep->base.inqueue;
        sk = ep->base.sk;
        sk = ep->base.sk;
 
 
        while (NULL != (chunk = sctp_inq_pop(inqueue))) {
        while (NULL != (chunk = sctp_inq_pop(inqueue))) {
                subtype.chunk = chunk->chunk_hdr->type;
                subtype.chunk = chunk->chunk_hdr->type;
 
 
                /* We might have grown an association since last we
                /* We might have grown an association since last we
                 * looked, so try again.
                 * looked, so try again.
                 *
                 *
                 * This happens when we've just processed our
                 * This happens when we've just processed our
                 * COOKIE-ECHO chunk.
                 * COOKIE-ECHO chunk.
                 */
                 */
                if (NULL == chunk->asoc) {
                if (NULL == chunk->asoc) {
                        asoc = sctp_endpoint_lookup_assoc(ep,
                        asoc = sctp_endpoint_lookup_assoc(ep,
                                                          sctp_source(chunk),
                                                          sctp_source(chunk),
                                                          &transport);
                                                          &transport);
                        chunk->asoc = asoc;
                        chunk->asoc = asoc;
                        chunk->transport = transport;
                        chunk->transport = transport;
                }
                }
 
 
                state = asoc ? asoc->state : SCTP_STATE_CLOSED;
                state = asoc ? asoc->state : SCTP_STATE_CLOSED;
 
 
                /* Remember where the last DATA chunk came from so we
                /* Remember where the last DATA chunk came from so we
                 * know where to send the SACK.
                 * know where to send the SACK.
                 */
                 */
                if (asoc && sctp_chunk_is_data(chunk))
                if (asoc && sctp_chunk_is_data(chunk))
                        asoc->peer.last_data_from = chunk->transport;
                        asoc->peer.last_data_from = chunk->transport;
                else
                else
                        SCTP_INC_STATS(SctpInCtrlChunks);
                        SCTP_INC_STATS(SctpInCtrlChunks);
 
 
                if (chunk->transport)
                if (chunk->transport)
                        chunk->transport->last_time_heard = jiffies;
                        chunk->transport->last_time_heard = jiffies;
 
 
                error = sctp_do_sm(SCTP_EVENT_T_CHUNK, subtype, state,
                error = sctp_do_sm(SCTP_EVENT_T_CHUNK, subtype, state,
                                   ep, asoc, chunk, GFP_ATOMIC);
                                   ep, asoc, chunk, GFP_ATOMIC);
 
 
                if (error && chunk)
                if (error && chunk)
                        chunk->pdiscard = 1;
                        chunk->pdiscard = 1;
 
 
                /* Check to see if the endpoint is freed in response to
                /* Check to see if the endpoint is freed in response to
                 * the incoming chunk. If so, get out of the while loop.
                 * the incoming chunk. If so, get out of the while loop.
                 */
                 */
                if (!sctp_sk(sk)->ep)
                if (!sctp_sk(sk)->ep)
                        break;
                        break;
        }
        }
}
}
 
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.