示例#1
0
        internal static void WriteQueryVersion3(byte[] buffer, int offset, TimeSpan maxResponseTime, IpV4Address groupAddress, bool isSuppressRouterSideProcessing, byte queryRobustnessVariable, TimeSpan queryInterval, IEnumerable <IpV4Address> sourceAddresses)
        {
            ByteArrayExtensions.Write(buffer, offset, (byte)17);
            if (maxResponseTime < TimeSpan.Zero || maxResponseTime > IgmpDatagram.MaxVersion3MaxResponseTime)
            {
                throw new ArgumentOutOfRangeException("maxResponseTime", (object)maxResponseTime, "must be in the range [" + (object)TimeSpan.Zero + ", " + (string)(object)IgmpDatagram.MaxVersion3MaxResponseTime + "]");
            }
            double num1 = maxResponseTime.TotalSeconds * 10.0;
            byte   num2 = num1 < 128.0 ? (byte)num1 : (byte)(double)IgmpDatagram.ValueToCode((int)num1);

            ByteArrayExtensions.Write(buffer, offset + 1, num2);
            ByteArrayExtensions.Write(buffer, offset + 4, groupAddress, Endianity.Big);
            if ((int)queryRobustnessVariable > 7)
            {
                throw new ArgumentOutOfRangeException("queryRobustnessVariable", (object)queryRobustnessVariable, "must be in range [0, 7]");
            }
            ByteArrayExtensions.Write(buffer, offset + 8, (byte)((int)queryRobustnessVariable | (isSuppressRouterSideProcessing ? 8 : 0)));
            if (queryInterval < TimeSpan.Zero || queryInterval > IgmpDatagram.MaxQueryInterval)
            {
                throw new ArgumentOutOfRangeException("queryInterval", (object)maxResponseTime, "must be in the range [" + (object)TimeSpan.Zero + ", " + (string)(object)IgmpDatagram.MaxQueryInterval + "]");
            }
            double totalSeconds = queryInterval.TotalSeconds;
            byte   num3         = totalSeconds < 128.0 ? (byte)totalSeconds : (byte)(double)IgmpDatagram.ValueToCode((int)totalSeconds);

            ByteArrayExtensions.Write(buffer, offset + 9, num3);
            int num4 = 0;

            foreach (IpV4Address ipV4Address in sourceAddresses)
            {
                ByteArrayExtensions.Write(buffer, offset + 12 + 4 * num4, ipV4Address, Endianity.Big);
                ++num4;
            }
            ByteArrayExtensions.Write(buffer, offset + 10, (ushort)num4, Endianity.Big);
            IgmpDatagram.WriteChecksum(buffer, offset, 12 + 4 * num4);
        }
示例#2
0
        internal static void WriteHeader(byte[] buffer, int offset, IgmpMessageType igmpMessageType, TimeSpan maxResponseTime, IpV4Address groupAddress)
        {
            ByteArrayExtensions.Write(buffer, offset, (byte)igmpMessageType);
            double num = maxResponseTime.TotalSeconds * 10.0;

            if (num >= 256.0 || num < 0.0)
            {
                throw new ArgumentOutOfRangeException("maxResponseTime", (object)maxResponseTime, "must be in the range [" + (object)TimeSpan.Zero + ", " + (string)(object)TimeSpan.FromSeconds(25.5) + "]");
            }
            ByteArrayExtensions.Write(buffer, offset + 1, (byte)num);
            ByteArrayExtensions.Write(buffer, offset + 4, groupAddress, Endianity.Big);
            IgmpDatagram.WriteChecksum(buffer, offset, 8);
        }
示例#3
0
        internal static void WriteReportVersion3(byte[] buffer, int offset, IEnumerable <IgmpGroupRecord> groupRecords)
        {
            ByteArrayExtensions.Write(buffer, offset, (byte)34);
            ushort num     = (ushort)0;
            int    offset1 = offset + 8;

            foreach (IgmpGroupRecord igmpGroupRecord in groupRecords)
            {
                IgmpGroupRecordDatagram.Write(buffer, ref offset1, igmpGroupRecord.RecordType, igmpGroupRecord.AuxiliaryData, igmpGroupRecord.MulticastAddress, igmpGroupRecord.SourceAddresses);
                ++num;
            }
            ByteArrayExtensions.Write(buffer, offset + 6, num, Endianity.Big);
            IgmpDatagram.WriteChecksum(buffer, offset, offset1 - offset);
        }