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

Function ProtoAliasOut

freebsd/netinet/libalias/alias.c:691–725  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

689}
690
691static int
692ProtoAliasOut(struct libalias *la, struct ip *pip,
693 struct in_addr ip_dst, u_char ip_p, u_short *ip_sum, int create)
694{
695/*
696 Handle outgoing IP packets. The
697 only thing which is done in this case is to alias
698 the source IP address of the packet.
699*/
700 struct alias_link *lnk;
701
702 LIBALIAS_LOCK_ASSERT(la);
703
704/* Return if proxy-only mode is enabled */
705 if (la->packetAliasMode & PKT_ALIAS_PROXY_ONLY)
706 return (PKT_ALIAS_OK);
707
708 if (!create)
709 return (PKT_ALIAS_IGNORED);
710
711 lnk = FindProtoOut(la, pip->ip_src, ip_dst, ip_p);
712 if (lnk != NULL) {
713 struct in_addr alias_address;
714
715 alias_address = GetAliasAddress(lnk);
716
717/* Change source address */
718 DifferentialChecksum(ip_sum,
719 &alias_address, &pip->ip_src, 2);
720 pip->ip_src = alias_address;
721
722 return (PKT_ALIAS_OK);
723 }
724 return (PKT_ALIAS_IGNORED);
725}
726
727static int
728UdpAliasIn(struct libalias *la, struct ip *pip)

Callers 1

LibAliasOutLockedFunction · 0.85

Calls 3

FindProtoOutFunction · 0.85
GetAliasAddressFunction · 0.85
DifferentialChecksumFunction · 0.85

Tested by

no test coverage detected