PingPlotter Script V4.00
ScriptType=Startup
Language=VBScript
DefaultEnabled=1
This script will allow editing of the source adapter address for the selected engine.
---- Do not edit this line, or anything above it ----
option explicit

' Set up an event to call when each new target is created - this overrides the default
' setting value and writes in our edits (if they exist).
Events.SetEvent MainForm, "OnNewTargetView", "CreateNewTarget"

' Create a new menu
dim NewMenu
set NewMenu = MainForm.CreateAppObject("TMenuItem")
NewMenu.Name = "miEditSourceIP"
NewMenu.Caption = "Edit Source IP for this configuration"

' Hook up the "OnClick" event
Events.SetEvent NewMenu, "OnClick", "EditSourceIP"

' Add the menu to the Tools menu, and make sure the Tools menu is visible
MainForm.miTools.Add(NewMenu)
MainForm.miTools.Visible = True

' ---------------------------------------------------------------------
' Prompt for TOS byte value for current target's engine.
' ---------------------------------------------------------------------
sub EditSourceIP(Action)
  dim ReturnValueString
  dim ReturnValueInteger
  
  ReturnValueString = MainForm.DataCollector.Settings.AdditionalSettings("SourceAdapterAddress_Rule")
  
  if InputQuery("Enter source IP Address", "Enter source IP Address to use for configuration """ & MainForm.DataCollector.Settings.ConfigSettings.Name & """", ReturnValueString) then
	  if (ReturnValueString <> MainForm.DataCollector.Settings.AdditionalSettings("SourceAdapterAddress_Rule")) then
	    MainForm.DataCollector.Settings.AdditionalSettings("SourceAdapterAddress_Rule") = ReturnValueString
	    MainForm.DataCollector.Settings.SourceAdapterAddress = ReturnValueString
		  ShowMessage("Source Adapter IP Address changed to: " & ReturnValueString & vbCRLF & vbCRLF & "Note: This works on all IPv4 packet types EXCEPT TCP.")
	  else
		  ShowMessage("Value NOT changed.")
	  end if
	end if
end sub

' This is called each time we create a new grid / form.  This is a great
' time to check and make sure the default adapter ip address is correctly 
' overwritten in the Engine.
sub CreateNewTarget(Sender, NewTarget)
  ' Just load the setting from the override spot.
  dim Settings
  set Settings = NewTarget.DataCollector.Settings
  Settings.SourceAdapterAddress = Settings.AdditionalSettings("SourceAdapterAddress_Rule")
end sub