ruby-pcap 0.7.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,22 @@
1
+ require 'mkmf'
2
+
3
+ pcap_dir = with_config("pcap-dir", "/usr/local")
4
+ pcap_includedir = with_config("pcap-includedir", pcap_dir + "/include")
5
+ pcap_libdir = with_config("pcap-libdir", pcap_dir + "/lib")
6
+
7
+ $CFLAGS = "-I#{pcap_includedir}"
8
+ $LDFLAGS = "-L#{pcap_libdir}"
9
+
10
+ # According to the blog entry at
11
+ # http://blog.phusion.nl/2010/06/10/making-ruby-threadable-properly-handling-context-switching-in-native-extensions/
12
+ # TRAP_BEG and TRAP_END just release / reacquire the GIL (global interpreter lock) on Ruby 1.9, which means
13
+ # they should not be used in our case.
14
+ $defs.push("-DPCAP_DONT_TRAP=1") if RUBY_VERSION >= '1.9'
15
+
16
+ have_library("socket", "socket")
17
+ have_library("xnet", "gethostbyname")
18
+ have_func("hstrerror")
19
+ if have_header("pcap.h") && have_library("pcap", "pcap_open_live")
20
+ have_func("pcap_compile_nopcap")
21
+ create_makefile("pcap")
22
+ end
@@ -0,0 +1,444 @@
1
+ /*
2
+ * icmp_packet.c
3
+ *
4
+ * $Id: icmp_packet.c,v 1.1.1.1 1999/10/27 09:54:38 fukusima Exp $
5
+ *
6
+ * Copyright (C) 1999 Masaki Fukushima
7
+ */
8
+
9
+ #include "ruby_pcap.h"
10
+
11
+ /* rfc1256 */
12
+ #ifndef ICMP_ROUTERADVERT
13
+ #define ICMP_ROUTERADVERT 9
14
+ #endif
15
+ #ifndef ICMP_ROUTERSOLICIT
16
+ #define ICMP_ROUTERSOLICIT 10
17
+ #endif
18
+
19
+ /* rfc1393 */
20
+ #ifndef ICMP_TROUTE
21
+ #define ICMP_TROUTE 30
22
+ #endif
23
+
24
+ /* rfc1788 */
25
+ #ifndef ICMP_DOMAIN
26
+ #define ICMP_DOMAIN 37
27
+ #endif
28
+ #ifndef ICMP_DOMAINREPLY
29
+ #define ICMP_DOMAINREPLY 38
30
+ #endif
31
+
32
+ /* rfc1700 */
33
+ #ifndef ICMP_UNREACH_NET_UNKNOWN
34
+ #define ICMP_UNREACH_NET_UNKNOWN 6
35
+ #endif
36
+ #ifndef ICMP_UNREACH_HOST_UNKNOWN
37
+ #define ICMP_UNREACH_HOST_UNKNOWN 7
38
+ #endif
39
+ #ifndef ICMP_UNREACH_ISOLATED
40
+ #define ICMP_UNREACH_ISOLATED 8
41
+ #endif
42
+ #ifndef ICMP_UNREACH_NET_PROHIB
43
+ #define ICMP_UNREACH_NET_PROHIB 9
44
+ #endif
45
+ #ifndef ICMP_UNREACH_HOST_PROHIB
46
+ #define ICMP_UNREACH_HOST_PROHIB 10
47
+ #endif
48
+ #ifndef ICMP_UNREACH_TOSNET
49
+ #define ICMP_UNREACH_TOSNET 11
50
+ #endif
51
+ #ifndef ICMP_UNREACH_TOSHOST
52
+ #define ICMP_UNREACH_TOSHOST 12
53
+ #endif
54
+
55
+ /* rfc1716 */
56
+ #ifndef ICMP_UNREACH_FILTER_PROHIB
57
+ #define ICMP_UNREACH_FILTER_PROHIB 13
58
+ #endif
59
+ #ifndef ICMP_UNREACH_HOST_PRECEDENCE
60
+ #define ICMP_UNREACH_HOST_PRECEDENCE 14
61
+ #endif
62
+ #ifndef ICMP_UNREACH_PRECEDENCE_CUTOFF
63
+ #define ICMP_UNREACH_PRECEDENCE_CUTOFF 15
64
+ #endif
65
+
66
+ #ifndef ICMP_PARAMPROB_OPTABSENT
67
+ #define ICMP_PARAMPROB_OPTABSENT 1
68
+ #endif
69
+
70
+ #define ICMP_HDR(pkt) ((struct icmp *)LAYER4_HDR(pkt))
71
+ #define ICMP_DATA(pkt) ((u_char *)LAYER5_HDR(pkt))
72
+ #define ICMP_DATALEN(pkt) \
73
+ (ntohs(IP_HDR(pkt)->ip_len) - (IP_HDR(pkt)->ip_hl * 4 + 8))
74
+ #define ICMP_CAPLEN(pkt) (pkt->hdr.pkthdr.caplen - pkt->hdr.layer4_off)
75
+
76
+ VALUE cICMPPacket;
77
+
78
+ #define CheckTruncateICMP(pkt, need) \
79
+ CheckTruncate(pkt, pkt->hdr.layer4_off, need, "truncated ICMP")
80
+
81
+ struct icmp_type_info {
82
+ char *name;
83
+ VALUE klass;
84
+ };
85
+ static struct icmp_type_info icmp_types[] = {
86
+ {/* 0 */ "echo reply" },
87
+ {},{},
88
+ {/* 3 */ "unreachable" },
89
+ {/* 4 */ "source quench" },
90
+ {/* 5 */ "redirect" },
91
+ {},{},
92
+ {/* 8 */ "echo request" },
93
+ {/* 9 */ "router advertisement" },
94
+ {/* 10 */ "router solicitation" },
95
+ {/* 11 */ "time exceeded" },
96
+ {/* 12 */ "parameter problem" },
97
+ {/* 13 */ "time stamp request" },
98
+ {/* 14 */ "time stamp reply" },
99
+ {/* 15 */ "information request" },
100
+ {/* 16 */ "information reply" },
101
+ {/* 17 */ "address mask request" },
102
+ {/* 18 */ "address mask reply" },
103
+ {},{},{},{},{},{},{},{},{},{},{},
104
+ {/* 30 */ "traceroute" },
105
+ {},{},{},{},{},{},
106
+ {/* 37 */ "domain name request" },
107
+ {/* 38 */ "domain name reply" }
108
+ #define ICMP_TYPE_MAX 38
109
+ };
110
+
111
+ VALUE
112
+ setup_icmp_packet(pkt, tl_len)
113
+ struct packet_object *pkt;
114
+ int tl_len;
115
+ {
116
+ VALUE klass = cICMPPacket;
117
+
118
+ if (tl_len >= 1) {
119
+ struct icmp *icmp = ICMP_HDR(pkt);
120
+ if (icmp->icmp_type <= ICMP_TYPE_MAX
121
+ && icmp_types[icmp->icmp_type].klass) {
122
+ klass = icmp_types[icmp->icmp_type].klass;
123
+ }
124
+ }
125
+ return klass;
126
+ }
127
+
128
+
129
+ #define ICMPP_METHOD(func, need, val) \
130
+ static VALUE\
131
+ (func)(self)\
132
+ VALUE self;\
133
+ {\
134
+ struct packet_object *pkt;\
135
+ struct icmp *icmp;\
136
+ GetPacket(self, pkt);\
137
+ CheckTruncateICMP(pkt, (need));\
138
+ icmp = ICMP_HDR(pkt);\
139
+ return (val);\
140
+ }
141
+
142
+ /*
143
+ * Common methods (icmp_type independent)
144
+ */
145
+
146
+ ICMPP_METHOD(icmpp_type, 1, INT2FIX(icmp->icmp_type))
147
+ ICMPP_METHOD(icmpp_code, 2, INT2FIX(icmp->icmp_code))
148
+ ICMPP_METHOD(icmpp_cksum, 4, INT2FIX(ntohs(icmp->icmp_cksum)))
149
+ ICMPP_METHOD(icmpp_typestr, 1,
150
+ (icmp->icmp_type <= ICMP_TYPE_MAX
151
+ &&icmp_types[icmp->icmp_type].name)
152
+ ? rb_str_new2(icmp_types[icmp->icmp_type].name)
153
+ : rb_obj_as_string(INT2FIX(icmp->icmp_type)))
154
+
155
+
156
+ /*
157
+ * icmp_type specific methods
158
+ */
159
+
160
+ ICMPP_METHOD(icmpp_pptr, 5, INT2FIX(icmp->icmp_pptr))
161
+ ICMPP_METHOD(icmpp_gwaddr, 8, new_ipaddr(&icmp->icmp_gwaddr))
162
+ ICMPP_METHOD(icmpp_id, 6, INT2FIX(ntohs(icmp->icmp_id)))
163
+ ICMPP_METHOD(icmpp_seq, 8, INT2FIX(ntohs(icmp->icmp_seq)))
164
+ #ifdef WORDS_BIGENDIAN
165
+ ICMPP_METHOD(icmpp_seqle, 8, INT2FIX(((0x00ff&icmp->icmp_seq)<<8) +
166
+ (icmp->icmp_seq >> 8)))
167
+ #else
168
+ ICMPP_METHOD(icmpp_seqle, 8, INT2FIX(icmp->icmp_seq))
169
+ #endif
170
+
171
+ /* rfc1191 */
172
+ struct mtu_discovery {
173
+ u_short unused;
174
+ u_short nextmtu;
175
+ };
176
+ #define MTUD(icmp) ((struct mtu_discovery *)&icmp->icmp_void)
177
+
178
+ static VALUE
179
+ icmpp_nextmtu(self)
180
+ VALUE self;
181
+ {
182
+ struct packet_object *pkt;
183
+ struct icmp *icmp;
184
+
185
+ GetPacket(self, pkt);
186
+ CheckTruncateICMP(pkt, 8);
187
+ icmp = ICMP_HDR(pkt);
188
+
189
+ if (icmp->icmp_code != ICMP_UNREACH_NEEDFRAG)
190
+ rb_raise(rb_eRuntimeError, "not ICMP_UNREACH_NEEDFRAG");
191
+ return INT2FIX(ntohs(MTUD(icmp)->nextmtu));
192
+ }
193
+
194
+ /* rfc1256 */
195
+ struct ih_rdiscovery {
196
+ u_char num_addrs;
197
+ u_char wpa;
198
+ u_short lifetime;
199
+ };
200
+ #define IHRD(icmp) ((struct ih_rdiscovery *)&icmp->icmp_void)
201
+
202
+ struct id_rdiscovery {
203
+ struct in_addr ird_addr;
204
+ long ird_pref;
205
+ };
206
+ #define IDRD(icmp) ((struct id_rdiscovery *)icmp->icmp_data)
207
+
208
+ ICMPP_METHOD(icmpp_num_addrs, 5, INT2FIX(IHRD(icmp)->num_addrs))
209
+ ICMPP_METHOD(icmpp_wpa, 6, INT2FIX(IHRD(icmp)->wpa))
210
+ ICMPP_METHOD(icmpp_lifetime, 8, INT2FIX(ntohs(IHRD(icmp)->lifetime)))
211
+
212
+ static VALUE
213
+ icmpp_radv(self, ind)
214
+ VALUE self, ind;
215
+ {
216
+ struct packet_object *pkt;
217
+ struct icmp *icmp;
218
+ int i = NUM2INT(ind);
219
+ VALUE ary;
220
+
221
+ GetPacket(self, pkt);
222
+ CheckTruncateICMP(pkt, 5);
223
+ if (i > IHRD(icmp)->num_addrs)
224
+ rb_raise(rb_eRuntimeError, "num_addrs = %d, requested radv(%d)",
225
+ (int)IHRD(icmp)->num_addrs, i);
226
+
227
+ CheckTruncateICMP(pkt, 8 + i*8);
228
+ icmp = ICMP_HDR(pkt);
229
+
230
+ ary = rb_ary_new();
231
+ rb_ary_push(ary, new_ipaddr(&IDRD(icmp)->ird_addr));
232
+ rb_ary_push(ary, INT2NUM(ntohl(IDRD(icmp)->ird_pref)));
233
+ return ary;
234
+ }
235
+
236
+ #define time_new_msec(t) rb_time_new((t)/1000, (t)%1000 * 1000)
237
+ ICMPP_METHOD(icmpp_otime, 12, time_new_msec(ntohl(icmp->icmp_otime)))
238
+ ICMPP_METHOD(icmpp_rtime, 16, time_new_msec(ntohl(icmp->icmp_rtime)))
239
+ ICMPP_METHOD(icmpp_ttime, 20, time_new_msec(ntohl(icmp->icmp_ttime)))
240
+
241
+ static VALUE
242
+ icmpp_ip(self)
243
+ VALUE self;
244
+ {
245
+ struct packet_object *pkt;
246
+ struct icmp *icmp;
247
+ struct pcap_pkthdr pkthdr;
248
+
249
+ GetPacket(self, pkt);
250
+ CheckTruncateICMP(pkt, 9);
251
+ icmp = ICMP_HDR(pkt);
252
+
253
+ pkthdr.caplen = ICMP_CAPLEN(pkt) - 8;
254
+ pkthdr.len = 0;
255
+ pkthdr.ts.tv_sec = 0;
256
+ pkthdr.ts.tv_usec = 0;
257
+ return new_packet((char *)&icmp->icmp_ip, &pkthdr, DLT_RAW);
258
+ }
259
+
260
+ ICMPP_METHOD(icmpp_mask, 12, UINT32_2_NUM(ntohl(icmp->icmp_mask)))
261
+ ICMPP_METHOD(icmpp_data, 9, rb_str_new(icmp->icmp_data, ICMP_CAPLEN(pkt)-8))
262
+
263
+ /* rfc1393 */
264
+ struct traceroute {
265
+ u_short ohc;
266
+ u_short rhc;
267
+ u_long lspeed;
268
+ u_long lmtu;
269
+ };
270
+ #define TROUTE(icmp) ((struct traceroute *)icmp->icmp_data)
271
+ ICMPP_METHOD(icmpp_ohc, 10, INT2FIX(ntohs(TROUTE(icmp)->ohc)))
272
+ ICMPP_METHOD(icmpp_rhc, 12, INT2FIX(ntohs(TROUTE(icmp)->rhc)))
273
+ ICMPP_METHOD(icmpp_lspeed, 16, UINT32_2_NUM(ntohl(TROUTE(icmp)->lspeed)))
274
+ ICMPP_METHOD(icmpp_lmtu, 20, UINT32_2_NUM(ntohl(TROUTE(icmp)->lmtu)))
275
+
276
+ /* rfc1788 */
277
+ struct domain_reply {
278
+ u_long ttl;
279
+ char names[1];
280
+ };
281
+ #define DOMAIN(icmp) ((struct domain_reply *)icmp->icmp_data)
282
+ ICMPP_METHOD(icmpp_ttl, 12, UINT32_2_NUM(ntohl(DOMAIN(icmp)->ttl)))
283
+
284
+ void
285
+ Init_icmp_packet(void)
286
+ {
287
+ VALUE klass;
288
+
289
+ rb_define_const(mPcap, "ICMP_ECHOREPLY", INT2NUM(ICMP_ECHOREPLY));
290
+ rb_define_const(mPcap, "ICMP_UNREACH", INT2NUM(ICMP_UNREACH));
291
+ rb_define_const(mPcap, "ICMP_SOURCEQUENCH",INT2NUM(ICMP_SOURCEQUENCH));
292
+ rb_define_const(mPcap, "ICMP_REDIRECT", INT2NUM(ICMP_REDIRECT));
293
+ rb_define_const(mPcap, "ICMP_ECHO", INT2NUM(ICMP_ECHO));
294
+ rb_define_const(mPcap, "ICMP_TIMXCEED", INT2NUM(ICMP_TIMXCEED));
295
+ rb_define_const(mPcap, "ICMP_PARAMPROB", INT2NUM(ICMP_PARAMPROB));
296
+ rb_define_const(mPcap, "ICMP_TSTAMP", INT2NUM(ICMP_TSTAMP));
297
+ rb_define_const(mPcap, "ICMP_TSTAMPREPLY", INT2NUM(ICMP_TSTAMPREPLY));
298
+ rb_define_const(mPcap, "ICMP_IREQ", INT2NUM(ICMP_IREQ));
299
+ rb_define_const(mPcap, "ICMP_IREQREPLY", INT2NUM(ICMP_IREQREPLY));
300
+ rb_define_const(mPcap, "ICMP_MASKREQ", INT2NUM(ICMP_MASKREQ));
301
+ rb_define_const(mPcap, "ICMP_MASKREPLY", INT2NUM(ICMP_MASKREPLY));
302
+
303
+ /* UNREACH codes */
304
+ rb_define_const(mPcap, "ICMP_UNREACH_NET", INT2NUM(ICMP_UNREACH_NET));
305
+ rb_define_const(mPcap, "ICMP_UNREACH_HOST", INT2NUM(ICMP_UNREACH_HOST));
306
+ rb_define_const(mPcap, "ICMP_UNREACH_PROTOCOL", INT2NUM(ICMP_UNREACH_PROTOCOL));
307
+ rb_define_const(mPcap, "ICMP_UNREACH_PORT", INT2NUM(ICMP_UNREACH_PORT));
308
+ rb_define_const(mPcap, "ICMP_UNREACH_NEEDFRAG", INT2NUM(ICMP_UNREACH_NEEDFRAG));
309
+ rb_define_const(mPcap, "ICMP_UNREACH_SRCFAIL", INT2NUM(ICMP_UNREACH_SRCFAIL));
310
+ rb_define_const(mPcap, "ICMP_UNREACH_NET_UNKNOWN", INT2NUM(ICMP_UNREACH_NET_UNKNOWN));
311
+ rb_define_const(mPcap, "ICMP_UNREACH_HOST_UNKNOWN", INT2NUM(ICMP_UNREACH_HOST_UNKNOWN));
312
+ rb_define_const(mPcap, "ICMP_UNREACH_ISOLATED", INT2NUM(ICMP_UNREACH_ISOLATED));
313
+ rb_define_const(mPcap, "ICMP_UNREACH_NET_PROHIB", INT2NUM(ICMP_UNREACH_NET_PROHIB));
314
+ rb_define_const(mPcap, "ICMP_UNREACH_HOST_PROHIB", INT2NUM(ICMP_UNREACH_HOST_PROHIB));
315
+ rb_define_const(mPcap, "ICMP_UNREACH_TOSNET", INT2NUM(ICMP_UNREACH_TOSNET));
316
+ rb_define_const(mPcap, "ICMP_UNREACH_TOSHOST", INT2NUM(ICMP_UNREACH_TOSHOST));
317
+ rb_define_const(mPcap, "ICMP_UNREACH_FILTER_PROHIB", INT2NUM(ICMP_UNREACH_FILTER_PROHIB));
318
+ rb_define_const(mPcap, "ICMP_UNREACH_HOST_PRECEDENCE", INT2NUM(ICMP_UNREACH_HOST_PRECEDENCE));
319
+ rb_define_const(mPcap, "ICMP_UNREACH_PRECEDENCE_CUTOFF", INT2NUM(ICMP_UNREACH_PRECEDENCE_CUTOFF));
320
+
321
+ /* REDIRECT codes */
322
+ rb_define_const(mPcap, "ICMP_REDIRECT_NET", INT2NUM(ICMP_REDIRECT_NET));
323
+ rb_define_const(mPcap, "ICMP_REDIRECT_HOST", INT2NUM(ICMP_REDIRECT_HOST));
324
+ rb_define_const(mPcap, "ICMP_REDIRECT_TOSNET", INT2NUM(ICMP_REDIRECT_TOSNET));
325
+ rb_define_const(mPcap, "ICMP_REDIRECT_TOSHOST", INT2NUM(ICMP_REDIRECT_TOSHOST));
326
+
327
+ /* TIMEXCEED codes */
328
+ rb_define_const(mPcap, "ICMP_TIMXCEED_INTRANS", INT2NUM(ICMP_TIMXCEED_INTRANS));
329
+ rb_define_const(mPcap, "ICMP_TIMXCEED_REASS", INT2NUM(ICMP_TIMXCEED_REASS));
330
+
331
+ /* PARAMPROB code */
332
+ rb_define_const(mPcap, "ICMP_PARAMPROB_OPTABSENT", INT2NUM(ICMP_PARAMPROB_OPTABSENT));
333
+
334
+ cICMPPacket = rb_define_class_under(mPcap, "ICMPPacket", cIPPacket);
335
+ rb_define_method(cICMPPacket, "icmp_type", icmpp_type, 0);
336
+ rb_define_method(cICMPPacket, "icmp_typestr", icmpp_typestr, 0);
337
+ rb_define_method(cICMPPacket, "icmp_code", icmpp_code, 0);
338
+ rb_define_method(cICMPPacket, "icmp_cksum", icmpp_cksum, 0);
339
+
340
+ klass = rb_define_class_under(mPcap, "ICMPEchoReply", cICMPPacket);
341
+ icmp_types[ICMP_ECHOREPLY].klass = klass;
342
+ rb_define_method(klass, "icmp_id", icmpp_id, 0);
343
+ rb_define_method(klass, "icmp_seq", icmpp_seq, 0);
344
+ rb_define_method(klass, "icmp_seqle", icmpp_seqle, 0);
345
+ rb_define_method(klass, "icmp_data", icmpp_data, 0);
346
+
347
+ klass = rb_define_class_under(mPcap, "ICMPUnreach", cICMPPacket);
348
+ icmp_types[ICMP_UNREACH].klass = klass;
349
+ rb_define_method(klass, "icmp_nextmtu", icmpp_nextmtu, 0);
350
+ rb_define_method(klass, "icmp_ip", icmpp_ip, 0);
351
+
352
+ klass = rb_define_class_under(mPcap, "ICMPSourceQuench", cICMPPacket);
353
+ icmp_types[ICMP_SOURCEQUENCH].klass = klass;
354
+ rb_define_method(klass, "icmp_ip", icmpp_ip, 0);
355
+
356
+ klass = rb_define_class_under(mPcap, "ICMPRedirect", cICMPPacket);
357
+ icmp_types[ICMP_REDIRECT].klass = klass;
358
+ rb_define_method(klass, "icmp_gwaddr", icmpp_gwaddr, 0);
359
+ rb_define_method(klass, "icmp_ip", icmpp_ip, 0);
360
+
361
+ klass = rb_define_class_under(mPcap, "ICMPEcho", cICMPPacket);
362
+ icmp_types[ICMP_ECHO].klass = klass;
363
+ rb_define_method(klass, "icmp_id", icmpp_id, 0);
364
+ rb_define_method(klass, "icmp_seq", icmpp_seq, 0);
365
+ rb_define_method(klass, "icmp_seqle", icmpp_seqle, 0);
366
+ rb_define_method(klass, "icmp_data", icmpp_data, 0);
367
+
368
+ klass = rb_define_class_under(mPcap, "ICMPRouterAdvert", cICMPPacket);
369
+ icmp_types[ICMP_ROUTERADVERT].klass = klass;
370
+ rb_define_method(klass, "icmp_num_addrs", icmpp_num_addrs, 0);
371
+ rb_define_method(klass, "icmp_wpa", icmpp_wpa, 0);
372
+ rb_define_method(klass, "icmp_lifetime", icmpp_lifetime, 0);
373
+ rb_define_method(klass, "icmp_radv", icmpp_radv, 1);
374
+
375
+ klass = rb_define_class_under(mPcap, "ICMPRouterSolicit", cICMPPacket);
376
+ icmp_types[ICMP_ROUTERSOLICIT].klass = klass;
377
+
378
+ klass = rb_define_class_under(mPcap, "ICMPTimxceed", cICMPPacket);
379
+ icmp_types[ICMP_TIMXCEED].klass = klass;
380
+ rb_define_method(klass, "icmp_ip", icmpp_ip, 0);
381
+
382
+ klass = rb_define_class_under(mPcap, "ICMPParamProb", cICMPPacket);
383
+ icmp_types[ICMP_PARAMPROB].klass = klass;
384
+ rb_define_method(klass, "icmp_pptr", icmpp_pptr, 0);
385
+ rb_define_method(klass, "icmp_ip", icmpp_ip, 0);
386
+
387
+ klass = rb_define_class_under(mPcap, "ICMPTStamp", cICMPPacket);
388
+ icmp_types[ICMP_TSTAMP].klass = klass;
389
+ rb_define_method(klass, "icmp_id", icmpp_id, 0);
390
+ rb_define_method(klass, "icmp_seq", icmpp_seq, 0);
391
+ rb_define_method(klass, "icmp_otime", icmpp_otime, 0);
392
+ rb_define_method(klass, "icmp_rtime", icmpp_rtime, 0);
393
+ rb_define_method(klass, "icmp_ttime", icmpp_ttime, 0);
394
+
395
+ klass = rb_define_class_under(mPcap, "ICMPTStampReply", cICMPPacket);
396
+ icmp_types[ICMP_TSTAMPREPLY].klass = klass;
397
+ rb_define_method(klass, "icmp_id", icmpp_id, 0);
398
+ rb_define_method(klass, "icmp_seq", icmpp_seq, 0);
399
+ rb_define_method(klass, "icmp_otime", icmpp_otime, 0);
400
+ rb_define_method(klass, "icmp_rtime", icmpp_rtime, 0);
401
+ rb_define_method(klass, "icmp_ttime", icmpp_ttime, 0);
402
+
403
+ klass = rb_define_class_under(mPcap, "ICMPIReq", cICMPPacket);
404
+ icmp_types[ICMP_IREQ].klass = klass;
405
+ rb_define_method(klass, "icmp_id", icmpp_id, 0);
406
+ rb_define_method(klass, "icmp_seq", icmpp_seq, 0);
407
+
408
+ klass = rb_define_class_under(mPcap, "ICMPIReqReply", cICMPPacket);
409
+ icmp_types[ICMP_IREQREPLY].klass = klass;
410
+ rb_define_method(klass, "icmp_id", icmpp_id, 0);
411
+ rb_define_method(klass, "icmp_seq", icmpp_seq, 0);
412
+
413
+ klass = rb_define_class_under(mPcap, "ICMPMaskReq", cICMPPacket);
414
+ icmp_types[ICMP_MASKREQ].klass = klass;
415
+ rb_define_method(klass, "icmp_id", icmpp_id, 0);
416
+ rb_define_method(klass, "icmp_seq", icmpp_seq, 0);
417
+ /*rb_define_method(klass, "icmp_mask", icmpp_mask, 0);*/
418
+
419
+ klass = rb_define_class_under(mPcap, "ICMPMaskReply", cICMPPacket);
420
+ icmp_types[ICMP_MASKREPLY].klass = klass;
421
+ rb_define_method(klass, "icmp_id", icmpp_id, 0);
422
+ rb_define_method(klass, "icmp_seq", icmpp_seq, 0);
423
+ /*rb_define_method(klass, "icmp_mask", icmpp_mask, 0);*/
424
+
425
+ klass = rb_define_class_under(mPcap, "ICMPTRoute", cICMPPacket);
426
+ icmp_types[ICMP_TROUTE].klass = klass;
427
+ rb_define_method(klass, "icmp_id", icmpp_id, 0);
428
+ rb_define_method(klass, "icmp_ohc", icmpp_ohc, 0);
429
+ rb_define_method(klass, "icmp_rhc", icmpp_rhc, 0);
430
+ rb_define_method(klass, "icmp_lspeed", icmpp_lspeed, 0);
431
+ rb_define_method(klass, "icmp_lmtu", icmpp_lmtu, 0);
432
+
433
+ klass = rb_define_class_under(mPcap, "ICMPDomain", cICMPPacket);
434
+ icmp_types[ICMP_DOMAIN].klass = klass;
435
+ rb_define_method(klass, "icmp_id", icmpp_id, 0);
436
+ rb_define_method(klass, "icmp_seq", icmpp_seq, 0);
437
+
438
+ klass = rb_define_class_under(mPcap, "ICMPDomainReply", cICMPPacket);
439
+ icmp_types[ICMP_DOMAINREPLY].klass = klass;
440
+ rb_define_method(klass, "icmp_id", icmpp_id, 0);
441
+ rb_define_method(klass, "icmp_seq", icmpp_seq, 0);
442
+ rb_define_method(klass, "icmp_ttl", icmpp_ttl, 0);
443
+ /*rb_define_method(klass, "icmp_names", icmpp_names, 0);*/
444
+ }