Lines Matching full:chunk
67 static void *sctp_addto_param(struct sctp_chunk *chunk, int len,
70 /* Control chunk destructor */
73 struct sctp_chunk *chunk = skb_shinfo(skb)->destructor_arg;
75 if (chunk->shkey) {
76 struct sctp_shared_key *shkey = chunk->shkey;
77 struct sctp_association *asoc = chunk->asoc;
93 sctp_auth_shkey_release(chunk->shkey);
97 static void sctp_control_set_owner_w(struct sctp_chunk *chunk)
99 struct sctp_association *asoc = chunk->asoc;
100 struct sk_buff *skb = chunk->skb;
109 if (chunk->auth) {
110 chunk->shkey = asoc->shkey;
111 sctp_auth_shkey_hold(chunk->shkey);
114 skb_shinfo(skb)->destructor_arg = chunk;
132 /* A helper to initialize an op error inside a provided chunk, as most
133 * cause codes will be embedded inside an abort chunk.
135 int sctp_init_cause(struct sctp_chunk *chunk, __be16 cause_code,
146 if (skb_tailroom(chunk->skb) < len)
149 chunk->subh.err_hdr = sctp_addto_chunk(chunk, sizeof(err), &err);
156 * This chunk is used to initiate a SCTP association between two
157 * endpoints. The format of the INIT chunk is shown below:
162 * | Type = 1 | Chunk Flags | Chunk Length |
178 * The INIT chunk contains the following parameters. Unless otherwise
179 * noted, each parameter MUST only be included once in the INIT chunk.
301 * Note 3: An INIT chunk MUST NOT contain more than one Host
306 * present in the received INIT chunk.
372 const struct sctp_chunk *chunk,
403 cookie = sctp_pack_cookie(asoc->ep, asoc, chunk, &cookie_len,
463 /* Now allocate and fill out the chunk. */
472 * address from which it received the DATA or control chunk
477 if (chunk->transport)
480 &chunk->transport->ipaddr);
527 * This chunk is used only during the initialization of an association.
529 * the initialization process. This chunk MUST precede any DATA chunk
536 * | Type = 10 |Chunk Flags | Length |
542 * Chunk Flags: 8 bit
548 * Set to the size of the chunk in bytes, including the 4 bytes of
549 * the chunk header and the size of the Cookie.
560 const struct sctp_chunk *chunk)
569 /* Build a cookie echo chunk. */
581 * address from which it * received the DATA or control chunk
586 if (chunk)
587 retval->transport = chunk->transport;
595 * This chunk is used only during the initialization of an
597 * ECHO chunk. This chunk MUST precede any DATA or SACK chunk sent
599 * chunks or SACK chunk in the same SCTP packet.
604 * | Type = 11 |Chunk Flags | Length = 4 |
607 * Chunk Flags: 8 bits
612 const struct sctp_chunk *chunk)
622 * address from which it * received the DATA or control chunk
627 if (retval && chunk && chunk->transport)
630 &chunk->transport->ipaddr);
642 * SCTP the same indication is made by including the CWR chunk.
643 * This chunk contains one data element, i.e. the TSN number that
644 * was sent in the ECNE chunk. This element represents the lowest
651 * | Chunk Type=13 | Flags=00000000| Chunk Length = 8 |
656 * Note: The CWR is considered a Control chunk.
660 const struct sctp_chunk *chunk)
679 * address from which it * received the DATA or control chunk
685 if (chunk)
686 retval->transport = chunk->transport;
692 /* Make an ECNE chunk. This is a congestion experienced report. */
711 /* Make a DATA chunk for the given association from the provided
722 * creating the chunk.
762 /* How much room is needed in the chunk? */
776 /* Create the chunk. */
785 * address from which it received the DATA or control chunk to
788 * reply chunk.
792 * SACK, the SACK chunk may be transmitted to one of the
801 * When a receiver of a duplicate DATA chunk sends a SACK to a
804 * DATA chunk. The reason being that receiving a duplicate
806 * path (as specified in the source address of the DATA chunk)
809 * [Send to the address from which we last received a DATA chunk.]
845 /* Make a SHUTDOWN chunk. */
847 const struct sctp_chunk *chunk)
864 if (chunk)
865 retval->transport = chunk->transport;
871 const struct sctp_chunk *chunk)
882 * address from which it * received the DATA or control chunk
887 if (retval && chunk)
888 retval->transport = chunk->transport;
895 const struct sctp_chunk *chunk)
912 * address from which it * received the DATA or control chunk
918 if (retval && chunk)
919 retval->transport = chunk->transport;
928 const struct sctp_chunk *chunk,
934 /* Set the T-bit if we have no association and 'chunk' is not
938 if (chunk && chunk->chunk_hdr &&
939 chunk->chunk_hdr->type == SCTP_CID_INIT)
952 * address from which it * received the DATA or control chunk
957 if (retval && chunk)
958 retval->transport = chunk->transport;
966 const struct sctp_chunk *chunk,
972 retval = sctp_make_abort(asoc, chunk,
987 * address from which it * received the DATA or control chunk
992 if (chunk)
993 retval->transport = chunk->transport;
1041 /* Append bytes to the end of a parameter. Will panic if chunk is not big
1044 static void *sctp_addto_param(struct sctp_chunk *chunk, int len,
1047 int chunklen = ntohs(chunk->chunk_hdr->length);
1050 target = skb_put(chunk->skb, len);
1057 /* Adjust the chunk length field. */
1058 chunk->chunk_hdr->length = htons(chunklen + len);
1059 chunk->chunk_end = skb_tail_pointer(chunk->skb);
1064 /* Make an ABORT chunk with a PROTOCOL VIOLATION cause code. */
1067 const struct sctp_chunk *chunk,
1074 retval = sctp_make_abort(asoc, chunk, sizeof(struct sctp_errhdr) +
1082 phdr.type = htons(chunk->chunk_hdr->type);
1083 phdr.length = chunk->chunk_hdr->length;
1093 const struct sctp_chunk *chunk,
1101 retval = sctp_make_abort(asoc, chunk, payload_len);
1116 const struct sctp_chunk *chunk)
1122 retval = sctp_make_abort(asoc, chunk, payload_len);
1134 const struct sctp_chunk *chunk)
1139 retval = sctp_make_abort(asoc, chunk,
1145 nep.cur_port = SCTP_INPUT_CB(chunk->skb)->encap_port;
1146 nep.new_port = chunk->transport->encap_port;
1153 /* Make a HEARTBEAT chunk. */
1174 /* Cast away the 'const', as this is just telling the chunk
1187 const struct sctp_chunk *chunk,
1204 * address from which it * received the DATA or control chunk
1209 if (chunk)
1210 retval->transport = chunk->transport;
1216 /* RFC4820 3. Padding Chunk (PAD)
1242 /* Create an Operation Error chunk with the specified space reserved.
1243 * This routine can be used for containing multiple causes in the chunk.
1247 const struct sctp_chunk *chunk,
1262 * address from which it received the DATA or control chunk
1266 if (chunk)
1267 retval->transport = chunk->transport;
1273 /* Create an Operation Error chunk of a fixed size, specifically,
1275 * This is a helper function to allocate an error chunk for those
1277 * errors, if the incoming chunk is large. If it can't fit in a single
1282 const struct sctp_chunk *chunk)
1294 return sctp_make_op_error_space(asoc, chunk, size);
1297 /* Create an Operation Error chunk. */
1299 const struct sctp_chunk *chunk,
1305 retval = sctp_make_op_error_space(asoc, chunk, paylen + reserve_tail);
1344 /* Adjust the chunk header to include the empty MAC */
1357 /* Turn an skb into a chunk.
1361 * M1) Each time a new DATA chunk is transmitted
1390 SCTP_DBG_OBJCNT_INC(chunk);
1397 /* Set chunk->source and dest based on the IP header in chunk->skb. */
1398 void sctp_init_addrs(struct sctp_chunk *chunk, union sctp_addr *src,
1401 memcpy(&chunk->source, src, sizeof(union sctp_addr));
1402 memcpy(&chunk->dest, dest, sizeof(union sctp_addr));
1405 /* Extract the source address from a chunk. */
1406 const union sctp_addr *sctp_source(const struct sctp_chunk *chunk)
1409 if (chunk->transport) {
1410 return &chunk->transport->ipaddr;
1413 return &chunk->source;
1417 /* Create a new chunk, setting the type and flags headers from the
1434 /* No need to allocate LL here, as this is only a chunk. */
1439 /* Make room for the chunk header. */
1455 /* Determine if the chunk needs to be authenticated */
1480 struct sctp_chunk *chunk;
1482 chunk = _sctp_make_chunk(asoc, type, flags, paylen, gfp);
1483 if (chunk)
1484 sctp_control_set_owner_w(chunk);
1486 return chunk;
1489 /* Release the memory occupied by a chunk. */
1490 static void sctp_chunk_destroy(struct sctp_chunk *chunk)
1492 BUG_ON(!list_empty(&chunk->list));
1493 list_del_init(&chunk->transmitted_list);
1495 consume_skb(chunk->skb);
1496 consume_skb(chunk->auth_chunk);
1498 SCTP_DBG_OBJCNT_DEC(chunk);
1499 kmem_cache_free(sctp_chunk_cachep, chunk);
1502 /* Possibly, free the chunk. */
1503 void sctp_chunk_free(struct sctp_chunk *chunk)
1506 if (chunk->msg)
1507 sctp_datamsg_put(chunk->msg);
1509 sctp_chunk_put(chunk);
1512 /* Grab a reference to the chunk. */
1518 /* Release a reference to the chunk. */
1525 /* Append bytes to the end of a chunk. Will panic if chunk is not big
1528 void *sctp_addto_chunk(struct sctp_chunk *chunk, int len, const void *data)
1530 int chunklen = ntohs(chunk->chunk_hdr->length);
1534 skb_put_zero(chunk->skb, padlen);
1535 target = skb_put_data(chunk->skb, data, len);
1537 /* Adjust the chunk length field. */
1538 chunk->chunk_hdr->length = htons(chunklen + padlen + len);
1539 chunk->chunk_end = skb_tail_pointer(chunk->skb);
1544 /* Append bytes from user space to the end of a chunk. Will panic if
1545 * chunk is not big enough.
1548 int sctp_user_addto_chunk(struct sctp_chunk *chunk, int len,
1553 /* Make room in chunk for data. */
1554 target = skb_put(chunk->skb, len);
1556 /* Copy data (whole iovec) into chunk */
1560 /* Adjust the chunk length field. */
1561 chunk->chunk_hdr->length =
1562 htons(ntohs(chunk->chunk_hdr->length) + len);
1563 chunk->chunk_end = skb_tail_pointer(chunk->skb);
1571 void sctp_chunk_assign_ssn(struct sctp_chunk *chunk)
1578 if (chunk->has_ssn)
1582 sid = ntohs(chunk->subh.data_hdr->stream);
1583 stream = &chunk->asoc->stream;
1588 msg = chunk->msg;
1607 void sctp_chunk_assign_tsn(struct sctp_chunk *chunk)
1609 if (!chunk->has_tsn) {
1613 chunk->subh.data_hdr->tsn =
1614 htonl(sctp_association_get_next_tsn(chunk->asoc));
1615 chunk->has_tsn = 1;
1621 struct sctp_chunk *chunk,
1629 scope = sctp_scope(sctp_source(chunk));
1634 skb = chunk->skb;
1721 /* Unpack the cookie from COOKIE ECHO chunk, recreating the association. */
1725 struct sctp_chunk *chunk, gfp_t gfp,
1731 struct sk_buff *skb = chunk->skb;
1743 bodysize = ntohs(chunk->chunk_hdr->length) - headersize;
1746 /* Verify that the chunk looks like it even has a cookie.
1748 * INIT chunk.
1750 len = ntohs(chunk->chunk_hdr->length);
1759 cookie = chunk->subh.cookie_hdr;
1777 * within the COOKIE ECHO chunk to the actual port numbers and the
1782 if (ntohl(chunk->sctp_hdr->vtag) != bear_cookie->my_vtag) {
1787 if (chunk->sctp_hdr->source != bear_cookie->peer_addr.v4.sin_port ||
1788 ntohs(chunk->sctp_hdr->dest) != bear_cookie->my_port) {
1818 *errp = sctp_make_op_error(asoc, chunk,
1830 scope = sctp_scope(sctp_source(chunk));
1838 retval->peer.port = ntohs(chunk->sctp_hdr->source);
1851 sctp_add_bind_addr(&retval->base.bind_addr, &chunk->dest,
1852 sizeof(chunk->dest), SCTP_ADDR_SRC,
1895 struct sctp_chunk *chunk,
1903 /* Make an ERROR chunk, preparing enough room for
1907 *errp = sctp_make_op_error_space(asoc, chunk, len);
1917 /* Stop processing this chunk. */
1923 struct sctp_chunk *chunk,
1929 *errp = sctp_make_op_error_space(asoc, chunk, 0);
1934 /* Stop processing this chunk. */
1940 const struct sctp_chunk *chunk,
1949 /* Create an error chunk and fill it in with our payload. */
1950 *errp = sctp_make_violation_paramlen(asoc, chunk, param);
1961 struct sctp_chunk *chunk,
1974 *errp = sctp_make_op_error(asoc, chunk, SCTP_ERROR_DNS_FAILED,
1977 /* Stop processing this chunk. */
2062 * parameters within this chunk
2065 * parameters within this chunk, and report the unrecognized
2066 * parameter in an 'Unrecognized Parameter' ERROR chunk.
2072 * 'Unrecognized Parameter' ERROR chunk.
2075 * SCTP_IERROR_NO_ERROR - continue with the chunk
2082 struct sctp_chunk *chunk,
2097 /* Make an ERROR chunk, preparing enough room for
2101 *errp = sctp_make_op_error_limited(asoc, chunk);
2130 * SCTP_IERROR_NO_ERROR - continue with the chunk
2137 struct sctp_chunk *chunk,
2146 * chunk type, i.e., unrecognized parameters should be further
2147 * identified based on the chunk id.
2174 chunk, err_chunk);
2181 sctp_process_hn_param(asoc, param, chunk, err_chunk);
2196 * MUST be aborted. The ABORT chunk SHOULD contain the error
2202 chunk, err_chunk);
2213 * INIT-ACK chunk if the sender wants to receive authenticated
2218 chunk, err_chunk);
2243 sctp_process_inv_paramlength(asoc, param.p, chunk,
2250 pr_debug("%s: unrecognized param:%d for chunk:%d\n",
2253 retval = sctp_process_unk_param(asoc, param, chunk, err_chunk);
2263 struct sctp_chunk *chunk, struct sctp_chunk **errp)
2277 return sctp_process_inv_mandatory(asoc, chunk, errp);
2288 * VIOLATION error. We build the ERROR chunk here and let the normal
2291 if (param.v != (void *)chunk->chunk_end)
2292 return sctp_process_inv_paramlength(asoc, param.p, chunk, errp);
2295 * the state cookie for an INIT-ACK chunk.
2299 chunk, errp);
2304 chunk, errp);
2325 int sctp_process_init(struct sctp_association *asoc, struct sctp_chunk *chunk,
2346 asoc->encap_port = SCTP_INPUT_CB(chunk->skb)->encap_port;
2350 if (sctp_cmp_addr_exact(sctp_source(chunk), peer_addr))
2360 chunk->sctp_hdr->source, 0))
2362 if (sctp_cmp_addr_exact(sctp_source(chunk), &addr))
2370 /* source address of chunk may not match any valid address */
2473 /* ADDIP Section 4.1 ASCONF Chunk Procedures
2478 * A2) A serial number should be assigned to the Chunk. The serial
2746 * ADDIP 3.1.1 Address Configuration Change Chunk (ASCONF)
2750 * | Type = 0xC1 | Chunk Flags | Chunk Length |
2783 /* Create the chunk. */
2862 /* Create an asconf chunk with the required length. */
2867 /* Add the address parameters to the asconf chunk. */
2908 * Create an ASCONF chunk with Set Primary IP address parameter.
2925 /* Create the chunk and make asconf header. */
2940 /* ADDIP 3.1.2 Address Configuration Acknowledgement Chunk (ASCONF-ACK)
2944 * | Type = 0x80 | Chunk Flags | Chunk Length |
2957 * Create an ASCONF_ACK chunk with enough space for the parameter responses.
2966 /* Create the chunk. */
2980 /* Add response parameters to an ASCONF_ACK chunk. */
2981 static void sctp_add_asconf_response(struct sctp_chunk *chunk, __be32 crr_id,
3007 sctp_addto_chunk(chunk, sizeof(ack_param), &ack_param);
3015 sctp_addto_chunk(chunk, err_param_len, &err_param);
3017 /* Add the failed TLV copied from ASCONF chunk. */
3019 sctp_addto_chunk(chunk, asconf_param_len, asconf_param);
3108 * which contained the ASCONF chunk, the receiver MUST reject
3167 struct sctp_chunk *chunk, bool addr_param_needed,
3174 addip = (struct sctp_addip_chunk *)chunk->chunk_hdr;
3226 if (param.v != chunk->chunk_end)
3232 /* Process an incoming ASCONF chunk with the next expected serial no. and
3233 * return an ASCONF_ACK chunk to be sent in response.
3265 /* create an ASCONF_ACK chunk.
3274 /* Process the TLVs contained within the ASCONF chunk. */
3372 /* Get the corresponding ASCONF response error code from the ASCONF_ACK chunk
3399 /* Skip the addiphdr from the asconf_ack chunk and store a pointer to
3434 /* Process an incoming ASCONF_ACK chunk against the cached last ASCONF chunk. */
3470 /* Process the TLVs contained in the last sent ASCONF chunk. */
3519 /* Free the cached last sent asconf chunk. */
3527 /* Make a FWD TSN chunk. */
3582 /* RE-CONFIG 3.1 (RE-CONFIG chunk)
3586 * | Type = 130 | Chunk Flags | Chunk Length |
3842 struct sctp_chunk *chunk,
3850 hdr = (struct sctp_reconf_chunk *)chunk->chunk_hdr;