Centralize satosin(), sintosa() and ifatoia() macros in <netinet/in.h>
Remove local definitions.
This commit is contained in:
parent
420d4edc40
commit
17d77e9346
@ -477,6 +477,10 @@ int in_localaddr __P((struct in_addr));
|
||||
char *inet_ntoa __P((struct in_addr)); /* in libkern */
|
||||
char *inet_ntoa_r __P((struct in_addr ina, char *buf)); /* in libkern */
|
||||
|
||||
#define satosin(sa) ((struct sockaddr_in *)(sa))
|
||||
#define sintosa(sin) ((struct sockaddr *)(sin))
|
||||
#define ifatoia(ifa) ((struct in_ifaddr *)(ifa))
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
@ -399,9 +399,6 @@ in_pcbladdr(inp, nam, plocal_sin)
|
||||
* and the primary interface supports broadcast,
|
||||
* choose the broadcast address for that interface.
|
||||
*/
|
||||
#define satosin(sa) ((struct sockaddr_in *)(sa))
|
||||
#define sintosa(sin) ((struct sockaddr *)(sin))
|
||||
#define ifatoia(ifa) ((struct in_ifaddr *)(ifa))
|
||||
if (sin->sin_addr.s_addr == INADDR_ANY)
|
||||
sin->sin_addr = IA_SIN(TAILQ_FIRST(&in_ifaddrhead))->sin_addr;
|
||||
else if (sin->sin_addr.s_addr == (u_long)INADDR_BROADCAST &&
|
||||
|
@ -101,11 +101,9 @@ in_addroute(void *v_arg, void *n_arg, struct radix_node_head *head,
|
||||
if (in_broadcast(sin->sin_addr, rt->rt_ifp)) {
|
||||
rt->rt_flags |= RTF_BROADCAST;
|
||||
} else {
|
||||
#define satosin(sa) ((struct sockaddr_in *)sa)
|
||||
if (satosin(rt->rt_ifa->ifa_addr)->sin_addr.s_addr
|
||||
== sin->sin_addr.s_addr)
|
||||
rt->rt_flags |= RTF_LOCAL;
|
||||
#undef satosin
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -558,7 +558,6 @@ ip_input(struct mbuf *m)
|
||||
(ip_fw_fwd_addr == NULL);
|
||||
|
||||
TAILQ_FOREACH(ia, &in_ifaddrhead, ia_link) {
|
||||
#define satosin(sa) ((struct sockaddr_in *)(sa))
|
||||
|
||||
#ifdef BOOTP_COMPAT
|
||||
if (IA_SIN(ia)->sin_addr.s_addr == INADDR_ANY)
|
||||
@ -1428,7 +1427,7 @@ ip_rtaddr(dst)
|
||||
}
|
||||
if (ipforward_rt.ro_rt == 0)
|
||||
return ((struct in_ifaddr *)0);
|
||||
return ((struct in_ifaddr *) ipforward_rt.ro_rt->rt_ifa);
|
||||
return (ifatoia(ipforward_rt.ro_rt->rt_ifa));
|
||||
}
|
||||
|
||||
/*
|
||||
@ -1653,7 +1652,6 @@ ip_forward(m, srcrt)
|
||||
* Also, don't send redirect if forwarding using a default route
|
||||
* or a route modified by a redirect.
|
||||
*/
|
||||
#define satosin(sa) ((struct sockaddr_in *)(sa))
|
||||
if (rt->rt_ifp == m->m_pkthdr.rcvif &&
|
||||
(rt->rt_flags & (RTF_DYNAMIC|RTF_MODIFIED)) == 0 &&
|
||||
satosin(rt_key(rt))->sin_addr.s_addr != 0 &&
|
||||
|
@ -180,7 +180,7 @@ ip_output(m0, opt, ro, flags, imo)
|
||||
#endif
|
||||
ip = mtod(m, struct ip *);
|
||||
hlen = IP_VHL_HL(ip->ip_vhl) << 2 ;
|
||||
ia = (struct in_ifaddr *)ro->ro_rt->rt_ifa;
|
||||
ia = ifatoia(ro->ro_rt->rt_ifa);
|
||||
goto sendit;
|
||||
} else
|
||||
rule = NULL ;
|
||||
@ -238,8 +238,6 @@ ip_output(m0, opt, ro, flags, imo)
|
||||
* If routing to interface only,
|
||||
* short circuit routing lookup.
|
||||
*/
|
||||
#define ifatoia(ifa) ((struct in_ifaddr *)(ifa))
|
||||
#define sintosa(sin) ((struct sockaddr *)(sin))
|
||||
if (flags & IP_ROUTETOIF) {
|
||||
if ((ia = ifatoia(ifa_ifwithdstaddr(sintosa(dst)))) == 0 &&
|
||||
(ia = ifatoia(ifa_ifwithnet(sintosa(dst)))) == 0) {
|
||||
|
Loading…
Reference in New Issue
Block a user