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

Function sppp_get_ip_addrs

freebsd/net/if_spppsubr.c:4812–4851  ·  view source on GitHub ↗

* Get both IP addresses. */

Source from the content-addressed store, hash-verified

4810 * Get both IP addresses.
4811 */
4812void
4813sppp_get_ip_addrs(struct sppp *sp, u_long *src, u_long *dst, u_long *srcmask)
4814{
4815 struct epoch_tracker et;
4816 struct ifnet *ifp = SP2IFP(sp);
4817 struct ifaddr *ifa;
4818 struct sockaddr_in *si, *sm;
4819 u_long ssrc, ddst;
4820
4821 sm = NULL;
4822 ssrc = ddst = 0L;
4823 /*
4824 * Pick the first AF_INET address from the list,
4825 * aliases don't make any sense on a p2p link anyway.
4826 */
4827 si = NULL;
4828 NET_EPOCH_ENTER(et);
4829 CK_STAILQ_FOREACH(ifa, &ifp->if_addrhead, ifa_link)
4830 if (ifa->ifa_addr->sa_family == AF_INET) {
4831 si = (struct sockaddr_in *)ifa->ifa_addr;
4832 sm = (struct sockaddr_in *)ifa->ifa_netmask;
4833 if (si)
4834 break;
4835 }
4836 if (ifa) {
4837 if (si && si->sin_addr.s_addr) {
4838 ssrc = si->sin_addr.s_addr;
4839 if (srcmask)
4840 *srcmask = ntohl(sm->sin_addr.s_addr);
4841 }
4842
4843 si = (struct sockaddr_in *)ifa->ifa_dstaddr;
4844 if (si && si->sin_addr.s_addr)
4845 ddst = si->sin_addr.s_addr;
4846 }
4847 NET_EPOCH_EXIT(et);
4848
4849 if (dst) *dst = ntohl(ddst);
4850 if (src) *src = ntohl(ssrc);
4851}
4852
4853#ifdef INET
4854/*

Callers 5

sppp_cisco_inputFunction · 0.85
sppp_ipcp_openFunction · 0.85
sppp_ipcp_RCRFunction · 0.85
sppp_ipcp_scrFunction · 0.85
sppp_fr_arpFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected