@ingroup packet_parser * @brief Check to see if ASCONF contains an Add IP or Del IP parameter * * IsADDorDEL scans an ASCONF packet to see if it contains an AddIP or DelIP * parameter * * @param la Pointer to the relevant libalias instance * @param sm Pointer to sctp message information * @param direction SN_TO_LOCAL | SN_TO_GLOBAL * * @return SCTP_ADD_IP_ADDRESS | SCTP_DEL_IP_ADDRESS |
| 1645 | * @return SCTP_ADD_IP_ADDRESS | SCTP_DEL_IP_ADDRESS | 0 - fail |
| 1646 | */ |
| 1647 | static int |
| 1648 | IsADDorDEL(struct libalias *la, struct sctp_nat_msg *sm, int direction) |
| 1649 | { |
| 1650 | struct sctp_paramhdr *param; |
| 1651 | int bytes_left; |
| 1652 | int param_size; |
| 1653 | int param_count; |
| 1654 | |
| 1655 | param_count = 1; |
| 1656 | param = sm->sctpchnk.Asconf; |
| 1657 | param_size = SCTP_SIZE32(ntohs(param->param_length)); |
| 1658 | |
| 1659 | bytes_left = sm->chunk_length; |
| 1660 | if (bytes_left < param_size) |
| 1661 | return (0); /* not found */ |
| 1662 | /* step through Asconf parameters */ |
| 1663 | while(bytes_left >= SN_ASCONFACK_PARAM_SIZE) { |
| 1664 | if (ntohs(param->param_type) == SCTP_ADD_IP_ADDRESS) |
| 1665 | return (SCTP_ADD_IP_ADDRESS); |
| 1666 | else if (ntohs(param->param_type) == SCTP_DEL_IP_ADDRESS) |
| 1667 | return (SCTP_DEL_IP_ADDRESS); |
| 1668 | /* check others just in case */ |
| 1669 | bytes_left -= param_size; |
| 1670 | if (bytes_left >= SN_MIN_PARAM_SIZE) { |
| 1671 | param = SN_SCTP_NEXTPARAM(param); |
| 1672 | } else { |
| 1673 | return (0); /*Neither found */ |
| 1674 | } |
| 1675 | param_size = SCTP_SIZE32(ntohs(param->param_length)); |
| 1676 | if (bytes_left < param_size) return (0); |
| 1677 | |
| 1678 | if (++param_count > sysctl_param_proc_limit) { |
| 1679 | SN_LOG(SN_LOG_EVENT, |
| 1680 | logsctperror("Parameter parse limit exceeded IsADDorDEL)", |
| 1681 | sm->sctp_hdr->v_tag, sysctl_param_proc_limit, direction)); |
| 1682 | return (0); /* not found limit exceeded*/ |
| 1683 | } |
| 1684 | } |
| 1685 | return (0); /*Neither found */ |
| 1686 | } |
| 1687 | |
| 1688 | /* ---------------------------------------------------------------------- |
| 1689 | * STATE MACHINE CODE |
no test coverage detected