OpenMoHAA
0.82.0
Loading...
Searching...
No Matches
pinger.h
1
/*
2
GameSpy Ping SDK
3
Dan "Mr. Pants" Schoenblum
4
dan@gamespy.com
5
6
Copyright 1999-2007 GameSpy Industries, Inc
7
8
devsupport@gamespy.com
9
*/
10
11
#ifndef _PINGER_H_
12
#define _PINGER_H_
13
14
#include "../common/gsCommon.h"
15
16
#ifdef __cplusplus
17
extern
"C"
{
18
#endif
19
20
/************
21
** DEFINES **
22
************/
23
// This controls the size of UDP pings.
24
// The protocol takes up 8 of these bytes.
25
// The rest can be used by the app.
27
#ifndef PINGER_UDP_PING_SIZE
28
#define PINGER_UDP_PING_SIZE 32
29
#endif
30
31
// Value for ping if a ping timed-out.
33
#define PINGER_TIMEOUT -1
34
35
/**********
36
** TYPES **
37
**********/
38
typedef
enum
{ PINGERFalse, PINGERTrue } PINGERBool;
39
40
/**************
41
** CALLBACKS **
42
**************/
43
// A function of this type is used as:
44
// a param to pingerInit, gets called when an uninitiated UDP ping is received
45
// a param to pingerPing, gets called when the ping is completed, or times out
46
// if the ping times out, ping is PINGER_TIMEOUT
47
// IP and port are in network byte order
49
typedef
void (* pingerGotPing)(
unsigned
int
IP,
50
unsigned
short
port,
51
int
ping,
52
const
char
* data,
53
int
len,
54
void
* param);
55
56
// When a ping is sent, this callback gets called so that
57
// the application can use the ping bytes not being used
58
// by the protocol.
59
// The application can write up to len bytes to data.
60
// IP and port are in network byte order.
62
typedef
void (* pingerSetData)(
unsigned
int
IP,
63
unsigned
short
port,
64
char
* data,
65
int
len,
66
void
* param);
67
68
/**************
69
** FUNCTIONS **
70
**************/
71
72
// Called once to initialize the pinger library.
73
// localPort is in host byte order
74
// localAddress=NULL : don't specify a local interface
75
// localPort=0 : not doing UDP pings
77
PINGERBool pingerInit(
const
char
* localAddress,
78
unsigned
short
localPort,
79
pingerGotPing pinged,
80
void
* pingedParam,
81
pingerSetData setData,
82
void
* setDataParam);
83
84
// Called to clean-up when done with pinger.
86
void
pingerShutdown(
void
);
87
88
// Called to do processing.
89
// The more frequently this function is called,
90
// the more accurate the pings will be.
91
//
92
// Example: if this func is called once every 20ms, and a ping
93
// is returned as 100ms, then the ping is in the range 90-110.
95
void
pingerThink(
void
);
96
97
// Does a ping. If blocking, does not return until the ping is completed.
98
// timeout specifes how long (in milliseconds) to wait for the ping reply.
99
// A value of 0 means wait forever. Note, this is dangerous because pings
100
// are not reliable. A blocking ping with a 0 timeout will never return if
101
// the ping is lost.
102
// port=0 : ICMP ping (this is NOT currently supported)
103
// port!=0 : UDP ping
104
// IP and port are in network byte order
106
void
pingerPing(
unsigned
int
IP,
107
unsigned
short
port,
108
pingerGotPing reply,
109
void
* replyParam,
110
PINGERBool blocking,
111
gsi_time timeout);
112
113
#ifdef __cplusplus
114
}
115
#endif
116
117
#endif
code
gamespy
pinger
pinger.h
Generated by
1.13.2