The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/netinet/sctp_var.h

Version: -  FREEBSD  -  FREEBSD11  -  FREEBSD10  -  FREEBSD9  -  FREEBSD92  -  FREEBSD91  -  FREEBSD90  -  FREEBSD8  -  FREEBSD82  -  FREEBSD81  -  FREEBSD80  -  FREEBSD7  -  FREEBSD74  -  FREEBSD73  -  FREEBSD72  -  FREEBSD71  -  FREEBSD70  -  FREEBSD6  -  FREEBSD64  -  FREEBSD63  -  FREEBSD62  -  FREEBSD61  -  FREEBSD60  -  FREEBSD5  -  FREEBSD55  -  FREEBSD54  -  FREEBSD53  -  FREEBSD52  -  FREEBSD51  -  FREEBSD50  -  FREEBSD4  -  FREEBSD3  -  FREEBSD22  -  linux-2.6  -  linux-2.4.22  -  MK83  -  MK84  -  PLAN9  -  DFBSD  -  NETBSD  -  NETBSD5  -  NETBSD4  -  NETBSD3  -  NETBSD20  -  OPENBSD  -  xnu-517  -  xnu-792  -  xnu-792.6.70  -  xnu-1228  -  xnu-1456.1.26  -  xnu-1699.24.8  -  xnu-2050.18.24  -  OPENSOLARIS  -  minix-3-1-1 
SearchContext: -  none  -  3  -  10 

    1 /*-
    2  * Copyright (c) 2001-2008, by Cisco Systems, Inc. All rights reserved.
    3  *
    4  * Redistribution and use in source and binary forms, with or without
    5  * modification, are permitted provided that the following conditions are met:
    6  *
    7  * a) Redistributions of source code must retain the above copyright notice,
    8  *   this list of conditions and the following disclaimer.
    9  *
   10  * b) Redistributions in binary form must reproduce the above copyright
   11  *    notice, this list of conditions and the following disclaimer in
   12  *   the documentation and/or other materials provided with the distribution.
   13  *
   14  * c) Neither the name of Cisco Systems, Inc. nor the names of its
   15  *    contributors may be used to endorse or promote products derived
   16  *    from this software without specific prior written permission.
   17  *
   18  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
   19  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
   20  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
   21  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
   22  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
   23  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
   24  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
   25  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
   26  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
   27  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
   28  * THE POSSIBILITY OF SUCH DAMAGE.
   29  */
   30 
   31 /* $KAME: sctp_var.h,v 1.24 2005/03/06 16:04:19 itojun Exp $     */
   32 
   33 #include <sys/cdefs.h>
   34 __FBSDID("$FreeBSD: releng/8.2/sys/netinet/sctp_var.h 206742 2010-04-17 04:15:46Z rrs $");
   35 
   36 #ifndef _NETINET_SCTP_VAR_H_
   37 #define _NETINET_SCTP_VAR_H_
   38 
   39 #include <netinet/sctp_uio.h>
   40 
   41 #if defined(_KERNEL) || defined(__Userspace__)
   42 
   43 extern struct pr_usrreqs sctp_usrreqs;
   44 
   45 
   46 #define sctp_feature_on(inp, feature)  (inp->sctp_features |= feature)
   47 #define sctp_feature_off(inp, feature) (inp->sctp_features &= ~feature)
   48 #define sctp_is_feature_on(inp, feature) ((inp->sctp_features & feature) == feature)
   49 #define sctp_is_feature_off(inp, feature) ((inp->sctp_features & feature) == 0)
   50 
   51 
   52 /* managing mobility_feature in inpcb (by micchie) */
   53 #define sctp_mobility_feature_on(inp, feature)  (inp->sctp_mobility_features |= feature)
   54 #define sctp_mobility_feature_off(inp, feature) (inp->sctp_mobility_features &= ~feature)
   55 #define sctp_is_mobility_feature_on(inp, feature) (inp->sctp_mobility_features & feature)
   56 #define sctp_is_mobility_feature_off(inp, feature) ((inp->sctp_mobility_features & feature) == 0)
   57 
   58 #define sctp_maxspace(sb) (max((sb)->sb_hiwat,SCTP_MINIMAL_RWND))
   59 
   60 #define sctp_sbspace(asoc, sb) ((long) ((sctp_maxspace(sb) > (asoc)->sb_cc) ? (sctp_maxspace(sb) - (asoc)->sb_cc) : 0))
   61 
   62 #define sctp_sbspace_failedmsgs(sb) ((long) ((sctp_maxspace(sb) > (sb)->sb_cc) ? (sctp_maxspace(sb) - (sb)->sb_cc) : 0))
   63 
   64 #define sctp_sbspace_sub(a,b) ((a > b) ? (a - b) : 0)
   65 
   66 /*
   67  * I tried to cache the readq entries at one point. But the reality
   68  * is that it did not add any performance since this meant we had to
   69  * lock the STCB on read. And at that point once you have to do an
   70  * extra lock, it really does not matter if the lock is in the ZONE
   71  * stuff or in our code. Note that this same problem would occur with
   72  * an mbuf cache as well so it is not really worth doing, at least
   73  * right now :-D
   74  */
   75 
   76 #define sctp_free_a_readq(_stcb, _readq) { \
   77         SCTP_ZONE_FREE(SCTP_BASE_INFO(ipi_zone_readq), (_readq)); \
   78         SCTP_DECR_READQ_COUNT(); \
   79 }
   80 
   81 #define sctp_alloc_a_readq(_stcb, _readq) { \
   82         (_readq) = SCTP_ZONE_GET(SCTP_BASE_INFO(ipi_zone_readq), struct sctp_queued_to_read); \
   83         if ((_readq)) { \
   84              SCTP_INCR_READQ_COUNT(); \
   85         } \
   86 }
   87 
   88 #define sctp_free_a_strmoq(_stcb, _strmoq) { \
   89         if ((_strmoq)->holds_key_ref) { \
   90                 sctp_auth_key_release(stcb, sp->auth_keyid); \
   91                 (_strmoq)->holds_key_ref = 0; \
   92         } \
   93         SCTP_ZONE_FREE(SCTP_BASE_INFO(ipi_zone_strmoq), (_strmoq)); \
   94         SCTP_DECR_STRMOQ_COUNT(); \
   95 }
   96 
   97 #define sctp_alloc_a_strmoq(_stcb, _strmoq) { \
   98         (_strmoq) = SCTP_ZONE_GET(SCTP_BASE_INFO(ipi_zone_strmoq), struct sctp_stream_queue_pending); \
   99          if ((_strmoq)) {                         \
  100                 memset(_strmoq, 0, sizeof(struct sctp_stream_queue_pending)); \
  101                 SCTP_INCR_STRMOQ_COUNT(); \
  102                 (_strmoq)->holds_key_ref = 0; \
  103         } \
  104 }
  105 
  106 #define sctp_free_a_chunk(_stcb, _chk) { \
  107         if ((_chk)->holds_key_ref) {\
  108                 sctp_auth_key_release((_stcb), (_chk)->auth_keyid); \
  109                 (_chk)->holds_key_ref = 0; \
  110         } \
  111         if (_stcb) { \
  112           SCTP_TCB_LOCK_ASSERT((_stcb)); \
  113           if ((_chk)->whoTo) { \
  114                   sctp_free_remote_addr((_chk)->whoTo); \
  115                   (_chk)->whoTo = NULL; \
  116           } \
  117           if (((_stcb)->asoc.free_chunk_cnt > SCTP_BASE_SYSCTL(sctp_asoc_free_resc_limit)) || \
  118                (SCTP_BASE_INFO(ipi_free_chunks) > SCTP_BASE_SYSCTL(sctp_system_free_resc_limit))) { \
  119                 SCTP_ZONE_FREE(SCTP_BASE_INFO(ipi_zone_chunk), (_chk)); \
  120                 SCTP_DECR_CHK_COUNT(); \
  121           } else { \
  122                 TAILQ_INSERT_TAIL(&(_stcb)->asoc.free_chunks, (_chk), sctp_next); \
  123                 (_stcb)->asoc.free_chunk_cnt++; \
  124                 atomic_add_int(&SCTP_BASE_INFO(ipi_free_chunks), 1); \
  125           } \
  126         } else { \
  127                 SCTP_ZONE_FREE(SCTP_BASE_INFO(ipi_zone_chunk), (_chk)); \
  128                 SCTP_DECR_CHK_COUNT(); \
  129         } \
  130 }
  131 
  132 #define sctp_alloc_a_chunk(_stcb, _chk) { \
  133         if (TAILQ_EMPTY(&(_stcb)->asoc.free_chunks))  { \
  134                 (_chk) = SCTP_ZONE_GET(SCTP_BASE_INFO(ipi_zone_chunk), struct sctp_tmit_chunk); \
  135                 if ((_chk)) { \
  136                         SCTP_INCR_CHK_COUNT(); \
  137                         (_chk)->whoTo = NULL; \
  138                         (_chk)->holds_key_ref = 0; \
  139                 } \
  140         } else { \
  141                 (_chk) = TAILQ_FIRST(&(_stcb)->asoc.free_chunks); \
  142                 TAILQ_REMOVE(&(_stcb)->asoc.free_chunks, (_chk), sctp_next); \
  143                 atomic_subtract_int(&SCTP_BASE_INFO(ipi_free_chunks), 1); \
  144                 (_chk)->holds_key_ref = 0; \
  145                 SCTP_STAT_INCR(sctps_cached_chk); \
  146                 (_stcb)->asoc.free_chunk_cnt--; \
  147         } \
  148 }
  149 
  150 
  151 #define sctp_free_remote_addr(__net) { \
  152         if ((__net)) {  \
  153                 if (SCTP_DECREMENT_AND_CHECK_REFCOUNT(&(__net)->ref_count)) { \
  154                         (void)SCTP_OS_TIMER_STOP(&(__net)->rxt_timer.timer); \
  155                         (void)SCTP_OS_TIMER_STOP(&(__net)->pmtu_timer.timer); \
  156                         (void)SCTP_OS_TIMER_STOP(&(__net)->fr_timer.timer); \
  157                         if ((__net)->ro.ro_rt) { \
  158                                 RTFREE((__net)->ro.ro_rt); \
  159                                 (__net)->ro.ro_rt = NULL; \
  160                         } \
  161                         if ((__net)->src_addr_selected) { \
  162                                 sctp_free_ifa((__net)->ro._s_addr); \
  163                                 (__net)->ro._s_addr = NULL; \
  164                         } \
  165                         (__net)->src_addr_selected = 0; \
  166                         (__net)->dest_state = SCTP_ADDR_NOT_REACHABLE; \
  167                         SCTP_ZONE_FREE(SCTP_BASE_INFO(ipi_zone_net), (__net)); \
  168                         SCTP_DECR_RADDR_COUNT(); \
  169                 } \
  170         } \
  171 }
  172 
  173 #define sctp_sbfree(ctl, stcb, sb, m) { \
  174         SCTP_SAVE_ATOMIC_DECREMENT(&(sb)->sb_cc, SCTP_BUF_LEN((m))); \
  175         SCTP_SAVE_ATOMIC_DECREMENT(&(sb)->sb_mbcnt, MSIZE); \
  176         if (((ctl)->do_not_ref_stcb == 0) && stcb) {\
  177                 SCTP_SAVE_ATOMIC_DECREMENT(&(stcb)->asoc.sb_cc, SCTP_BUF_LEN((m))); \
  178                 SCTP_SAVE_ATOMIC_DECREMENT(&(stcb)->asoc.my_rwnd_control_len, MSIZE); \
  179         } \
  180         if (SCTP_BUF_TYPE(m) != MT_DATA && SCTP_BUF_TYPE(m) != MT_HEADER && \
  181             SCTP_BUF_TYPE(m) != MT_OOBDATA) \
  182                 atomic_subtract_int(&(sb)->sb_ctl,SCTP_BUF_LEN((m))); \
  183 }
  184 
  185 #define sctp_sballoc(stcb, sb, m) { \
  186         atomic_add_int(&(sb)->sb_cc,SCTP_BUF_LEN((m))); \
  187         atomic_add_int(&(sb)->sb_mbcnt, MSIZE); \
  188         if (stcb) { \
  189                 atomic_add_int(&(stcb)->asoc.sb_cc,SCTP_BUF_LEN((m))); \
  190                 atomic_add_int(&(stcb)->asoc.my_rwnd_control_len, MSIZE); \
  191         } \
  192         if (SCTP_BUF_TYPE(m) != MT_DATA && SCTP_BUF_TYPE(m) != MT_HEADER && \
  193             SCTP_BUF_TYPE(m) != MT_OOBDATA) \
  194                 atomic_add_int(&(sb)->sb_ctl,SCTP_BUF_LEN((m))); \
  195 }
  196 
  197 
  198 #define sctp_ucount_incr(val) { \
  199         val++; \
  200 }
  201 
  202 #define sctp_ucount_decr(val) { \
  203         if (val > 0) { \
  204                 val--; \
  205         } else { \
  206                 val = 0; \
  207         } \
  208 }
  209 
  210 #define sctp_mbuf_crush(data) do { \
  211         struct mbuf *_m; \
  212         _m = (data); \
  213         while(_m && (SCTP_BUF_LEN(_m) == 0)) { \
  214                 (data)  = SCTP_BUF_NEXT(_m); \
  215                 SCTP_BUF_NEXT(_m) = NULL; \
  216                 sctp_m_free(_m); \
  217                 _m = (data); \
  218         } \
  219 } while (0)
  220 
  221 #define sctp_flight_size_decrease(tp1) do { \
  222         if (tp1->whoTo->flight_size >= tp1->book_size) \
  223                 tp1->whoTo->flight_size -= tp1->book_size; \
  224         else \
  225                 tp1->whoTo->flight_size = 0; \
  226 } while (0)
  227 
  228 #define sctp_flight_size_increase(tp1) do { \
  229        (tp1)->whoTo->flight_size += (tp1)->book_size; \
  230 } while (0)
  231 
  232 #ifdef SCTP_FS_SPEC_LOG
  233 #define sctp_total_flight_decrease(stcb, tp1) do { \
  234         if (stcb->asoc.fs_index > SCTP_FS_SPEC_LOG_SIZE) \
  235                 stcb->asoc.fs_index = 0;\
  236         stcb->asoc.fslog[stcb->asoc.fs_index].total_flight = stcb->asoc.total_flight; \
  237         stcb->asoc.fslog[stcb->asoc.fs_index].tsn = tp1->rec.data.TSN_seq; \
  238         stcb->asoc.fslog[stcb->asoc.fs_index].book = tp1->book_size; \
  239         stcb->asoc.fslog[stcb->asoc.fs_index].sent = tp1->sent; \
  240         stcb->asoc.fslog[stcb->asoc.fs_index].incr = 0; \
  241         stcb->asoc.fslog[stcb->asoc.fs_index].decr = 1; \
  242         stcb->asoc.fs_index++; \
  243         tp1->window_probe = 0; \
  244         if (stcb->asoc.total_flight >= tp1->book_size) { \
  245                 stcb->asoc.total_flight -= tp1->book_size; \
  246                 if (stcb->asoc.total_flight_count > 0) \
  247                         stcb->asoc.total_flight_count--; \
  248         } else { \
  249                 stcb->asoc.total_flight = 0; \
  250                 stcb->asoc.total_flight_count = 0; \
  251         } \
  252 } while (0)
  253 
  254 #define sctp_total_flight_increase(stcb, tp1) do { \
  255         if (stcb->asoc.fs_index > SCTP_FS_SPEC_LOG_SIZE) \
  256                 stcb->asoc.fs_index = 0;\
  257         stcb->asoc.fslog[stcb->asoc.fs_index].total_flight = stcb->asoc.total_flight; \
  258         stcb->asoc.fslog[stcb->asoc.fs_index].tsn = tp1->rec.data.TSN_seq; \
  259         stcb->asoc.fslog[stcb->asoc.fs_index].book = tp1->book_size; \
  260         stcb->asoc.fslog[stcb->asoc.fs_index].sent = tp1->sent; \
  261         stcb->asoc.fslog[stcb->asoc.fs_index].incr = 1; \
  262         stcb->asoc.fslog[stcb->asoc.fs_index].decr = 0; \
  263         stcb->asoc.fs_index++; \
  264        (stcb)->asoc.total_flight_count++; \
  265        (stcb)->asoc.total_flight += (tp1)->book_size; \
  266 } while (0)
  267 
  268 #else
  269 
  270 #define sctp_total_flight_decrease(stcb, tp1) do { \
  271         tp1->window_probe = 0; \
  272         if (stcb->asoc.total_flight >= tp1->book_size) { \
  273                 stcb->asoc.total_flight -= tp1->book_size; \
  274                 if (stcb->asoc.total_flight_count > 0) \
  275                         stcb->asoc.total_flight_count--; \
  276         } else { \
  277                 stcb->asoc.total_flight = 0; \
  278                 stcb->asoc.total_flight_count = 0; \
  279         } \
  280 } while (0)
  281 
  282 #define sctp_total_flight_increase(stcb, tp1) do { \
  283        (stcb)->asoc.total_flight_count++; \
  284        (stcb)->asoc.total_flight += (tp1)->book_size; \
  285 } while (0)
  286 
  287 #endif
  288 
  289 
  290 struct sctp_nets;
  291 struct sctp_inpcb;
  292 struct sctp_tcb;
  293 struct sctphdr;
  294 
  295 
  296 void sctp_close(struct socket *so);
  297 int sctp_disconnect(struct socket *so);
  298 
  299 void sctp_ctlinput __P((int, struct sockaddr *, void *));
  300 int sctp_ctloutput __P((struct socket *, struct sockopt *));
  301 void sctp_input_with_port __P((struct mbuf *, int, uint16_t));
  302 void sctp_input __P((struct mbuf *, int));
  303 void sctp_pathmtu_adjustment __P((struct sctp_inpcb *, struct sctp_tcb *, struct sctp_nets *, uint16_t));
  304 void sctp_drain __P((void));
  305 void sctp_init __P((void));
  306 
  307 void sctp_finish(void);
  308 
  309 int sctp_flush(struct socket *, int);
  310 int sctp_shutdown __P((struct socket *));
  311 void sctp_notify 
  312 __P((struct sctp_inpcb *, struct ip *ip, struct sctphdr *,
  313     struct sockaddr *, struct sctp_tcb *,
  314     struct sctp_nets *));
  315 
  316         int sctp_bindx(struct socket *, int, struct sockaddr_storage *,
  317         int, int, struct proc *);
  318 
  319 /* can't use sctp_assoc_t here */
  320         int sctp_peeloff(struct socket *, struct socket *, int, caddr_t, int *);
  321 
  322         int sctp_ingetaddr(struct socket *,
  323         struct sockaddr **
  324 );
  325 
  326         int sctp_peeraddr(struct socket *,
  327         struct sockaddr **
  328 );
  329 
  330         int sctp_listen(struct socket *, int, struct thread *);
  331 
  332         int sctp_accept(struct socket *, struct sockaddr **);
  333 
  334 #endif                          /* _KERNEL */
  335 
  336 #endif                          /* !_NETINET_SCTP_VAR_H_ */

Cache object: f9ae70e3cf218a6ddd99f28397aae8ad


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.