-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathNatify.cpp
51 lines (42 loc) · 1.32 KB
/
Natify.cpp
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
#include <common/Common.hpp>
#include <dwc/dwc_match.h>
#include <gs/common/gsAvailable.h>
#include <gs/common/gsPlatformUtil.h>
#include <gs/common/gsSocketRevolution.h>
#include <gs/natneg/natify.h>
#include <gs/natneg/natneg.h>
#include <platform/string.h>
#include <wiimmfi/Natify.hpp>
namespace Wiimmfi {
namespace Natify {
bool sDoingNatify;
NatifyData sNatifyData;
void Callback(BOOL success, NAT* theNat) {
// If NATify was successful, copy the data over
sDoingNatify = false;
if (success) {
DEBUG_REPORT("[NATIFY] NATify done for PID %d\n", stpMatchCnt->profileId)
sNatifyData.profileId = stpMatchCnt->profileId;
sNatifyData.portRestricted = nat.portRestricted;
sNatifyData.ipRestricted = nat.ipRestricted;
sNatifyData.natPromiscuity = nat.promiscuity;
sNatifyData.natType = nat.type;
sNatifyData.natMappingScheme = nat.mappingScheme;
sNatifyData.qr2Compatible = nat.qr2Compatible;
}
}
int CopyData(u8* buffer) {
memcpy(buffer, &sNatifyData, sizeof(sNatifyData));
return sizeof(sNatifyData) + 1;
}
void Start() {
DEBUG_REPORT("[NATIFY] Started NATify procedure\n")
sDoingNatify = true;
NNStartNatDetection(Callback);
}
void Update() {
if (sDoingNatify)
NegotiateThink(nullptr);
}
} // namespace Natify
} // namespace Wiimmfi