Ejemplo n.º 1
0
        /// <inheritdoc/>
        public override BlockCodegen Emit(BasicBlockBuilder BasicBlock)
        {
            var lhsAddrCodegen = DestinationAddress.Emit(BasicBlock);

            BasicBlock = lhsAddrCodegen.BasicBlock;
            var rhsValueCodegen = Value.Emit(BasicBlock);

            BasicBlock = rhsValueCodegen.BasicBlock;

            // LLVM AtomicRMW instructions always return the *old* value,
            // but we want the *new* value (with Xchg being the lone
            // exception).
            //
            // We can compute the new value by first performing the RMW
            // and then computing the new value ourselves.

            var rmwOp = BuildAtomicRMW(
                BasicBlock.Builder,
                Op,
                lhsAddrCodegen.Value,
                rhsValueCodegen.Value,
                LLVMAtomicOrdering.LLVMAtomicOrderingSequentiallyConsistent,
                false);

            return(new BlockCodegen(
                       BasicBlock,
                       BuildRMWResult(
                           BasicBlock.Builder,
                           Op,
                           rmwOp,
                           rhsValueCodegen.Value)));
        }
Ejemplo n.º 2
0
        public TripLocationViewModel(
            ISchedulerProvider schedulerProvider,
            INavigationService navigationService,
            ISearchPlaceViewModelFactory searchPlaceViewModelFactory)
        {
            _pickupLocationEditorViewModel      = searchPlaceViewModelFactory.GetPickupLocationEditorViewModel();
            _destinationLocationEditorViewModel = searchPlaceViewModelFactory.GetDestinationLocationEditorViewModel(this);
            _navigationService = navigationService;

            _pickupLocationEditorViewModel.SelectedAddress
            .ObserveOn(schedulerProvider.SynchronizationContextScheduler)
            .Subscribe(address =>
            {
                PickupAddress.SetAddress(address);
                _pickupLocationChanged.OnNext(true);
                _navigationService.GoBack();
            });

            _destinationLocationEditorViewModel.SelectedAddress
            .ObserveOn(schedulerProvider.SynchronizationContextScheduler)
            .Subscribe(address =>
            {
                DestinationAddress.SetAddress(address);
                CanRequest = true;
                _navigationService.GoBack();
            });
        }
Ejemplo n.º 3
0
        protected override void OnInit(EventArgs e)
        {
            base.OnInit(e);

            LocalizeView();

            AddHighlightColors(lstHighlights);
            PopulateLists();
            LoadZones();
            LoadData();

            var sourceAddress = HccApp.ContactServices.Addresses.FindStoreContactAddress();

            SourceAddress.LoadFromAddress(sourceAddress);

            var destinationAdress = new Address();

            destinationAdress.CountryBvin = Country.UnitedStatesCountryBvin;
            destinationAdress.Line1       = "319 N. Clematis St.";
            destinationAdress.Line2       = "Suite 500";
            destinationAdress.RegionBvin  = "FL";
            destinationAdress.City        = "West Palm Beach";
            destinationAdress.PostalCode  = "33401";
            DestinationAddress.LoadFromAddress(destinationAdress);
        }
        public virtual int _GetUniqueIdentifier()
        {
            var hashCode = 399326290;

            hashCode = hashCode * -1521134295 + (Id?.GetHashCode() ?? 0);
            hashCode = hashCode * -1521134295 + (TransportOrderNo?.GetHashCode() ?? 0);
            hashCode = hashCode * -1521134295 + (OrderYear?.GetHashCode() ?? 0);
            hashCode = hashCode * -1521134295 + (DocumentTransportNo?.GetHashCode() ?? 0);
            hashCode = hashCode * -1521134295 + (OrderDate?.GetHashCode() ?? 0);
            hashCode = hashCode * -1521134295 + (DepartureCustomerName?.GetHashCode() ?? 0);
            hashCode = hashCode * -1521134295 + (DepartureAddress?.GetHashCode() ?? 0);
            hashCode = hashCode * -1521134295 + (DepartureCity?.GetHashCode() ?? 0);
            hashCode = hashCode * -1521134295 + (DepartureState?.GetHashCode() ?? 0);
            hashCode = hashCode * -1521134295 + (DestinationName?.GetHashCode() ?? 0);
            hashCode = hashCode * -1521134295 + (DestinationAddress?.GetHashCode() ?? 0);
            hashCode = hashCode * -1521134295 + (DestinationCity?.GetHashCode() ?? 0);
            hashCode = hashCode * -1521134295 + (DestinationState?.GetHashCode() ?? 0);
            hashCode = hashCode * -1521134295 + (Qty?.GetHashCode() ?? 0);
            hashCode = hashCode * -1521134295 + (OrderWeight?.GetHashCode() ?? 0);
            hashCode = hashCode * -1521134295 + (Volume?.GetHashCode() ?? 0);
            hashCode = hashCode * -1521134295 + (Pallet?.GetHashCode() ?? 0);
            hashCode = hashCode * -1521134295 + (RetiredDate?.GetHashCode() ?? 0);
            hashCode = hashCode * -1521134295 + (DeliveryDate?.GetHashCode() ?? 0);
            hashCode = hashCode * -1521134295 + (Note?.GetHashCode() ?? 0);
            hashCode = hashCode * -1521134295 + (CallCustomerBefore?.GetHashCode() ?? 0);
            hashCode = hashCode * -1521134295 + (Telephone?.GetHashCode() ?? 0);
            hashCode = hashCode * -1521134295 + (DayClosed?.GetHashCode() ?? 0);
            hashCode = hashCode * -1521134295 + (Urgent?.GetHashCode() ?? 0);
            return(hashCode);
        }
Ejemplo n.º 5
0
        private byte[] GetHeaderBytes()
        {
            //TODO - the following things don't work (because of endianism)
            // Identification + Flags + Fragment Offset
            // Header Checksum

            List <byte>   bytes  = new List <byte>();
            List <UInt32> fields = new List <UInt32>();

            //Add the packetsections together into 32-bit words
            //UInt32 field1 = 0;
            UInt32 xVersion       = (UInt32)(this.Version << 28);
            UInt32 xHeaderLength  = (UInt32)(this.HeaderLength << 24);
            UInt32 xTypeOfService = (UInt32)(this.TypeOfService << 16);
            UInt32 xTotalLength   = (UInt32)(this.TotalLength << 0);

            //field1 = ;
            fields.Add(HostToNetwork(xVersion + xHeaderLength + xTypeOfService + xTotalLength));

            //UInt32 field2 = (UInt32)((this.Identification << 16) | ((byte)(this.FragmentFlags)) << 12 | (this.FragmentOffset << 1));
            UInt32 field2   = 0;
            UInt32 Identity = (UInt32)(this.Identification << 16);
            UInt32 Flags    = (UInt32)((byte)(this.FragmentFlags)) << 14;
            UInt32 Offset   = (UInt32)((this.FragmentOffset) & (UInt16)0xFF);

            field2 = Identity + Flags + Offset;
            fields.Add(HostToNetwork(field2));

            //UInt32 field3 = (UInt32)((this.TimeToLive << 0) | (((byte)(this.Protocol)) << 8) | (UInt16)(this.HeaderChecksum << 16));
            UInt32 xTimeToLive     = (UInt32)(this.TimeToLive << 24);
            UInt32 xProtocol       = (UInt32)((byte)this.Protocol << 16);
            UInt32 xHeaderChecksum = (UInt32)(this.HeaderChecksum << 0);

            //Console.WriteLine("Field3: " + field3.ToBinary(32));
            fields.Add(HostToNetwork(xTimeToLive + xProtocol + xHeaderChecksum));

            //Split the 32-bit words into bytes
            for (int i = 0; i < fields.Count; i++)
            {
                bytes.Add((byte)(fields[i] >> 0));
                bytes.Add((byte)(fields[i] >> 8));
                bytes.Add((byte)(fields[i] >> 16));
                bytes.Add((byte)(fields[i] >> 24));
            }

            //Source and Destination
            foreach (byte b in SourceAddress.ToByteArray())
            {
                bytes.Add(b);
            }

            foreach (byte b in DestinationAddress.ToByteArray())
            {
                bytes.Add(b);
            }

            //TODO - Options field

            return(bytes.ToArray());
        }
Ejemplo n.º 6
0
    private void BindShippingAddress(DestinationAddress shippingAddress)
    {
        StringBuilder shippingAdr = new StringBuilder();

        shippingAdr.Append("<table cellspacing=\"0\" cellpadding=\"0\" border=\"0\" width=\"100%\"><tr>");
        shippingAdr.Append("<td>Customer Name:</td>");
        shippingAdr.Append("<td>" + shippingAddress.FirstName + " " + shippingAddress.LastName + "</td></tr><tr>");
        shippingAdr.Append("<td>Address:</td>");
        shippingAdr.Append("<td>" + shippingAddress.ToAddress + "</td></tr><tr>");
        if (!string.IsNullOrEmpty(shippingAddress.ToAddress2))
        {
            shippingAdr.Append("<td>Address2:</td>");
            shippingAdr.Append("<td>" + shippingAddress.ToAddress2 + "</td></tr><tr>");
        }
        shippingAdr.Append("<td>Country:</td>");
        shippingAdr.Append("<td>" + shippingAddress.ToCountry + "</td></tr><tr>");
        shippingAdr.Append("<td>City:</td>");
        shippingAdr.Append("<td>" + shippingAddress.ToCity + "</td></tr><tr>");
        shippingAdr.Append("<td>State:</td>");
        shippingAdr.Append("<td>" + shippingAddress.ToState + "</td></tr><tr>");
        shippingAdr.Append("<td>ZipCode:</td>");
        shippingAdr.Append("<td>" + shippingAddress.Zip + "</td></tr><tr>");
        shippingAdr.Append("<td>Email Address:</td>");
        shippingAdr.Append("<td>" + shippingAddress.Email + "</td></tr><tr>");
        shippingAdr.Append("<td>Phone No:</td>");
        shippingAdr.Append("<td>" + shippingAddress.Phone + "</td></tr>");
        shippingAdr.Append("</table>");
        ltShippingAddress.Text = shippingAdr.ToString();

        _toAddress = shippingAddress;
        _toAddress.ToCountryName = "";
        Session["sl_toAddress"]  = _toAddress;
    }
Ejemplo n.º 7
0
 /// <summary>
 /// Converts the packet to a string.
 /// </summary>
 /// <returns></returns>
 public override String ToString()
 {
     return(base.ToString() + "\r\nIPv6 Packet [\r\n"
            + "\tIPv6 Source Address: " + SourceAddress.ToString() + ", \r\n"
            + "\tIPv6 Destination Address: " + DestinationAddress.ToString() + "\r\n"
            + "]");
     // TODO Implement Better ToString
 }
        public override void Execute()
        {
            base.Execute();

            // Add some validation based on the type of RuleCollection (SNAT will be supported later)
            // if (MNM.AzureFirewallNatRCActionType.Dnat.Equals(ActionType))
            {
                if (DestinationAddress.Length != 1)
                {
                    throw new ArgumentException("Only one destination address is accepted.", nameof(DestinationAddress));
                }

                if (DestinationPort.Length != 1)
                {
                    throw new ArgumentException("Only one destination port is accepted.", nameof(DestinationPort));
                }

                ValidateIsSingleIpNotRange(DestinationAddress.Single());
                if (TranslatedAddress != null)
                {
                    ValidateIsSingleIpNotRange(TranslatedAddress);
                }
                if (TranslatedFqdn != null)
                {
                    ValidateIsFqdn(TranslatedFqdn);
                }

                // Only one of TranslatedAddress or TranslatedFqdn is allowed
                if ((TranslatedAddress != null) && (TranslatedFqdn != null))
                {
                    throw new ArgumentException("Both TranslatedAddress and TranslatedFqdn not allowed");
                }

                // One of TranslatedAddress or TranslatedFqdn must be present
                if ((TranslatedAddress == null) && (TranslatedFqdn == null))
                {
                    throw new ArgumentException("Either TranslatedAddress or TranslatedFqdn is required");
                }

                ValidateIsSinglePortNotRange(DestinationPort.Single());
                ValidateIsSinglePortNotRange(TranslatedPort);
            }

            var networkRule = new PSAzureFirewallNatRule
            {
                Name                 = this.Name,
                Description          = this.Description,
                Protocols            = this.Protocol?.ToList(),
                SourceAddresses      = this.SourceAddress?.ToList(),
                DestinationAddresses = this.DestinationAddress?.ToList(),
                DestinationPorts     = this.DestinationPort?.ToList(),
                TranslatedAddress    = this.TranslatedAddress,
                TranslatedFqdn       = this.TranslatedFqdn,
                TranslatedPort       = this.TranslatedPort
            };

            WriteObject(networkRule);
        }
Ejemplo n.º 9
0
        public override int GetHashCode()
        {
            var hash = Type.GetHashCode();

            hash ^= SourceAddress?.GetHashCode() ?? 0;
            hash ^= DestinationAddress?.GetHashCode() ?? 0;
            hash ^= SourcePort;
            hash ^= DestinationPort << 16;

            return(hash);
        }
Ejemplo n.º 10
0
 protected override void WriteData(AcnBinaryWriter data)
 {
     data.Write(ComponentId.ToByteArray());
     data.WriteOctet(MemberId);
     data.WriteOctet(ChannelNumber);
     data.WriteOctet(ReciprocalChannel);
     data.WriteOctet(TotalSequenceNumber);
     data.WriteOctet(ReliableSequenceNumber);
     DestinationAddress.WriteData(data);
     ChannelParameterBlock.WriteData(data);
     data.Write(AdHocExpiry);
 }
Ejemplo n.º 11
0
        /// <summary>
        /// Compare two instances
        /// </summary>
        /// <param name="obj">
        /// A <see cref="object" />
        /// </param>
        /// <returns>
        /// A <see cref="bool" />
        /// </returns>
        public override bool Equals(object obj)
        {
            // Check for null values and compare run-time types.
            if ((obj == null) || (GetType() != obj.GetType()))
            {
                return(false);
            }


            var wol = (WakeOnLanPacket)obj;

            return(DestinationAddress.Equals(wol.DestinationAddress));
        }
Ejemplo n.º 12
0
        public override byte[] GetBytes()
        {
            int nLength = 6;

            if (AddressType == AddressType.IPV4)
            {
                nLength += 4;
            }
            else if (AddressType == AddressType.IPV6)
            {
                nLength += 16;
            }
            else if (AddressType == AddressType.DomainName)
            {
                nLength += (1 + DestinationDomain.Length);
            }

            m_bBytes    = new byte[nLength];
            m_bBytes[0] = Version;
            m_bBytes[1] = (byte)SOCKSCommand;
            m_bBytes[2] = (byte)Reserved;
            m_bBytes[3] = (byte)AddressType;
            if (AddressType == AddressType.IPV4)
            {
                byte[] bAddr = DestinationAddress.GetAddressBytes();
                Array.Copy(bAddr, 0, m_bBytes, 4, bAddr.Length);

                m_bBytes[4 + bAddr.Length]     = (byte)((DestinationPort & 0xFF00) >> 8);
                m_bBytes[4 + bAddr.Length + 1] = (byte)((DestinationPort & 0xFF) >> 0);
            }
            else if (AddressType == AddressType.IPV6)
            {
                byte[] bAddr = DestinationAddress.GetAddressBytes();
                Array.Copy(bAddr, 0, m_bBytes, 4, bAddr.Length);

                m_bBytes[4 + bAddr.Length]     = (byte)((DestinationPort & 0xFF00) >> 8);
                m_bBytes[4 + bAddr.Length + 1] = (byte)((DestinationPort & 0xFF) >> 0);
            }
            else if (AddressType == AddressType.DomainName)
            {
                byte[] bAddr = System.Text.UTF8Encoding.UTF8.GetBytes(DestinationDomain);
                m_bBytes[4] = (byte)bAddr.Length;
                Array.Copy(bAddr, 0, m_bBytes, 4 + 1, bAddr.Length);

                m_bBytes[4 + 1 + bAddr.Length]     = (byte)((DestinationPort & 0xFF00) >> 8);
                m_bBytes[4 + 1 + bAddr.Length + 1] = (byte)((DestinationPort & 0xFF) >> 0);
            }


            return(m_bBytes);
        }
Ejemplo n.º 13
0
        /// <summary>
        /// Decodes the submit_multi response from the SMSC.
        /// </summary>
        protected override void DecodeSmscResponse()
        {
            byte[] remainder = BytesAfterHeader;

            ServiceType      = SmppStringUtil.GetCStringFromBody(ref remainder);
            SourceAddressTon = (TonType)remainder[0];
            SourceAddressNpi = (NpiType)remainder[1];
            SourceAddress    = SmppStringUtil.GetCStringFromBody(ref remainder, 2);

            //the SMSC might not send back the number of destinations,
            //so check if it did
            if (remainder.Length > 0)
            {
                _numberOfDests       = remainder[0];
                DestinationAddresses = new DestinationAddress[NumberOfDestinations];

                //trim off the number of destinations
                long   length       = remainder.Length - 1;
                byte[] newRemainder = new byte[length];
                Array.Copy(remainder, 1, newRemainder, 0, length);
                remainder    = newRemainder;
                newRemainder = null;

                for (int i = 0; i < _destinationAddresses.Length; i++)
                {
                    _destinationAddresses[i] = new DestinationAddress(ref remainder);
                }
            }

            EsmClass             = remainder[0];
            ProtocolId           = remainder[1];
            PriorityFlag         = (PriorityType)remainder[2];
            ScheduleDeliveryTime = SmppStringUtil.GetCStringFromBody(ref remainder, 3);
            ValidityPeriod       = SmppStringUtil.GetCStringFromBody(ref remainder);
            RegisteredDelivery   = (RegisteredDeliveryType)remainder[0];
            ReplaceIfPresentFlag = (remainder[1] == 0)? false : true;
            DataCoding           = (DataCoding)remainder[2];
            SmDefaultMessageId   = remainder[3];
            _SmLength            = remainder[4];
            ShortMessage         = SmppStringUtil.GetStringFromBody(ref remainder, 5, 5 + _SmLength);

            //fill the TLV table if applicable
            TranslateTlvDataIntoTable(remainder);
        }
Ejemplo n.º 14
0
        private void ShowMarkers()
        {
            if (AddressSelectionMode == AddressSelectionMode.DropoffSelection)
            {
                var currentState = ((HomeViewModel)ViewModel.Parent).CurrentViewState;

                if (currentState == HomeViewModelState.BookingStatus || currentState == HomeViewModelState.ManualRidelinq)
                {
                    return;
                }

                SetAnnotation(DestinationAddress, _destinationAnnotation, false);
                SetOverlay(_pickupCenterPin, false);
                SetOverlay(_dropoffCenterPin, true);

                SetAnnotation(PickupAddress, _pickupAnnotation, PickupAddress.HasValidCoordinate());
            }
            else if (AddressSelectionMode == AddressSelectionMode.PickupSelection)
            {
                var currentState = ((HomeViewModel)ViewModel.Parent).CurrentViewState;

                if (currentState == HomeViewModelState.BookingStatus || currentState == HomeViewModelState.ManualRidelinq)
                {
                    // Don't display movable pickup or dropoff pins
                    return;
                }

                SetAnnotation(PickupAddress, _pickupAnnotation, false);
                SetOverlay(_dropoffCenterPin, false);
                SetOverlay(_pickupCenterPin, true);

                SetAnnotation(DestinationAddress, _destinationAnnotation, DestinationAddress.HasValidCoordinate());
            }
            else
            {
                SetOverlay(_pickupCenterPin, false);
                SetOverlay(_dropoffCenterPin, false);

                SetAnnotation(DestinationAddress, _destinationAnnotation, DestinationAddress.HasValidCoordinate());

                SetAnnotation(PickupAddress, _pickupAnnotation, PickupAddress.HasValidCoordinate());
            }
        }
Ejemplo n.º 15
0
        public byte[] PacketToBytes()
        {
            List <byte> packetbytes = new List <byte>();

            PacketLength = PacketHeaderLength + Payload.Length;

            packetbytes.AddRange(BitConverter.GetBytes(PacketLength));
            packetbytes.AddRange(BitConverter.GetBytes(ID));
            packetbytes.AddRange(SourceAddress.GetAddressBytes());
            packetbytes.AddRange(DestinationAddress.GetAddressBytes());
            packetbytes.AddRange(BitConverter.GetBytes(Frequency));
            packetbytes.AddRange(BitConverter.GetBytes(Bandwith));
            packetbytes.AddRange(BitConverter.GetBytes(BitRate));
            packetbytes.AddRange(BitConverter.GetBytes(Performance));
            packetbytes.AddRange(BitConverter.GetBytes(Port));
            packetbytes.AddRange(BitConverter.GetBytes(slotWindow.FirstSlot));
            packetbytes.AddRange(BitConverter.GetBytes(slotWindow.NumberofSlots));
            packetbytes.AddRange(Encoding.ASCII.GetBytes(Payload ?? ""));
            return(packetbytes.ToArray());
        }
Ejemplo n.º 16
0
        public override bool Equals(object obj)
        {
            if (obj == this)
            {
                return(true);
            }

            var o = obj as SocketTuple;

            if (o == null)
            {
                return(false);
            }

            return
                (Type == o.Type &&
                 SourceAddress.Equals(o.SourceAddress) &&
                 DestinationAddress.Equals(o.DestinationAddress) &&
                 SourcePort == o.SourcePort &&
                 DestinationPort == o.DestinationPort);
        }
Ejemplo n.º 17
0
 private void GetOrderDetails(int storeId, int portalId, int orderId, string cultureName)
 {
     try
     {
         OrderLabel orderDetail = GetOrderDetailByOrderId(orderId, storeId, portalId, cultureName);
         if (orderDetail != null)
         {
             OriginAddress billingAddress = GetUserBillingAddress(orderDetail.UserBillingAddressId);
             BindBillingAddress(billingAddress);
             int providerId = GetShippingProviderIdByShippingMethod(orderDetail.ShippingMethodId);
             ProviderSetting(providerId, storeId, portalId);
             Session["labelOrderInfo"]  = orderDetail;
             lblUserShippingMethod.Text = string.Format("{0}:{1}", "User Selected Method:",
                                                        orderDetail.ShippingMethodName);
             DestinationAddress shippingAddress = GetUserShippingAddress(orderDetail.UserShippingAddressId, storeId, portalId);
             BindShippingAddress(shippingAddress);
             AspxCommerce.Core.WareHouseAddress wareHouseAddress = GetWareHouseAddress(storeId, portalId);
             BindWareHouseAddress(wareHouseAddress);
             if (shippingAddress.ToCountry != null && shippingAddress.ToCountry.ToLower().Trim() != "united states" && shippingAddress.ToCountry.ToLower().Trim() != wareHouseAddress.Country.ToLower().Trim())
             {
                 int count = rblLabelTypeList.Items.Count;
                 for (int i = 0; i < count; i++)
                 {
                     rblLabelTypeList.Items[i].Enabled = false;
                 }
                 rblLabelTypeList.Items.Add(new ListItem()
                 {
                     Text     = "International Label",
                     Selected = true,
                     Value    = "internationallabel"
                 });
             }
             BindPackageDetails(orderDetail);
         }
     }
     catch (Exception ex)
     {
         ProcessException(ex);
     }
 }
        protected internal override object newInitialMessage(IChannelHandlerContext ctx)
        {
            String address = DestinationAddress.ToString();

            IFullHttpRequest req = new DefaultFullHttpRequest(Codecs.Http.HttpVersion.Http11, HttpMethod.Connect, address, Unpooled.Empty, false);

            req.Headers.Set(HttpHeaderNames.Host, address);

            if (authorization != null)
            {
                req.Headers.Remove(HttpHeaderNames.ProxyAuthorization);

                req.Headers.Set(HttpHeaderNames.ProxyAuthorization, authorization);
            }

            if (outboundHeaders != null)
            {
                req.Headers.Add(outboundHeaders);
            }

            return(req);
        }
Ejemplo n.º 19
0
        public byte[] convertToBytes()
        {
            List <byte> package_in_Bytes = new List <byte>();
            // const int headerLength=24+label
            int headerLength = 24 + labelStack.GetLengthOfStack();

            package_length = payload.Length + headerLength;

            package_in_Bytes.AddRange(labelStack.GetStackInBytes());           //length of stack
            package_in_Bytes.AddRange(BitConverter.GetBytes(messageID));       // 4 bytes
            package_in_Bytes.AddRange(BitConverter.GetBytes(package_length));  //4bytes
            package_in_Bytes.AddRange(BitConverter.GetBytes(TTL));             // 2 bytes
            package_in_Bytes.AddRange(SourceAddress.GetAddressBytes());        //4 bytes
            package_in_Bytes.AddRange(DestinationAddress.GetAddressBytes());   // 4 bytes
            package_in_Bytes.AddRange(BitConverter.GetBytes(Port));            // 2 bytes
            package_in_Bytes.AddRange(CurrentNodeIP.GetAddressBytes());        //4 bytes
            package_in_Bytes.AddRange(Encoding.ASCII.GetBytes(payload ?? "")); // length of payload

            //package_length = package_in_Bytes.Count;
            //Console.WriteLine("Package length: " +package_length);
            return(package_in_Bytes.ToArray());
        }
Ejemplo n.º 20
0
        public override void Execute()
        {
            base.Execute();

            // Add some validation based on the type of RuleCollection (SNAT will be supported later)
            // if (MNM.AzureFirewallNatRCActionType.Dnat.Equals(ActionType))
            {
                if (DestinationAddress.Length != 1)
                {
                    throw new ArgumentException("Only one destination address is accepted.", nameof(DestinationAddress));
                }

                if (DestinationPort.Length != 1)
                {
                    throw new ArgumentException("Only one destination port is accepted.", nameof(DestinationPort));
                }

                ValidateIsSingleIpNotRange(DestinationAddress.Single());
                ValidateIsSingleIpNotRange(TranslatedAddress);

                ValidateIsSinglePortNotRange(DestinationPort.Single());
                ValidateIsSinglePortNotRange(TranslatedPort);
            }

            var networkRule = new PSAzureFirewallNatRule
            {
                Name                 = this.Name,
                Description          = this.Description,
                Protocols            = this.Protocol?.ToList(),
                SourceAddresses      = this.SourceAddress?.ToList(),
                DestinationAddresses = this.DestinationAddress?.ToList(),
                DestinationPorts     = this.DestinationPort?.ToList(),
                TranslatedAddress    = this.TranslatedAddress,
                TranslatedPort       = this.TranslatedPort
            };

            WriteObject(networkRule);
        }
Ejemplo n.º 21
0
        /// <summary cref="Packet.ToString(StringOutputType)" />
        public override string ToString(StringOutputType outputFormat)
        {
            var    buffer      = new StringBuilder();
            string color       = "";
            string colorEscape = "";

            if (outputFormat == StringOutputType.Colored || outputFormat == StringOutputType.VerboseColored)
            {
                color       = Color;
                colorEscape = AnsiEscapeSequences.Reset;
            }

            if (outputFormat == StringOutputType.Normal || outputFormat == StringOutputType.Colored)
            {
                // build the output string
                buffer.AppendFormat("{0}[IPv4Packet: SourceAddress={2}, DestinationAddress={3}, HeaderLength={4}, Protocol={5}, TimeToLive={6}]{1}",
                                    color,
                                    colorEscape,
                                    SourceAddress,
                                    DestinationAddress,
                                    HeaderLength,
                                    Protocol,
                                    TimeToLive);
            }

            if (outputFormat == StringOutputType.Verbose || outputFormat == StringOutputType.VerboseColored)
            {
                // collect the properties and their value
                Dictionary <string, string> properties = new Dictionary <string, string>();
                properties.Add("version", Version.ToString());
                // FIXME: Header length output is incorrect
                properties.Add("header length", HeaderLength + " bytes");
                string diffServices = Convert.ToString(DifferentiatedServices, 2).PadLeft(8, '0').Insert(4, " ");
                properties.Add("differentiated services", "0x" + DifferentiatedServices.ToString("x").PadLeft(2, '0'));
                properties.Add("", diffServices.Substring(0, 7) + ".. = [" + (DifferentiatedServices >> 2) + "] code point");
                properties.Add(" ", ".... .." + diffServices[6] + ". = [" + diffServices[6] + "] ECN");
                properties.Add("  ", ".... ..." + diffServices[7] + " = [" + diffServices[7] + "] ECE");
                properties.Add("total length", TotalLength.ToString());
                properties.Add("identification", "0x" + Id.ToString("x") + " (" + Id + ")");
                string flags = Convert.ToString(FragmentFlags, 2).PadLeft(8, '0').Substring(5, 3);
                properties.Add("flags", "0x" + FragmentFlags.ToString("x").PadLeft(2, '0'));
                properties.Add("   ", flags[0] + ".. = [" + flags[0] + "] reserved");
                properties.Add("    ", "." + flags[1] + ". = [" + flags[1] + "] don't fragment");
                properties.Add("     ", ".." + flags[2] + " = [" + flags[2] + "] more fragments");
                properties.Add("fragment offset", FragmentOffset.ToString());
                properties.Add("time to live", TimeToLive.ToString());
                properties.Add("protocol", Protocol.ToString() + " (0x" + Protocol.ToString("x") + ")");
                properties.Add("header checksum", "0x" + Checksum.ToString("x") + " [" + (ValidChecksum ? "valid" : "invalid") + "]");
                properties.Add("source", SourceAddress.ToString());
                properties.Add("destination", DestinationAddress.ToString());

                // calculate the padding needed to right-justify the property names
                int padLength = Utils.RandomUtils.LongestStringLength(new List <string>(properties.Keys));

                // build the output string
                buffer.AppendLine("IP:  ******* IPv4 - \"Internet Protocol (Version 4)\" - offset=? length=" + TotalPacketLength);
                buffer.AppendLine("IP:");
                foreach (var property in properties)
                {
                    if (property.Key.Trim() != "")
                    {
                        buffer.AppendLine("IP: " + property.Key.PadLeft(padLength) + " = " + property.Value);
                    }
                    else
                    {
                        buffer.AppendLine("IP: " + property.Key.PadLeft(padLength) + "   " + property.Value);
                    }
                }
                buffer.AppendLine("IP:");
            }

            // append the base class output
            buffer.Append(base.ToString(outputFormat));

            return(buffer.ToString());
        }
Ejemplo n.º 22
0
        public void DestinationAddressConstructorTest()
        {
            DestinationAddress target = new DestinationAddress();

            Assert.AreEqual(AttributeType.DestinationAddress, target.AttributeType);
        }
Ejemplo n.º 23
0
        /// <summary>
        /// Decodes the submit_multi response from the SMSC.
        /// </summary>
        protected override void DecodeSmscResponse()
        {
            byte[] remainder = BytesAfterHeader;

            ServiceType = SmppStringUtil.GetCStringFromBody(ref remainder);
            SourceAddressTon =(TonType)remainder[0];
            SourceAddressNpi =(NpiType)remainder[1];
            SourceAddress = SmppStringUtil.GetCStringFromBody(ref remainder, 2);

            //the SMSC might not send back the number of destinations,
            //so check if it did
            if(remainder.Length > 0)
            {
                _NumberOfDests = remainder[0];
                DestinationAddresses = new DestinationAddress[NumberOfDestinations];

                //trim off the number of destinations
                long length = remainder.Length - 1;
                byte[] newRemainder = new byte[length];
                Array.Copy(remainder, 1, newRemainder, 0, length);
                remainder = newRemainder;
                newRemainder = null;

                for(int i = 0; i < _DestinationAddresses.Length; i++)
                {
                    _DestinationAddresses[i] = new DestinationAddress(ref remainder);
                }
            }

            EsmClass = remainder[0];
            ProtocolId = remainder[1];
            PriorityFlag =(PriorityType)remainder[2];
            ScheduleDeliveryTime = SmppStringUtil.GetCStringFromBody(ref remainder, 3);
            ValidityPeriod = SmppStringUtil.GetCStringFromBody(ref remainder);
            RegisteredDelivery =(RegisteredDeliveryType)remainder[0];
            ReplaceIfPresentFlag =(remainder[1] == 0)? false : true;
            DataCoding =(DataCoding)remainder[2];
            SmDefaultMessageId = remainder[3];
            _SmLength = remainder[4];
            ShortMessage = SmppStringUtil.GetStringFromBody(ref remainder, 5, 5 + _SmLength);

            //fill the TLV table if applicable
            TranslateTlvDataIntoTable(remainder);
        }
Ejemplo n.º 24
0
        protected override void Process(Timer timer)
        {
            List <SMSQueue> queue = Context.GetSMSToSend(Settings.Default.SMSSendBatchSize).ToList();

            foreach (SMSQueue sms in queue)
            {
                try
                {
                    Trace.TraceInformation("Отправка сообщения {0}", sms.Id);
                    DestinationAddress[] dests = sms.DestinationMap.Select
                                                 (
                        item =>
                        item.IsDistributionList ?
                        new DestinationAddress(item.destination_addr) :
                        new DestinationAddress(
                            (Pdu.TonType)item.dest_addr_ton,
                            (Pdu.NpiType)item.dest_addr_npi,
                            item.destination_addr)
                                                 ).ToArray();
                    MessageLcd2 sendPdu;
                    if (sms.number_of_dests > 1)
                    {
                        RoaminSMPP.Packet.Request.SmppSubmitMulti multi = new RoaminSMPP.Packet.Request.SmppSubmitMulti();
                        multi.DestinationAddresses = dests;
                        sendPdu = multi;
                    }
                    else
                    {
                        DestinationAddress dest = dests[0];
                        RoaminSMPP.Packet.Request.SmppSubmitSm single = new RoaminSMPP.Packet.Request.SmppSubmitSm()
                        {
                            DestinationAddress    = dest.DestAddress,
                            DestinationAddressNpi = dest.DestinationAddressNpi,
                            DestinationAddressTon = dest.DestinationAddressTon
                        };
                        sendPdu = single;
                    }
                    Hashtable tlvTable = new Hashtable();
                    sms.SMSTLV.ToList().ForEach(item => tlvTable.Add(Convert.ToUInt16(item.Tag), Convert.FromBase64String(item.Value)));
                    sendPdu.TlvTable.tlvTable    = tlvTable;
                    sendPdu.SequenceNumber       = (uint)sms.sequence_number;
                    sendPdu.ServiceType          = sms.service_type;
                    sendPdu.SourceAddress        = sms.source_addr;
                    sendPdu.EsmClass             = (byte)sms.esm_class;
                    sendPdu.ProtocolId           = (Pdu.SmppVersionType)sms.protocol_id;
                    sendPdu.PriorityFlag         = (Pdu.PriorityType)sms.priority_flag;
                    sendPdu.ScheduleDeliveryTime = sms.schedule_delivery_time;
                    sendPdu.ValidityPeriod       = sms.validity_period;
                    sendPdu.RegisteredDelivery   = (Pdu.RegisteredDeliveryType)sms.registered_delivery;
                    sendPdu.ReplaceIfPresentFlag = sms.replace_if_present_flag >= 1 ? true : false;
                    sendPdu.DataCoding           = (Pdu.DataCodingType)sms.data_coding;
                    sendPdu.SmDefaultMessageId   = (byte)(sms.sm_default_msg_id ?? 0);
                    sendPdu.ShortMessage         = sms.short_message.GetBytesFromHex();
                    RoaminSMPP.SMPPCommunicator connection = SMPPPool.GetConnection(sms.ProviderId.Value, sms.source_addr);
                    sendPdu.SourceAddressNpi   = connection.NpiType;
                    sendPdu.SourceAddressTon   = connection.TonType;
                    sendPdu.RegisteredDelivery = (Pdu.RegisteredDeliveryType)sms.registered_delivery;
                    connection.SendPdu(sendPdu);
                    Context.GetStatusUpdater().UpdateSMSStatus(sms.Id, null, SMSStatus.Send, null, RoaminSMPP.Packet.Pdu.MessageStateType.Accepted);
                    lock (_syncLock)
                    {
                        _sentMessages.Add(sendPdu.SequenceNumber, sms.Id);
                    }
                }
                catch (Exception ex)
                {
                    //TODO: Реализовать логику RetryCount
                    Trace.TraceWarning("Невозможно отправить сообщение с Id = {0}, ошибка: {1}", sms.Id, ex);
                }
            }
        }
Ejemplo n.º 25
0
        public string BuildXml()
        {
            string result = string.Empty;

            StringWriter  sw = new StringWriter(System.Globalization.CultureInfo.InvariantCulture);
            XmlTextWriter xw = new XmlTextWriter(sw);

            xw.Formatting  = Formatting.Indented;
            xw.Indentation = 2;

            xw.WriteStartDocument();

            //Preamble
            xw.WriteStartElement("FDXRateRequest");
            xw.WriteAttributeString("xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance");
            xw.WriteAttributeString("xsi:noNamespaceSchemaLocation", "FDXRateRequest.xsd");

            RequestHeader.WriteToXml(xw, "RequestHeader");
            xw.WriteElementString("ReturnShipmentIndicator", ReturnType.ToString());
            xw.WriteElementString("ShipDate", ShipDate.ToString("yyyy-MM-dd"));
            xw.WriteElementString("DropoffType", this.globals.DefaultDropOffType.ToString());
            xw.WriteElementString("Service", Service.ToString());
            xw.WriteElementString("Packaging", Packaging.ToString());
            xw.WriteElementString("WeightUnits", WeightUnits.ToString());
            xw.WriteElementString("Weight", _Weight.ToString("0.0"));
            xw.WriteElementString("ListRate", globals.UseListRates ? "1" : "0");

            OriginAddress.WriteToXml(xw, "OriginAddress");
            DestinationAddress.WriteToXml(xw, "DestinationAddress");

            xw.WriteStartElement("Payment");
            xw.WriteElementString("PayorType", "SENDER");
            xw.WriteEndElement();

            if (Packaging == PackageType.YOURPACKAGING)
            {
                Dimensions.WriteToXml(xw, "Dimensions");
            }

            xw.WriteStartElement("DeclaredValue");
            xw.WriteElementString("Value", _DeclaredValue.ToString("0.00"));
            xw.WriteElementString("CurrencyCode", "USD");
            xw.WriteEndElement();

            if (ContainsAlcohol)
            {
                xw.WriteElementString("Alcohol", "1");
            }
            SpecialServices.WriteToXml(xw, "SpecialServices");
            xw.WriteElementString("PackageCount", PackageCount.ToString());

            //_RequestContact.WriteToXml(xw, "Contact")
            //_RequestAddress.WriteToXml(xw, "Address")

            xw.WriteEndDocument();

            xw.Flush();
            xw.Close();

            result = sw.GetStringBuilder().ToString();

            return(result);
        }
Ejemplo n.º 26
0
 public override string ToString()
 {
     return(base.ToString() + $", SourceAddress: {SourceAddress?.ToString() ?? "empty"}, DestinationAddress: {DestinationAddress?.ToString() ?? "empty"}, Version: {Version}, Mdc: {(Mdc != null ? new Hex(Mdc).ToString() : "empty")}");
 }
Ejemplo n.º 27
0
        protected void btnTest_Click(object sender, EventArgs e)
        {
            SaveData();

            var testSettings = new FedExGlobalServiceSettings
            {
                AccountNumber         = AccountNumberField.Text,
                DefaultDropOffType    = (DropOffType)int.Parse(lstDropOffType.SelectedValue),
                DefaultPackaging      = (PackageType)int.Parse(lstPackaging.SelectedValue),
                DiagnosticsMode       = true,
                ForceResidentialRates = chkResidential.Checked,
                MeterNumber           = MeterNumberField.Text.Trim(),
                UserKey                  = KeyField.Text.Trim(),
                UserPassword             = PasswordField.Text.Trim(),
                UseDevelopmentServiceUrl = chkDevelopmentUrl.Checked
            };

            var logger = new TextLogger();

            var testSvc = new FedExProvider(testSettings, logger)
            {
                Settings =
                {
                    ServiceCode = int.Parse(lstServicesTest.SelectedValue),
                    Packaging   = (int)testSettings.DefaultPackaging
                }
            };

            var testShipment = new Shipment
            {
                DestinationAddress = DestinationAddress.GetAsAddress(),
                SourceAddress      = SourceAddress.GetAsAddress()
            };

            var testItem = new Shippable
            {
                BoxHeight     = decimal.Parse(TestHeight.Text),
                BoxLength     = decimal.Parse(TestLength.Text),
                BoxWidth      = decimal.Parse(TestWidth.Text),
                BoxLengthType = LengthType.Inches,
                BoxWeight     = decimal.Parse(TestWeight.Text),
                BoxWeightType = WeightType.Pounds
            };

            testShipment.Items.Add(testItem);

            var sb = new StringBuilder();

            sb.AppendFormat(Localization.GetString("StartingTest"), DateTime.Now);
            sb.Append("<br />");

            var rates = testSvc.RateShipment(testShipment);

            foreach (var r in rates)
            {
                sb.AppendFormat(Localization.GetString("RateFound"), r.EstimatedCost.ToString("C"), r.DisplayName,
                                r.ServiceCodes, r.ServiceId);
                sb.Append("<br />");
            }
            sb.Append("<br />");
            sb.Append(Localization.GetString("Log"));
            sb.Append(":<br />");
            foreach (var m in logger.Messages)
            {
                sb.Append(m + "<br />");
            }
            sb.AppendFormat(Localization.GetString("FinishedTest"), DateTime.Now);

            litTestOuput.Text = sb.ToString();
        }
Ejemplo n.º 28
0
        private void ShowMarkers()
        {
            if (AddressSelectionMode == AddressSelectionMode.DropoffSelection)
            {
                var position = new Position {
                    Latitude = PickupAddress.Latitude, Longitude = PickupAddress.Longitude
                };

                _destinationPin.Visible        = false;
                _pickupOverlay.Visibility      = ViewStates.Invisible;
                _destinationOverlay.Visibility = ViewStates.Visible;

                if (PickupAddress.HasValidCoordinate())
                {
                    _pickupPin.Visible  = true;
                    _pickupPin.Position = new LatLng(position.Latitude, position.Longitude);
                }
                else
                {
                    _pickupPin.Visible = false;
                }
            }
            else if (AddressSelectionMode == AddressSelectionMode.PickupSelection)
            {
                _pickupPin.Visible             = false;
                _destinationOverlay.Visibility = ViewStates.Invisible;
                _pickupOverlay.Visibility      = ViewStates.Visible;

                if (DestinationAddress.HasValidCoordinate())
                {
                    var position = new Position {
                        Latitude = DestinationAddress.Latitude, Longitude = DestinationAddress.Longitude
                    };
                    _destinationPin.Visible  = true;
                    _destinationPin.Position = new LatLng(position.Latitude, position.Longitude);
                }
                else
                {
                    _destinationPin.Visible = false;
                }
            }
            else
            {
                _destinationOverlay.Visibility = ViewStates.Gone;
                _pickupOverlay.Visibility      = ViewStates.Gone;


                if (PickupAddress.HasValidCoordinate())
                {
                    var position = new Position {
                        Latitude = PickupAddress.Latitude, Longitude = PickupAddress.Longitude
                    };
                    _pickupPin.Visible  = true;
                    _pickupPin.Position = new LatLng(position.Latitude, position.Longitude);
                }
                else
                {
                    _pickupPin.Visible = false;
                }

                if (DestinationAddress.HasValidCoordinate())
                {
                    var position = new Position {
                        Latitude = DestinationAddress.Latitude, Longitude = DestinationAddress.Longitude
                    };
                    _destinationPin.Visible  = true;
                    _destinationPin.Position = new LatLng(position.Latitude, position.Longitude);
                }
                else
                {
                    _destinationPin.Visible = false;
                }
            }
        }
Ejemplo n.º 29
0
 public override string ToString()
 {
     return($"{{{Type}, {SourceAddress.IPAddressToString()}:{SourcePort}->{DestinationAddress.IPAddressToString()}:{DestinationPort}}}");
 }
Ejemplo n.º 30
0
 /// <summary>
 /// Returns the string representation of this frame
 /// </summary>
 /// <returns>The string representation of this frame</returns>
 public override string ToString()
 {
     return("IPFrame [version: " + Version.ToString() + ", source: " + SourceAddress.ToString() + ", destination: " + DestinationAddress.ToString() + "]");
 }
Ejemplo n.º 31
0
 public override string ToString()
 {
     return(base.ToString() + $", SourceAddress: {SourceAddress?.ToString() ?? "empty"}, DestinationAddress: {DestinationAddress?.ToString() ?? "empty"}, Version: {Version}, Mdc: {Mdc?.ToHexString() ?? "empty"}");
 }