Exemple #1
0
        /*
         *
         * 1	Heartbeat Info	[RFC4960]
         * 2-4	Unassigned
         * 5	IPv4 Address	[RFC4960]
         * 6	IPv6 Address	[RFC4960]
         * 7	State Cookie	[RFC4960]
         * 8	Unrecognized Parameters	[RFC4960]
         * 9	Cookie Preservative	[RFC4960]
         * 10	Unassigned
         * 11	Host Name Address	[RFC4960]
         * 12	Supported Address Types	[RFC4960]
         * 13	Outgoing SSN Reset Request Parameter	[RFC6525]
         * 14	Incoming SSN Reset Request Parameter	[RFC6525]
         * 15	SSN/TSN Reset Request Parameter	[RFC6525]
         * 16	Re-configuration Response Parameter	[RFC6525]
         * 17	Add Outgoing Streams Request Parameter	[RFC6525]
         * 18	Add Incoming Streams Request Parameter	[RFC6525]
         * 19-32767	Unassigned
         * 32768	Reserved for ECN Capable (0x8000)
         * 32770	Random (0x8002)	[RFC4805]
         * 32771	Chunk List (0x8003)	[RFC4895]
         * 32772	Requested HMAC Algorithm Parameter (0x8004)	[RFC4895]
         * 32773	Padding (0x8005)
         * 32776	Supported Extensions (0x8008)	[RFC5061]
         * 32777-49151	Unassigned
         * 49152	Forward TSN supported (0xC000)	[RFC3758]
         * 49153	Add IP Address (0xC001)	[RFC5061]
         * 49154	Delete IP Address (0xC002)	[RFC5061]
         * 49155	Error Cause Indication (0xC003)	[RFC5061]
         * 49156	Set Primary Address (0xC004)	[RFC5061]
         * 49157	Success Indication (0xC005)	[RFC5061]
         * 49158	Adaptation Layer Indication (0xC006)	[RFC5061]
         *
         *
         */

        protected VariableParam readVariable()
        {
            int type = _body.GetUShort();
            int len  = _body.GetUShort();
            int blen = len - 4;

            byte[]  data;
            Unknown var;

            switch (type)
            {
            case 1:
                var = new HeartbeatInfo(1, "HeartbeatInfo");
                break;

            //      2-4	Unassigned
            case 5:
                var = new IPv4Address(5, "IPv4Address");
                break;

            case 6:
                var = new IPv6Address(6, "IPv6Address");
                break;

            case 7:
                var = new StateCookie(7, "StateCookie");
                break;

            case 8:
                var = new UnrecognizedParameters(8, "UnrecognizedParameters");
                break;

            case 9:
                var = new CookiePreservative(9, "CookiePreservative");
                break;

            //      10	Unassigned
            case 11:
                var = new HostNameAddress(11, "HostNameAddress");
                break;

            case 12:
                var = new SupportedAddressTypes(12, "SupportedAddressTypes");
                break;

            case 13:
                var = new OutgoingSSNResetRequestParameter(13, "OutgoingSSNResetRequestParameter");
                break;

            case 14:
                var = new IncomingSSNResetRequestParameter(14, "IncomingSSNResetRequestParameter");
                break;

            case 15:
                var = new SSNTSNResetRequestParameter(15, "SSNTSNResetRequestParameter");
                break;

            case 16:
                var = new ReconfigurationResponseParameter(16, "ReconfigurationResponseParameter");
                break;

            case 17:
                var = new AddOutgoingStreamsRequestParameter(17, "AddOutgoingStreamsRequestParameter");
                break;

            case 18:
                var = new AddIncomingStreamsRequestParameter(18, "AddIncomingStreamsRequestParameter");
                break;

            //      19-32767	Unassigned
            case 32768:
                var = new Unknown(32768, "ReservedforECNCapable");
                break;

            case 32770:
                var = new RandomParam(32770, "Random");
                break;

            case 32771:
                var = new ChunkListParam(32771, "ChunkList");
                break;

            case 32772:
                var = new RequestedHMACAlgorithmParameter(32772, "RequestedHMACAlgorithmParameter");
                break;

            case 32773:
                var = new Unknown(32773, "Padding");
                break;

            case 32776:
                var = new SupportedExtensions(32776, "SupportedExtensions");
                break;

            //      32777-49151	Unassigned
            case 49152:
                var = new ForwardTSNsupported(49152, "ForwardTSNsupported");
                break;

            case 49153:
                var = new Unknown(49153, "AddIPAddress");
                break;

            case 49154:
                var = new Unknown(49154, "DeleteIPAddress");
                break;

            case 49155:
                var = new Unknown(49155, "ErrorCauseIndication");
                break;

            case 49156:
                var = new Unknown(49156, "SetPrimaryAddress");
                break;

            case 49157:
                var = new Unknown(49157, "SuccessIndication");
                break;

            case 49158:
                var = new Unknown(49158, "AdaptationLayerIndication");
                break;

            default:
                var = new Unknown(-1, "Unknown");
                break;
            }
            try {
                var.readBody(_body, blen);
                Logger.Debug("variable type " + var.getType() + " name " + var.getName());
            }
            catch (SctpPacketFormatException ex) {
                Logger.Error(ex.ToString());
            }
            if (_body.hasRemaining())
            {
                int mod = blen % 4;
                if (mod != 0)
                {
                    for (int pad = mod; pad < 4; pad++)
                    {
                        _body.GetByte();
                    }
                }
            }
            return(var);
        }