MCPcopy Create free account
hub / github.com/F-Stack/f-stack / sctp_process_cookie_new

Function sctp_process_cookie_new

freebsd/netinet/sctp_input.c:1994–2271  ·  view source on GitHub ↗

* handle a state cookie for a new association m: input packet mbuf chain-- * assumes a pullup on IP/SCTP/COOKIE-ECHO chunk note: this is a "split" mbuf * and the cookie signature does not exist offset: offset into mbuf to the * cookie-echo chunk length: length of the cookie chunk to: where the init * was from returns a new TCB */

Source from the content-addressed store, hash-verified

1992 * was from returns a new TCB
1993 */
1994static struct sctp_tcb *
1995sctp_process_cookie_new(struct mbuf *m, int iphlen, int offset,
1996 struct sockaddr *src, struct sockaddr *dst,
1997 struct sctphdr *sh, struct sctp_state_cookie *cookie, int cookie_len,
1998 struct sctp_inpcb *inp, struct sctp_nets **netp,
1999 struct sockaddr *init_src, int *notification,
2000 int auth_skipped, uint32_t auth_offset, uint32_t auth_len,
2001 uint8_t mflowtype, uint32_t mflowid,
2002 uint32_t vrf_id, uint16_t port)
2003{
2004 struct sctp_tcb *stcb;
2005 struct sctp_init_chunk *init_cp, init_buf;
2006 struct sctp_init_ack_chunk *initack_cp, initack_buf;
2007 union sctp_sockstore store;
2008 struct sctp_association *asoc;
2009 int init_offset, initack_offset, initack_limit;
2010 int retval;
2011 int error = 0;
2012 uint8_t auth_chunk_buf[SCTP_CHUNK_BUFFER_SIZE];
2013
2014 /*
2015 * find and validate the INIT chunk in the cookie (peer's info) the
2016 * INIT should start after the cookie-echo header struct (chunk
2017 * header, state cookie header struct)
2018 */
2019 init_offset = offset + sizeof(struct sctp_cookie_echo_chunk);
2020 init_cp = (struct sctp_init_chunk *)
2021 sctp_m_getptr(m, init_offset, sizeof(struct sctp_init_chunk),
2022 (uint8_t *)&init_buf);
2023 if (init_cp == NULL) {
2024 /* could not pull a INIT chunk in cookie */
2025 SCTPDBG(SCTP_DEBUG_INPUT1,
2026 "process_cookie_new: could not pull INIT chunk hdr\n");
2027 return (NULL);
2028 }
2029 if (init_cp->ch.chunk_type != SCTP_INITIATION) {
2030 SCTPDBG(SCTP_DEBUG_INPUT1, "HUH? process_cookie_new: could not find INIT chunk!\n");
2031 return (NULL);
2032 }
2033 initack_offset = init_offset + SCTP_SIZE32(ntohs(init_cp->ch.chunk_length));
2034 /*
2035 * find and validate the INIT-ACK chunk in the cookie (my info) the
2036 * INIT-ACK follows the INIT chunk
2037 */
2038 initack_cp = (struct sctp_init_ack_chunk *)
2039 sctp_m_getptr(m, initack_offset, sizeof(struct sctp_init_ack_chunk),
2040 (uint8_t *)&initack_buf);
2041 if (initack_cp == NULL) {
2042 /* could not pull INIT-ACK chunk in cookie */
2043 SCTPDBG(SCTP_DEBUG_INPUT1, "process_cookie_new: could not pull INIT-ACK chunk hdr\n");
2044 return (NULL);
2045 }
2046 if (initack_cp->ch.chunk_type != SCTP_INITIATION_ACK) {
2047 return (NULL);
2048 }
2049 /*
2050 * NOTE: We can't use the INIT_ACK's chk_length to determine the
2051 * "initack_limit" value. This is because the chk_length field

Callers 2

sctp_handle_cookie_echoFunction · 0.85

Calls 15

sctp_m_getptrFunction · 0.85
sctp_aloc_assocFunction · 0.85
sctp_generate_causeFunction · 0.85
sctp_abort_associationFunction · 0.85
sctp_free_assocFunction · 0.85
sctp_process_initFunction · 0.85
sctp_handle_authFunction · 0.85
memsetFunction · 0.85
sctp_timer_startFunction · 0.85

Tested by

no test coverage detected