MCPcopy Create free account
hub / github.com/bfbbdecomp/bfbb / __ETHFilter

Function __ETHFilter

src/dolphin/src/eth/ethsec.c:150–266  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

148}
149
150BOOL __ETHFilter(u8 *buf, s32 len) {
151 ETHHeader *eh;
152 IPHeader *ip;
153 TCPHeader *tcp;
154 TCPResetInfo *ri;
155 u8 digest1[16];
156 u8 digest2[16];
157
158 ri = &Ri;
159 if (CheckConsoleType()) {
160 return TRUE;
161 }
162
163 eh = (ETHHeader *)buf;
164 if (eh->type != 0x800) {
165 return TRUE;
166 }
167
168 if (memcmp(eh->src, NintendoAddr, 3) == 0) {
169 return TRUE;
170 }
171
172 len = len - sizeof(ETHHeader);
173 ip = (IPHeader *)(eh + 1);
174 if (len < IP_MIN_HLEN || len < ip->len) {
175 return TRUE;
176 }
177
178 if(ip->proto != IP_PROTO_TCP) {
179 return TRUE;
180 }
181
182 tcp = (TCPHeader *)((u32)ip + ((ip->verlen & 0xf) << 2));
183 if ((s32)(((tcp->flag & 0xf000) >> 10)) < TCP_MIN_HLEN) {
184 return TRUE;
185 }
186
187 if (ip->len < ((ip->verlen & 0xf) << 2) + (s32)(((tcp->flag & 0xf000) >> 10))) {
188 return TRUE;
189 }
190
191 if ((tcp->flag & 3) == 2) {
192 switch(tcp->src) {
193 case 0x76c:
194 case 0x35:
195 return TRUE;
196 }
197
198 switch (tcp->dst) {
199 case 0x76c:
200 return TRUE;
201 }
202
203 if (IPIsLocalAddr(0, ip->src) == FALSE) {
204 return TRUE;
205 }
206
207 if (tcp->flag & 4) {

Callers 1

readbuffer1Function · 0.85

Calls 7

CheckConsoleTypeFunction · 0.85
memcmpFunction · 0.85
VerifyPacketFunction · 0.85
memmoveFunction · 0.85
GetTcpSegLenFunction · 0.85
CalcDigestFunction · 0.85
__IPDecodeFromBase64Function · 0.85

Tested by

no test coverage detected