Message Processing
Timer Support Routines
ICMP Socket Initialization
Registry Support Routines
ICMP Ping and IP Address Routines
ListCtrl ICMP Trace Routines
List Control Image/Display Routines
LRESULT OnPINGAsynch (WPARAM wParam, LPARAM lParam)
WSAEvent is used as an index to select which event has signaled: FDRead or FDWrite. If it was a FDRead event, the incoming message is fetched using the CIcmp method Receive, and the list view display is updated.
When the button is pressed, set IconState to default, set icmpTTL to PingSocket.icmpMaxHops, reset icmpTracing, and call PingSocket.IcmpPing method.
Set icmpPingTTL to 0, PingSocket.icmpHops to 0, set default icon and output message about the target, then issue a PING with icmpTracing set to TRUE to start tracing.
Copy current option settings to interchange variables and invoke OptionsDlg dialog.
Exit dialog if option dialog was cancelled.
Update current option variables and save in the Registry.
Clear the list view control display. Active only when no Ping or Trace operation is in progress.
If a Ping operation is underway, abort the operation and display "Operation aborted" message.
void OnTimer(UINT)
If time-out period has not elapsed, increment icmpIntervalCount, change the animated icon's state and exit.
Otherwise, stop the timer, reset icon to default, set receive address to null, and update the trace display to show that the timer has expired.
void StopTimer (void)
void StartTimer (void)
void ChangeIconState (void)
BOOL InitSockets (void)
Connects to a RAW socket with ICMP protocol, and sets the notification message to WSA_PING_ASYNC. Requests notification for READ and WRITE messages only.
BOOL FetchWinsockSettings (void)
Returns TRUE if successful, FALSE if a valid Winsock is not detected.
BOOL LoadRegValues (void)
Returns TRUE if the Registry is accessible, else FALSE.
void SaveRegValues (void)
Returns TRUE if the Registry is accessible, else FALSE.
void SendPing (void)
If icmpTracing is TRUE, increment and set icmpPingTTL to reach the next node in the Internet tree.
Starts the system timer and calls the CIcmp Ping method.
unsigned long HostIPAddress (void)
Copies IDC_DEST to HostName.
GetIPAddress leaves a copy of the address in PingSocket.icmpSockAddr.
void UpdateTrace (void)
void DisplayTrace
(LPCSTR TripTimeMessage,
LPCSTR IPAddressMessage,
LPCSTR HostMessage)
Updates the ListView control with the parameter strings passed in.
Column | Message |
---|---|
1 | TripTimeMessage |
2 | IPAddressMessage |
3 | HostMessage |
void EndTrace(void)
Reset icmpTracing so next operation will be PING.
void InitImageList(void)
The image list smallImageList is initialized with small icons (16 x 16 pixels), and the image list largeImageList is initialized with large icons (32 x 32).
The image lists are added to the list view control and column titles are set in the control.
int AddListColumn
(int column, int lfmt,
int lmaxwidth, LPSTR ltext,
int lsubitem)
Creates the columns used in the list view control.
Parameter | Useage |
---|---|
column | The column number being set-up. |
lfmt | Alignment of data in the column. |
lmaxwidth | Maximum width, in pixels, of the column. |
ltext | Column title. |
lsubitem | Which sub-item to associate with this column. |
void DisplayBlankLine (void)
void SetTraceSequence
(int Seq,
int FocusItem,
ImageType FocusImage)
Output FocusImage and Seq on the line specified by FocusItem, and set the list view focus to the specified line.
void SetTraceFocus
(int FocusItem, int FocusSubItem)
Sets the focus in the list view control to the line described by FocusItem and the item on the line described by FocusSubItem.
void SetDisplayImage
(int FocusItem, enum ImageType FocusImage)
Inserts FocusImage in the line specified by FocusItem.
void TraceComment(CString Comment)