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

Function IsASCONFack

freebsd/netinet/libalias/alias_sctp.c:1594–1633  ·  view source on GitHub ↗

@ingroup packet_parser * @brief Check that ASCONF was successful * * Each ASCONF configuration parameter carries a correlation ID which should be * matched with an ASCONFack. This is difficult for a NAT, since every * association could potentially have a number of outstanding ASCONF * configuration parameters, which should only be activated on receipt of the * ACK. * * Currently we only l

Source from the content-addressed store, hash-verified

1592 * @return 1 - success | 0 - fail
1593 */
1594static int
1595IsASCONFack(struct libalias *la, struct sctp_nat_msg *sm, int direction)
1596{
1597 struct sctp_paramhdr *param;
1598 int bytes_left;
1599 int param_size;
1600 int param_count;
1601
1602 param_count = 1;
1603 param = sm->sctpchnk.Asconf;
1604 param_size = SCTP_SIZE32(ntohs(param->param_length));
1605 if (param_size == 8)
1606 return (1); /*success - default acknowledgement of everything */
1607
1608 bytes_left = sm->chunk_length;
1609 if (bytes_left < param_size)
1610 return (0); /* not found */
1611 /* step through Asconf parameters */
1612 while(bytes_left >= SN_ASCONFACK_PARAM_SIZE) {
1613 if (ntohs(param->param_type) == SCTP_SUCCESS_REPORT)
1614 return (1); /* success - but can't match correlation IDs - should only be one */
1615 /* check others just in case */
1616 bytes_left -= param_size;
1617 if (bytes_left >= SN_MIN_PARAM_SIZE) {
1618 param = SN_SCTP_NEXTPARAM(param);
1619 } else {
1620 return (0);
1621 }
1622 param_size = SCTP_SIZE32(ntohs(param->param_length));
1623 if (bytes_left < param_size) return (0);
1624
1625 if (++param_count > sysctl_param_proc_limit) {
1626 SN_LOG(SN_LOG_EVENT,
1627 logsctperror("Parameter parse limit exceeded (IsASCONFack)",
1628 sm->sctp_hdr->v_tag, sysctl_param_proc_limit, direction));
1629 return (0); /* not found limit exceeded*/
1630 }
1631 }
1632 return (0); /* not success */
1633}
1634
1635/** @ingroup packet_parser
1636 * @brief Check to see if ASCONF contains an Add IP or Del IP parameter

Callers 1

INa_processFunction · 0.85

Calls 1

logsctperrorFunction · 0.85

Tested by

no test coverage detected