예제 #1
0
            public static PeerAddressIp Decode(XdrDataInputStream stream)
            {
                PeerAddressIp decodedPeerAddressIp = new PeerAddressIp();
                IPAddrType    discriminant         = IPAddrType.Decode(stream);

                decodedPeerAddressIp.Discriminant = discriminant;
                switch (decodedPeerAddressIp.Discriminant.InnerValue)
                {
                case IPAddrType.IPAddrTypeEnum.IPv4:
                    int ipv4size = 4;
                    decodedPeerAddressIp.Ipv4 = new byte[ipv4size];
                    stream.Read(decodedPeerAddressIp.Ipv4, 0, ipv4size);
                    break;

                case IPAddrType.IPAddrTypeEnum.IPv6:
                    int ipv6size = 16;
                    decodedPeerAddressIp.Ipv6 = new byte[ipv6size];
                    stream.Read(decodedPeerAddressIp.Ipv6, 0, ipv6size);
                    break;
                }
                return(decodedPeerAddressIp);
            }
예제 #2
0
 public static void Encode(XdrDataOutputStream stream, IPAddrType value)
 {
     stream.WriteInt((int)value.InnerValue);
 }