]> err.no Git - linux-2.6/blobdiff - net/sctp/associola.c
the scheduled ieee80211 softmac removal
[linux-2.6] / net / sctp / associola.c
index 61bebb9b96e678bdf2dc8863245d77735d78779d..422c98aa9d5cd0b7b6fcb1d4713b28b94ae9f0b3 100644 (file)
@@ -1,21 +1,21 @@
-/* SCTP kernel reference Implementation
+/* SCTP kernel implementation
  * (C) Copyright IBM Corp. 2001, 2004
  * Copyright (c) 1999-2000 Cisco, Inc.
  * Copyright (c) 1999-2001 Motorola, Inc.
  * Copyright (c) 2001 Intel Corp.
  * 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 implementation
  *
  * This module provides the abstraction for an SCTP association.
  *
- * The SCTP reference implementation is free software;
+ * This SCTP implementation 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, or (at your option)
  * any later version.
  *
- * The SCTP reference implementation is distributed in the hope that it
+ * This SCTP implementation 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.
@@ -61,6 +61,7 @@
 
 /* Forward declarations for internal functions. */
 static void sctp_assoc_bh_rcv(struct work_struct *work);
+static void sctp_assoc_free_asconf_acks(struct sctp_association *asoc);
 
 
 /* 1st Level Abstractions. */
@@ -242,6 +243,7 @@ static struct sctp_association *sctp_association_init(struct sctp_association *a
        asoc->addip_serial = asoc->c.initial_tsn;
 
        INIT_LIST_HEAD(&asoc->addip_chunk_list);
+       INIT_LIST_HEAD(&asoc->asconf_ack_list);
 
        /* Make an empty list of remote transport addresses.  */
        INIT_LIST_HEAD(&asoc->peer.transport_addr_list);
@@ -431,8 +433,7 @@ void sctp_association_free(struct sctp_association *asoc)
        asoc->peer.transport_count = 0;
 
        /* Free any cached ASCONF_ACK chunk. */
-       if (asoc->addip_last_asconf_ack)
-               sctp_chunk_free(asoc->addip_last_asconf_ack);
+       sctp_assoc_free_asconf_acks(asoc);
 
        /* Free any cached ASCONF chunk. */
        if (asoc->addip_last_asconf)
@@ -1329,7 +1330,7 @@ void sctp_assoc_sync_pmtu(struct sctp_association *asoc)
        }
 
        SCTP_DEBUG_PRINTK("%s: asoc:%p, pmtu:%d, frag_point:%d\n",
-                         __FUNCTION__, asoc, asoc->pathmtu, asoc->frag_point);
+                         __func__, asoc, asoc->pathmtu, asoc->frag_point);
 }
 
 /* Should we send a SACK to update our peer? */
@@ -1369,7 +1370,7 @@ void sctp_assoc_rwnd_increase(struct sctp_association *asoc, unsigned len)
        }
 
        SCTP_DEBUG_PRINTK("%s: asoc %p rwnd increased by %d to (%u, %u) "
-                         "- %u\n", __FUNCTION__, asoc, len, asoc->rwnd,
+                         "- %u\n", __func__, asoc, len, asoc->rwnd,
                          asoc->rwnd_over, asoc->a_rwnd);
 
        /* Send a window update SACK if the rwnd has increased by at least the
@@ -1380,7 +1381,7 @@ void sctp_assoc_rwnd_increase(struct sctp_association *asoc, unsigned len)
        if (sctp_peer_needs_update(asoc)) {
                asoc->a_rwnd = asoc->rwnd;
                SCTP_DEBUG_PRINTK("%s: Sending window update SACK- asoc: %p "
-                                 "rwnd: %u a_rwnd: %u\n", __FUNCTION__,
+                                 "rwnd: %u a_rwnd: %u\n", __func__,
                                  asoc, asoc->rwnd, asoc->a_rwnd);
                sack = sctp_make_sack(asoc);
                if (!sack)
@@ -1409,7 +1410,7 @@ void sctp_assoc_rwnd_decrease(struct sctp_association *asoc, unsigned len)
                asoc->rwnd = 0;
        }
        SCTP_DEBUG_PRINTK("%s: asoc %p rwnd decreased by %d to (%u, %u)\n",
-                         __FUNCTION__, asoc, len, asoc->rwnd,
+                         __func__, asoc, len, asoc->rwnd,
                          asoc->rwnd_over);
 }
 
@@ -1485,3 +1486,56 @@ retry:
        asoc->assoc_id = (sctp_assoc_t) assoc_id;
        return error;
 }
+
+/* Free asconf_ack cache */
+static void sctp_assoc_free_asconf_acks(struct sctp_association *asoc)
+{
+       struct sctp_chunk *ack;
+       struct sctp_chunk *tmp;
+
+       list_for_each_entry_safe(ack, tmp, &asoc->asconf_ack_list,
+                               transmitted_list) {
+               list_del_init(&ack->transmitted_list);
+               sctp_chunk_free(ack);
+       }
+}
+
+/* Clean up the ASCONF_ACK queue */
+void sctp_assoc_clean_asconf_ack_cache(const struct sctp_association *asoc)
+{
+       struct sctp_chunk *ack;
+       struct sctp_chunk *tmp;
+
+       /* We can remove all the entries from the queue upto
+        * the "Peer-Sequence-Number".
+        */
+       list_for_each_entry_safe(ack, tmp, &asoc->asconf_ack_list,
+                               transmitted_list) {
+               if (ack->subh.addip_hdr->serial ==
+                               htonl(asoc->peer.addip_serial))
+                       break;
+
+               list_del_init(&ack->transmitted_list);
+               sctp_chunk_free(ack);
+       }
+}
+
+/* Find the ASCONF_ACK whose serial number matches ASCONF */
+struct sctp_chunk *sctp_assoc_lookup_asconf_ack(
+                                       const struct sctp_association *asoc,
+                                       __be32 serial)
+{
+       struct sctp_chunk *ack;
+
+       /* Walk through the list of cached ASCONF-ACKs and find the
+        * ack chunk whose serial number matches that of the request.
+        */
+       list_for_each_entry(ack, &asoc->asconf_ack_list, transmitted_list) {
+               if (ack->subh.addip_hdr->serial == serial) {
+                       sctp_chunk_hold(ack);
+                       return ack;
+               }
+       }
+
+       return NULL;
+}