Changeset View
Changeset View
Standalone View
Standalone View
sys/netinet/ip_icmp.c
Show All 38 Lines | |||||
#include <sys/param.h> | #include <sys/param.h> | ||||
#include <sys/systm.h> | #include <sys/systm.h> | ||||
#include <sys/mbuf.h> | #include <sys/mbuf.h> | ||||
#include <sys/protosw.h> | #include <sys/protosw.h> | ||||
#include <sys/socket.h> | #include <sys/socket.h> | ||||
#include <sys/time.h> | #include <sys/time.h> | ||||
#include <sys/kernel.h> | #include <sys/kernel.h> | ||||
#include <sys/lock.h> | #include <sys/lock.h> | ||||
#include <sys/rmlock.h> | |||||
#include <sys/sysctl.h> | #include <sys/sysctl.h> | ||||
#include <sys/syslog.h> | #include <sys/syslog.h> | ||||
#include <net/if.h> | #include <net/if.h> | ||||
#include <net/if_var.h> | #include <net/if_var.h> | ||||
#include <net/if_types.h> | #include <net/if_types.h> | ||||
#include <net/route.h> | #include <net/route.h> | ||||
#include <net/route/route_ctl.h> | #include <net/route/route_ctl.h> | ||||
▲ Show 20 Lines • Show All 695 Lines • ▼ Show 20 Lines | |||||
} | } | ||||
/* | /* | ||||
* Reflect the ip packet back to the source | * Reflect the ip packet back to the source | ||||
*/ | */ | ||||
static void | static void | ||||
icmp_reflect(struct mbuf *m) | icmp_reflect(struct mbuf *m) | ||||
{ | { | ||||
struct rm_priotracker in_ifa_tracker; | |||||
struct ip *ip = mtod(m, struct ip *); | struct ip *ip = mtod(m, struct ip *); | ||||
struct ifaddr *ifa; | struct ifaddr *ifa; | ||||
struct ifnet *ifp; | struct ifnet *ifp; | ||||
struct in_ifaddr *ia; | struct in_ifaddr *ia; | ||||
struct in_addr t; | struct in_addr t; | ||||
struct nhop_object *nh; | struct nhop_object *nh; | ||||
struct mbuf *opts = NULL; | struct mbuf *opts = NULL; | ||||
int optlen = (ip->ip_hl << 2) - sizeof(struct ip); | int optlen = (ip->ip_hl << 2) - sizeof(struct ip); | ||||
Show All 12 Lines | icmp_reflect(struct mbuf *m) | ||||
ip->ip_dst = ip->ip_src; | ip->ip_dst = ip->ip_src; | ||||
/* | /* | ||||
* Source selection for ICMP replies: | * Source selection for ICMP replies: | ||||
* | * | ||||
* If the incoming packet was addressed directly to one of our | * If the incoming packet was addressed directly to one of our | ||||
* own addresses, use dst as the src for the reply. | * own addresses, use dst as the src for the reply. | ||||
*/ | */ | ||||
IN_IFADDR_RLOCK(&in_ifa_tracker); | CK_LIST_FOREACH(ia, INADDR_HASH(t.s_addr), ia_hash) { | ||||
LIST_FOREACH(ia, INADDR_HASH(t.s_addr), ia_hash) { | |||||
if (t.s_addr == IA_SIN(ia)->sin_addr.s_addr) { | if (t.s_addr == IA_SIN(ia)->sin_addr.s_addr) { | ||||
t = IA_SIN(ia)->sin_addr; | t = IA_SIN(ia)->sin_addr; | ||||
IN_IFADDR_RUNLOCK(&in_ifa_tracker); | |||||
goto match; | goto match; | ||||
} | } | ||||
} | } | ||||
IN_IFADDR_RUNLOCK(&in_ifa_tracker); | |||||
/* | /* | ||||
* If the incoming packet was addressed to one of our broadcast | * If the incoming packet was addressed to one of our broadcast | ||||
* addresses, use the first non-broadcast address which corresponds | * addresses, use the first non-broadcast address which corresponds | ||||
* to the incoming interface. | * to the incoming interface. | ||||
*/ | */ | ||||
ifp = m->m_pkthdr.rcvif; | ifp = m->m_pkthdr.rcvif; | ||||
if (ifp != NULL && ifp->if_flags & IFF_BROADCAST) { | if (ifp != NULL && ifp->if_flags & IFF_BROADCAST) { | ||||
▲ Show 20 Lines • Show All 333 Lines • Show Last 20 Lines |