MCPcopy Create free account
hub / github.com/F-Stack/f-stack / IcmpAliasIn1

Function IcmpAliasIn1

freebsd/netinet/libalias/alias.c:288–331  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

286static int TcpAliasOut(struct libalias *, struct ip *, int, int create);
287
288static int
289IcmpAliasIn1(struct libalias *la, struct ip *pip)
290{
291
292 LIBALIAS_LOCK_ASSERT(la);
293/*
294 De-alias incoming echo and timestamp replies.
295 Alias incoming echo and timestamp requests.
296*/
297 struct alias_link *lnk;
298 struct icmp *ic;
299
300 ic = (struct icmp *)ip_next(pip);
301
302/* Get source address from ICMP data field and restore original data */
303 lnk = FindIcmpIn(la, pip->ip_src, pip->ip_dst, ic->icmp_id, 1);
304 if (lnk != NULL) {
305 u_short original_id;
306 int accumulate;
307
308 original_id = GetOriginalPort(lnk);
309
310/* Adjust ICMP checksum */
311 accumulate = ic->icmp_id;
312 accumulate -= original_id;
313 ADJUST_CHECKSUM(accumulate, ic->icmp_cksum);
314
315/* Put original sequence number back in */
316 ic->icmp_id = original_id;
317
318/* Put original address back into IP header */
319 {
320 struct in_addr original_address;
321
322 original_address = GetOriginalAddress(lnk);
323 DifferentialChecksum(&pip->ip_sum,
324 &original_address, &pip->ip_dst, 2);
325 pip->ip_dst = original_address;
326 }
327
328 return (PKT_ALIAS_OK);
329 }
330 return (PKT_ALIAS_IGNORED);
331}
332
333static int
334IcmpAliasIn2(struct libalias *la, struct ip *pip)

Callers 1

IcmpAliasInFunction · 0.85

Calls 5

ip_nextFunction · 0.85
FindIcmpInFunction · 0.85
GetOriginalPortFunction · 0.85
GetOriginalAddressFunction · 0.85
DifferentialChecksumFunction · 0.85

Tested by

no test coverage detected