Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   1) /* SPDX-License-Identifier: GPL-2.0-or-later */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2) /* SCTP kernel implementation
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3)  * (C) Copyright IBM Corp. 2001, 2004
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4)  * Copyright (c) 1999-2000 Cisco, Inc.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5)  * Copyright (c) 1999-2001 Motorola, Inc.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6)  * Copyright (c) 2001 Intel Corp.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8)  * This file is part of the SCTP kernel implementation
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10)  * These are definitions needed by the state machine.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12)  * Please send any bug reports or fixes you make to the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13)  * email addresses:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14)  *    lksctp developers <linux-sctp@vger.kernel.org>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16)  * Written or modified by:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17)  *    La Monte H.P. Yarroll <piggy@acm.org>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18)  *    Karl Knutson <karl@athena.chicago.il.us>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19)  *    Xingang Guo <xingang.guo@intel.com>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20)  *    Jon Grimm <jgrimm@us.ibm.com>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21)  *    Dajiang Zhang <dajiang.zhang@nokia.com>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22)  *    Sridhar Samudrala <sri@us.ibm.com>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23)  *    Daisy Chang <daisyc@us.ibm.com>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24)  *    Ardelle Fan <ardelle.fan@intel.com>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25)  *    Kevin Gao <kevin.gao@intel.com>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28) #include <linux/types.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29) #include <linux/compiler.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) #include <linux/slab.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) #include <linux/in.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) #include <net/sctp/command.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) #include <net/sctp/sctp.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) #ifndef __sctp_sm_h__
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) #define __sctp_sm_h__
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39)  * Possible values for the disposition are:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) enum sctp_disposition {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) 	SCTP_DISPOSITION_DISCARD,	 /* No further processing.  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) 	SCTP_DISPOSITION_CONSUME,	 /* Process return values normally.  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) 	SCTP_DISPOSITION_NOMEM,		 /* We ran out of memory--recover.  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) 	SCTP_DISPOSITION_DELETE_TCB,	 /* Close the association.  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) 	SCTP_DISPOSITION_ABORT,		 /* Close the association NOW.  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) 	SCTP_DISPOSITION_VIOLATION,	 /* The peer is misbehaving.  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) 	SCTP_DISPOSITION_NOT_IMPL,	 /* This entry is not implemented.  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) 	SCTP_DISPOSITION_ERROR,		 /* This is plain old user error.  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) 	SCTP_DISPOSITION_BUG,		 /* This is a bug.  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) typedef enum sctp_disposition (sctp_state_fn_t) (
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) 					struct net *net,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) 					const struct sctp_endpoint *ep,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) 					const struct sctp_association *asoc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) 					const union sctp_subtype type,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) 					void *arg,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) 					struct sctp_cmd_seq *commands);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) typedef void (sctp_timer_event_t) (struct timer_list *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) struct sctp_sm_table_entry {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) 	sctp_state_fn_t *fn;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) 	const char *name;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) /* A naming convention of "sctp_sf_xxx" applies to all the state functions
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67)  * currently in use.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) /* Prototypes for generic state functions. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) sctp_state_fn_t sctp_sf_not_impl;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) sctp_state_fn_t sctp_sf_bug;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) /* Prototypes for gener timer state functions. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) sctp_state_fn_t sctp_sf_timer_ignore;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) /* Prototypes for chunk state functions. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) sctp_state_fn_t sctp_sf_do_9_1_abort;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) sctp_state_fn_t sctp_sf_cookie_wait_abort;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) sctp_state_fn_t sctp_sf_cookie_echoed_abort;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) sctp_state_fn_t sctp_sf_shutdown_pending_abort;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) sctp_state_fn_t sctp_sf_shutdown_sent_abort;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) sctp_state_fn_t sctp_sf_shutdown_ack_sent_abort;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) sctp_state_fn_t sctp_sf_do_5_1B_init;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) sctp_state_fn_t sctp_sf_do_5_1C_ack;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) sctp_state_fn_t sctp_sf_do_5_1D_ce;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) sctp_state_fn_t sctp_sf_do_5_1E_ca;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) sctp_state_fn_t sctp_sf_do_4_C;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) sctp_state_fn_t sctp_sf_eat_data_6_2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) sctp_state_fn_t sctp_sf_eat_data_fast_4_4;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) sctp_state_fn_t sctp_sf_eat_sack_6_2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) sctp_state_fn_t sctp_sf_operr_notify;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) sctp_state_fn_t sctp_sf_t1_init_timer_expire;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) sctp_state_fn_t sctp_sf_t1_cookie_timer_expire;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) sctp_state_fn_t sctp_sf_t2_timer_expire;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) sctp_state_fn_t sctp_sf_t4_timer_expire;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) sctp_state_fn_t sctp_sf_t5_timer_expire;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) sctp_state_fn_t sctp_sf_sendbeat_8_3;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) sctp_state_fn_t sctp_sf_beat_8_3;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) sctp_state_fn_t sctp_sf_backbeat_8_3;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) sctp_state_fn_t sctp_sf_do_9_2_final;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) sctp_state_fn_t sctp_sf_do_9_2_shutdown;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) sctp_state_fn_t sctp_sf_do_9_2_shut_ctsn;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) sctp_state_fn_t sctp_sf_do_ecn_cwr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) sctp_state_fn_t sctp_sf_do_ecne;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) sctp_state_fn_t sctp_sf_ootb;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) sctp_state_fn_t sctp_sf_pdiscard;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) sctp_state_fn_t sctp_sf_violation;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) sctp_state_fn_t sctp_sf_discard_chunk;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) sctp_state_fn_t sctp_sf_do_5_2_1_siminit;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) sctp_state_fn_t sctp_sf_do_5_2_2_dupinit;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) sctp_state_fn_t sctp_sf_do_5_2_3_initack;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) sctp_state_fn_t sctp_sf_do_5_2_4_dupcook;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) sctp_state_fn_t sctp_sf_unk_chunk;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) sctp_state_fn_t sctp_sf_do_8_5_1_E_sa;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) sctp_state_fn_t sctp_sf_cookie_echoed_err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) sctp_state_fn_t sctp_sf_do_asconf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) sctp_state_fn_t sctp_sf_do_asconf_ack;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) sctp_state_fn_t sctp_sf_do_reconf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) sctp_state_fn_t sctp_sf_do_9_2_reshutack;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) sctp_state_fn_t sctp_sf_eat_fwd_tsn;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) sctp_state_fn_t sctp_sf_eat_fwd_tsn_fast;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) sctp_state_fn_t sctp_sf_eat_auth;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) /* Prototypes for primitive event state functions.  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) sctp_state_fn_t sctp_sf_do_prm_asoc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) sctp_state_fn_t sctp_sf_do_prm_send;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) sctp_state_fn_t sctp_sf_do_9_2_prm_shutdown;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) sctp_state_fn_t sctp_sf_cookie_wait_prm_shutdown;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) sctp_state_fn_t sctp_sf_cookie_echoed_prm_shutdown;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) sctp_state_fn_t sctp_sf_do_9_1_prm_abort;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) sctp_state_fn_t sctp_sf_cookie_wait_prm_abort;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) sctp_state_fn_t sctp_sf_cookie_echoed_prm_abort;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) sctp_state_fn_t sctp_sf_shutdown_pending_prm_abort;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) sctp_state_fn_t sctp_sf_shutdown_sent_prm_abort;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) sctp_state_fn_t sctp_sf_shutdown_ack_sent_prm_abort;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) sctp_state_fn_t sctp_sf_error_closed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) sctp_state_fn_t sctp_sf_error_shutdown;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) sctp_state_fn_t sctp_sf_ignore_primitive;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) sctp_state_fn_t sctp_sf_do_prm_requestheartbeat;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) sctp_state_fn_t sctp_sf_do_prm_asconf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) sctp_state_fn_t sctp_sf_do_prm_reconf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) /* Prototypes for other event state functions.  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) sctp_state_fn_t sctp_sf_do_no_pending_tsn;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) sctp_state_fn_t sctp_sf_do_9_2_start_shutdown;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) sctp_state_fn_t sctp_sf_do_9_2_shutdown_ack;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) sctp_state_fn_t sctp_sf_ignore_other;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) sctp_state_fn_t sctp_sf_cookie_wait_icmp_abort;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) /* Prototypes for timeout event state functions.  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) sctp_state_fn_t sctp_sf_do_6_3_3_rtx;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) sctp_state_fn_t sctp_sf_send_reconf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) sctp_state_fn_t sctp_sf_do_6_2_sack;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) sctp_state_fn_t sctp_sf_autoclose_timer_expire;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) /* Prototypes for utility support functions.  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) __u8 sctp_get_chunk_type(struct sctp_chunk *chunk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) const struct sctp_sm_table_entry *sctp_sm_lookup_event(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) 					struct net *net,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) 					enum sctp_event_type event_type,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) 					enum sctp_state state,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) 					union sctp_subtype event_subtype);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) int sctp_chunk_iif(const struct sctp_chunk *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) struct sctp_association *sctp_make_temp_asoc(const struct sctp_endpoint *,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) 					     struct sctp_chunk *,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) 					     gfp_t gfp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) __u32 sctp_generate_verification_tag(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) void sctp_populate_tie_tags(__u8 *cookie, __u32 curTag, __u32 hisTag);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) /* Prototypes for chunk-building functions.  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) struct sctp_chunk *sctp_make_init(const struct sctp_association *asoc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) 				  const struct sctp_bind_addr *bp,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) 				  gfp_t gfp, int vparam_len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) struct sctp_chunk *sctp_make_init_ack(const struct sctp_association *asoc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) 				      const struct sctp_chunk *chunk,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) 				      const gfp_t gfp, const int unkparam_len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) struct sctp_chunk *sctp_make_cookie_echo(const struct sctp_association *asoc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) 					 const struct sctp_chunk *chunk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) struct sctp_chunk *sctp_make_cookie_ack(const struct sctp_association *asoc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) 					const struct sctp_chunk *chunk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) struct sctp_chunk *sctp_make_cwr(const struct sctp_association *asoc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) 				 const __u32 lowest_tsn,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) 				 const struct sctp_chunk *chunk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) struct sctp_chunk *sctp_make_idata(const struct sctp_association *asoc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) 				   __u8 flags, int paylen, gfp_t gfp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) struct sctp_chunk *sctp_make_ifwdtsn(const struct sctp_association *asoc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) 				     __u32 new_cum_tsn, size_t nstreams,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) 				     struct sctp_ifwdtsn_skip *skiplist);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) struct sctp_chunk *sctp_make_datafrag_empty(const struct sctp_association *asoc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) 					    const struct sctp_sndrcvinfo *sinfo,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) 					    int len, __u8 flags, gfp_t gfp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) struct sctp_chunk *sctp_make_ecne(const struct sctp_association *asoc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) 				  const __u32 lowest_tsn);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) struct sctp_chunk *sctp_make_sack(struct sctp_association *asoc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) struct sctp_chunk *sctp_make_shutdown(const struct sctp_association *asoc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) 				      const struct sctp_chunk *chunk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) struct sctp_chunk *sctp_make_shutdown_ack(const struct sctp_association *asoc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) 					  const struct sctp_chunk *chunk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) struct sctp_chunk *sctp_make_shutdown_complete(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) 					const struct sctp_association *asoc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) 					const struct sctp_chunk *chunk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) int sctp_init_cause(struct sctp_chunk *chunk, __be16 cause, size_t paylen);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) struct sctp_chunk *sctp_make_abort(const struct sctp_association *asoc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) 				   const struct sctp_chunk *chunk,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) 				   const size_t hint);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) struct sctp_chunk *sctp_make_abort_no_data(const struct sctp_association *asoc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) 					   const struct sctp_chunk *chunk,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) 					   __u32 tsn);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) struct sctp_chunk *sctp_make_abort_user(const struct sctp_association *asoc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) 					struct msghdr *msg, size_t msg_len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) struct sctp_chunk *sctp_make_abort_violation(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) 					const struct sctp_association *asoc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) 					const struct sctp_chunk *chunk,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) 					const __u8 *payload,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) 					const size_t paylen);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) struct sctp_chunk *sctp_make_violation_paramlen(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) 					const struct sctp_association *asoc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) 					const struct sctp_chunk *chunk,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) 					struct sctp_paramhdr *param);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) struct sctp_chunk *sctp_make_violation_max_retrans(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) 					const struct sctp_association *asoc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) 					const struct sctp_chunk *chunk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) struct sctp_chunk *sctp_make_heartbeat(const struct sctp_association *asoc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) 				       const struct sctp_transport *transport);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) struct sctp_chunk *sctp_make_heartbeat_ack(const struct sctp_association *asoc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) 					   const struct sctp_chunk *chunk,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) 					   const void *payload,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) 					   const size_t paylen);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) struct sctp_chunk *sctp_make_op_error(const struct sctp_association *asoc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) 				      const struct sctp_chunk *chunk,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) 				      __be16 cause_code, const void *payload,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) 				      size_t paylen, size_t reserve_tail);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) struct sctp_chunk *sctp_make_asconf_update_ip(struct sctp_association *asoc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) 					      union sctp_addr *laddr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) 					      struct sockaddr *addrs,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) 					      int addrcnt, __be16 flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) struct sctp_chunk *sctp_make_asconf_set_prim(struct sctp_association *asoc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) 					     union sctp_addr *addr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) bool sctp_verify_asconf(const struct sctp_association *asoc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) 			struct sctp_chunk *chunk, bool addr_param_needed,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) 			struct sctp_paramhdr **errp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) struct sctp_chunk *sctp_process_asconf(struct sctp_association *asoc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) 				       struct sctp_chunk *asconf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) int sctp_process_asconf_ack(struct sctp_association *asoc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) 			    struct sctp_chunk *asconf_ack);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) struct sctp_chunk *sctp_make_fwdtsn(const struct sctp_association *asoc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) 				    __u32 new_cum_tsn, size_t nstreams,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) 				    struct sctp_fwdtsn_skip *skiplist);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) struct sctp_chunk *sctp_make_auth(const struct sctp_association *asoc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) 				  __u16 key_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) struct sctp_chunk *sctp_make_strreset_req(const struct sctp_association *asoc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) 					  __u16 stream_num, __be16 *stream_list,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) 					  bool out, bool in);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) struct sctp_chunk *sctp_make_strreset_tsnreq(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) 					const struct sctp_association *asoc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) struct sctp_chunk *sctp_make_strreset_addstrm(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) 					const struct sctp_association *asoc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) 					__u16 out, __u16 in);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) struct sctp_chunk *sctp_make_strreset_resp(const struct sctp_association *asoc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) 					   __u32 result, __u32 sn);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) struct sctp_chunk *sctp_make_strreset_tsnresp(struct sctp_association *asoc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) 					      __u32 result, __u32 sn,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) 					      __u32 sender_tsn,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) 					      __u32 receiver_tsn);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) bool sctp_verify_reconf(const struct sctp_association *asoc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) 			struct sctp_chunk *chunk,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) 			struct sctp_paramhdr **errp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) void sctp_chunk_assign_tsn(struct sctp_chunk *chunk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) void sctp_chunk_assign_ssn(struct sctp_chunk *chunk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) /* Prototypes for stream-processing functions.  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) struct sctp_chunk *sctp_process_strreset_outreq(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) 				struct sctp_association *asoc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) 				union sctp_params param,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) 				struct sctp_ulpevent **evp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) struct sctp_chunk *sctp_process_strreset_inreq(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) 				struct sctp_association *asoc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) 				union sctp_params param,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) 				struct sctp_ulpevent **evp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) struct sctp_chunk *sctp_process_strreset_tsnreq(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) 				struct sctp_association *asoc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) 				union sctp_params param,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) 				struct sctp_ulpevent **evp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) struct sctp_chunk *sctp_process_strreset_addstrm_out(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) 				struct sctp_association *asoc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) 				union sctp_params param,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) 				struct sctp_ulpevent **evp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) struct sctp_chunk *sctp_process_strreset_addstrm_in(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) 				struct sctp_association *asoc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) 				union sctp_params param,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) 				struct sctp_ulpevent **evp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) struct sctp_chunk *sctp_process_strreset_resp(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) 				struct sctp_association *asoc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) 				union sctp_params param,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) 				struct sctp_ulpevent **evp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) /* Prototypes for statetable processing. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301) int sctp_do_sm(struct net *net, enum sctp_event_type event_type,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302) 	       union sctp_subtype subtype, enum sctp_state state,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303) 	       struct sctp_endpoint *ep, struct sctp_association *asoc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304) 	       void *event_arg, gfp_t gfp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306) /* 2nd level prototypes */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307) void sctp_generate_t3_rtx_event(struct timer_list *t);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308) void sctp_generate_heartbeat_event(struct timer_list *t);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309) void sctp_generate_reconf_event(struct timer_list *t);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310) void sctp_generate_proto_unreach_event(struct timer_list *t);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312) void sctp_ootb_pkt_free(struct sctp_packet *packet);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314) struct sctp_association *sctp_unpack_cookie(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315) 					const struct sctp_endpoint *ep,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316) 					const struct sctp_association *asoc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317) 					struct sctp_chunk *chunk,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318) 					gfp_t gfp, int *err,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319) 					struct sctp_chunk **err_chk_p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 320) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 321) /* 3rd level prototypes */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 322) __u32 sctp_generate_tag(const struct sctp_endpoint *ep);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 323) __u32 sctp_generate_tsn(const struct sctp_endpoint *ep);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 324) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 325) /* Extern declarations for major data structures.  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 326) extern sctp_timer_event_t *sctp_timer_events[SCTP_NUM_TIMEOUT_TYPES];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 327) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 328) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 329) /* Get the size of a DATA chunk payload. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 330) static inline __u16 sctp_data_size(struct sctp_chunk *chunk)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 331) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 332) 	__u16 size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 333) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 334) 	size = ntohs(chunk->chunk_hdr->length);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 335) 	size -= sctp_datachk_len(&chunk->asoc->stream);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 336) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 337) 	return size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 338) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 339) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 340) /* Compare two TSNs */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 341) #define TSN_lt(a,b)	\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 342) 	(typecheck(__u32, a) && \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 343) 	 typecheck(__u32, b) && \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 344) 	 ((__s32)((a) - (b)) < 0))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 345) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 346) #define TSN_lte(a,b)	\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 347) 	(typecheck(__u32, a) && \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 348) 	 typecheck(__u32, b) && \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 349) 	 ((__s32)((a) - (b)) <= 0))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 350) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 351) /* Compare two MIDs */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 352) #define MID_lt(a, b)	\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 353) 	(typecheck(__u32, a) && \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 354) 	 typecheck(__u32, b) && \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 355) 	 ((__s32)((a) - (b)) < 0))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 356) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 357) /* Compare two SSNs */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 358) #define SSN_lt(a,b)		\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 359) 	(typecheck(__u16, a) && \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 360) 	 typecheck(__u16, b) && \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 361) 	 ((__s16)((a) - (b)) < 0))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 362) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 363) /* ADDIP 3.1.1 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 364) #define ADDIP_SERIAL_gte(a,b)	\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 365) 	(typecheck(__u32, a) && \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 366) 	 typecheck(__u32, b) && \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 367) 	 ((__s32)((b) - (a)) <= 0))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 368) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 369) /* Check VTAG of the packet matches the sender's own tag. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 370) static inline int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 371) sctp_vtag_verify(const struct sctp_chunk *chunk,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 372) 		 const struct sctp_association *asoc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 373) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 374) 	/* RFC 2960 Sec 8.5 When receiving an SCTP packet, the endpoint
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 375) 	 * MUST ensure that the value in the Verification Tag field of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 376) 	 * the received SCTP packet matches its own Tag. If the received
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 377) 	 * Verification Tag value does not match the receiver's own
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 378) 	 * tag value, the receiver shall silently discard the packet...
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 379) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 380)         if (ntohl(chunk->sctp_hdr->vtag) == asoc->c.my_vtag)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 381)                 return 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 382) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 383) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 384) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 385) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 386) /* Check VTAG of the packet matches the sender's own tag and the T bit is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 387)  * not set, OR its peer's tag and the T bit is set in the Chunk Flags.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 388)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 389) static inline int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 390) sctp_vtag_verify_either(const struct sctp_chunk *chunk,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 391) 			const struct sctp_association *asoc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 392) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 393)         /* RFC 2960 Section 8.5.1, sctpimpguide Section 2.41
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 394) 	 *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 395) 	 * B) The receiver of a ABORT MUST accept the packet
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 396) 	 *    if the Verification Tag field of the packet matches its own tag
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 397) 	 *    and the T bit is not set
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 398) 	 *    OR
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 399) 	 *    it is set to its peer's tag and the T bit is set in the Chunk
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 400) 	 *    Flags.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 401) 	 *    Otherwise, the receiver MUST silently discard the packet
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 402) 	 *    and take no further action.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 403) 	 *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 404) 	 * C) The receiver of a SHUTDOWN COMPLETE shall accept the packet
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 405) 	 *    if the Verification Tag field of the packet matches its own tag
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 406) 	 *    and the T bit is not set
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 407) 	 *    OR
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 408) 	 *    it is set to its peer's tag and the T bit is set in the Chunk
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 409) 	 *    Flags.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 410) 	 *    Otherwise, the receiver MUST silently discard the packet
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 411) 	 *    and take no further action.  An endpoint MUST ignore the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 412) 	 *    SHUTDOWN COMPLETE if it is not in the SHUTDOWN-ACK-SENT state.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 413) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 414)         if ((!sctp_test_T_bit(chunk) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 415)              (ntohl(chunk->sctp_hdr->vtag) == asoc->c.my_vtag)) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 416) 	    (sctp_test_T_bit(chunk) && asoc->c.peer_vtag &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 417) 	     (ntohl(chunk->sctp_hdr->vtag) == asoc->c.peer_vtag))) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 418)                 return 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 419) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 420) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 421) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 422) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 423) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 424) #endif /* __sctp_sm_h__ */