49 void (*handler) (
struct iaddr, u_int8_t *,
int);
51 struct protoent *proto;
58 log_fatal (
"attempted to reinitialize icmp protocol");
61 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
66 log_fatal (
"Can't register icmp object type: %s",
67 isc_result_totext (result));
85 proto = getprotobyname (
"icmp");
93 log_error (
"unable to create icmp socket: %m");
97#if defined (HAVE_SETFD)
98 if (fcntl (
icmp_state -> socket, F_SETFD, 1) < 0)
99 log_error (
"Can't set close-on-exec on icmp: %m");
104 if (setsockopt (
icmp_state -> socket, SOL_SOCKET, SO_DONTROUTE,
105 (
char *)&state,
sizeof state) < 0)
106 log_fatal (
"Can't disable SO_DONTROUTE on ICMP: %m");
112 log_fatal (
"Can't register icmp handle: %s",
113 isc_result_totext (result));
131 struct sockaddr_in to;
141 log_fatal (
"ICMP protocol used before initialization.");
143 memset (&to, 0,
sizeof(to));
145 to.sin_len =
sizeof to;
147 to.sin_family = AF_INET;
149 memcpy (&to.sin_addr, addr -> iabuf,
sizeof to.sin_addr);
155#if SIZEOF_STRUCT_IADDR_P == 8
156 icmp.icmp_id = (((u_int32_t)(u_int64_t)addr) ^
157 (u_int32_t)(((u_int64_t)addr) >> 32));
159 icmp.icmp_id = (u_int32_t)addr;
168 char *buf = (
char *)0;
175 isc_result_totext (status));
180 iov [0].
buf = (
char *)addr;
181 iov [0].
len =
sizeof *addr;
191 (
struct sockaddr *)&to,
sizeof to);
194 inet_ntoa(to.sin_addr));
196 if (status !=
sizeof icmp)
209 struct sockaddr_in from;
210 u_int8_t icbuf [1500];
223 status = recvfrom (state ->
socket, (
char *)icbuf,
sizeof icbuf, 0,
224 (
struct sockaddr *)&from, &sl);
227 return ISC_R_UNEXPECTED;
231 ip = (
struct ip *)icbuf;
235 if (status < hlen + (
sizeof *icfrom)) {
240 icfrom = (
struct icmp *)(icbuf + hlen);
248 if (state -> icmp_handler) {
249 memcpy (ia.
iabuf, &from.sin_addr,
sizeof from.sin_addr);
250 ia.
len =
sizeof from.sin_addr;
255 iov [0].
buf = (
char *)&ia;
256 iov [0].
len =
sizeof ia;
257 iov [1].
buf = (
char *)icbuf;
263 (*state -> icmp_handler) (ia, icbuf, len);
273 ia = (
struct iaddr *)buf;
275 icbuf = (u_int8_t *)(ia + 1);
278 (
int)(length -
sizeof ia));
287 if (length != (
sizeof (
struct icmp) +
sizeof (ia))) {
288 log_error (
"trace_icmp_output_input: data size mismatch %d:%d",
289 length, (
int)(
sizeof (
struct icmp) +
sizeof (ia)));
293 memcpy (ia.
iabuf, buf, 4);
void trace_icmp_input_input(trace_type_t *, unsigned, char *)
void trace_icmp_input_stop(trace_type_t *)
void trace_icmp_output_stop(trace_type_t *)
void trace_icmp_output_input(trace_type_t *, unsigned, char *)
int icmp_readsocket(omapi_object_t *h)
int icmp_echorequest(struct iaddr *addr)
void icmp_startup(int routep, void *handler)
isc_result_t icmp_echoreply(omapi_object_t *h)
const char * piaddr(const struct iaddr addr)
struct __omapi_object_type_t omapi_object_type_t
#define OMAPI_OBJECT_ALLOC(name, stype, type)
isc_result_t omapi_register_io_object(omapi_object_t *, int(*)(omapi_object_t *), int(*)(omapi_object_t *), isc_result_t(*)(omapi_object_t *), isc_result_t(*)(omapi_object_t *), isc_result_t(*)(omapi_object_t *))
struct __omapi_object omapi_object_t
isc_result_t omapi_object_type_register(omapi_object_type_t **, const char *, isc_result_t(*)(omapi_object_t *, omapi_object_t *, omapi_data_string_t *, omapi_typed_data_t *), isc_result_t(*)(omapi_object_t *, omapi_object_t *, omapi_data_string_t *, omapi_value_t **), isc_result_t(*)(omapi_object_t *, const char *, int), isc_result_t(*)(omapi_object_t *, const char *, va_list), isc_result_t(*)(omapi_object_t *, omapi_object_t *, omapi_object_t *), isc_result_t(*)(omapi_object_t **, omapi_object_t *, omapi_object_t *), isc_result_t(*)(omapi_object_t **, omapi_object_t *), isc_result_t(*)(omapi_object_t *, omapi_object_t *), isc_result_t(*)(omapi_object_t *, const char *, int), isc_result_t(*)(omapi_object_t **, const char *, int), isc_result_t(*)(size_t), size_t, isc_result_t(*)(omapi_object_t *, const char *, int), int)
void dfree(void *, const char *, int)
int log_error(const char *,...) __attribute__((__format__(__printf__
void log_fatal(const char *,...) __attribute__((__format__(__printf__
u_int32_t checksum(unsigned char *buf, unsigned nbytes, u_int32_t sum)
u_int32_t wrapsum(u_int32_t sum)
union icmp::@270231021253362017333165244027160240034037157104 icmp_dun
struct trace_iov trace_iov_t
trace_type_t * trace_type_register(const char *, void *, void(*)(trace_type_t *, unsigned, char *), void(*)(trace_type_t *), const char *, int)
isc_result_t trace_get_packet(trace_type_t **, unsigned *, char **)
struct trace_type trace_type_t
isc_result_t trace_write_packet_iov(trace_type_t *, int, trace_iov_t *, const char *, int)