-
Notifications
You must be signed in to change notification settings - Fork 0
/
echoserv.h
116 lines (94 loc) · 2.42 KB
/
echoserv.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
//
// ECHOSERV.H ƒf[ƒ^ƒOƒ‰ƒ€ECHOƒT[ƒo[
//
//
#ifndef _ECHOSERV_H
#define _ECHOSERV_H
#define INCL_WINSOCK_API_TYPEDEFS 1
#include <winsock2.h>
#include <nspapi.h>
#include <wsipx.h>
#include <windowsx.h>
#include <tchar.h>
#include <commctrl.h>
#include <stdlib.h>
#include <stdio.h>
#include <stdarg.h>
#include "..\aeguid.h"
#include "..\dwinsock.h"
#include "resource.h"
////////////////////////////////////////////////////////////
#define UM_ASYNC WM_USER+1
#define UM_ECHO WM_USER+2
#define ECHO_STATS_MSG 1
#define ECHO_EVENT_MSG 2
//
// Structure for linked list
//
typedef struct tagSOCKETENTRY
{
SOCKET Socket;
LPSOCKADDR lpSockAddr;
WSAPROTOCOL_INFOA Info;
struct tagSOCKETENTRY *lpNext;
}SOCKETENTRY, *LPSOCKETENTRY;
typedef struct tagSTATS
{
DWORD dwDatagrams;
DWORD dwRecv;
DWORD dwSend;
LPWSAPROTOCOL_INFO pInfo;
}STATS, *LPSTATS;
//
// ECHOUI.C
//
BOOL OnInitDialog(HWND hwnd,
HWND hwndFocus,
LPARAM lParam);
void OnCommand(HWND hwnd,
int nId,
HWND hwndCtl,
UINT codeNotify);
BOOL CALLBACK MainWndProc(HWND hwnd,
UINT uMsg,
WPARAM wParam,
LPARAM lParam);
void UpdateStats(HWND hwnd, LPSTATS lpStats);
void ShowEvent(HWND hwnd, LPCTSTR lpStr);
//
// ECHOSERV.c
//
void HandleAsyncMsg(HWND hwnd, WPARAM wParam, LPARAM lParam);
BOOL StartServer(HWND hwnd, UINT uAsyMsg, UINT uAppMsg);
void StopServer(void);
void LogEvent(HWND hwnd, LPCTSTR lpFormat, ...);
void LogWinSockError(HWND hwnd, LPCTSTR lpText, int nErrorCode);
void InstallClass(void);
void SetEchoService(WSAESETSERVICEOP essOp);
BOOL OpenListeners(HWND hwnd, UINT uAsyMsg);
void CloseListeners(void);
void RecvAndEcho(SOCKET socket, int nErrorCode);
BOOL FillLocalAddress(SOCKET socket,
LPSOCKADDR lpAddr,
LPWSAPROTOCOL_INFO lpInfo);
//
// SOCKLIST.C
//
LPSOCKETENTRY AddSocketEntry(SOCKET Socket,
LPWSAPROTOCOL_INFO lpInfo);
LPSOCKETENTRY GetSocketEntry(SOCKET Socket);
void DelSocketEntry(LPSOCKETENTRY lpThis);
LPSOCKETENTRY GetFirstSocketEntry(void);
LPSOCKETENTRY GetNextSocketEntry(LPSOCKETENTRY lpThis);
void DelAllSocketEntries(void);
////////////////////////////////////////////////////////////
//
// Message Handler macro for dialog boxes
//
#define HANDLE_DLG_MSG(hwnd, message, fn) \
case(message): \
return (BOOL) HANDLE_##message((hwnd), \
(wParam), \
(lParam), \
(fn))
#endif _ECHOSERV_H