diff --git a/data/msfgui/msfgui.glade b/data/msfgui/msfgui.glade index 927eedd1fb..bf3649dc31 100644 --- a/data/msfgui/msfgui.glade +++ b/data/msfgui/msfgui.glade @@ -44,7 +44,6 @@ - False gtk-preferences True @@ -87,7 +86,6 @@ - False Opcodes True @@ -173,7 +171,7 @@ True - Window + _Window True @@ -188,7 +186,7 @@ - + True gtk-justify-fill 1 @@ -210,7 +208,7 @@ - + True gtk-zoom-fit 1 @@ -228,11 +226,33 @@ - + True - _About + _Help True - + + + + + + + True + _Online + True + + + + + + + True + _About + True + + + + + @@ -689,24 +709,24 @@ True - + True View Code + True - - - True - gtk-edit - 1 - 0.5 - 0.5 - 0 - 0 - - - + + + True + gtk-edit + 1 + 0.5 + 0.5 + 0 + 0 + + diff --git a/external/ruby-pcapx/COPYING b/external/ruby-pcapx/COPYING deleted file mode 100644 index eeb586b392..0000000000 --- a/external/ruby-pcapx/COPYING +++ /dev/null @@ -1,340 +0,0 @@ - GNU GENERAL PUBLIC LICENSE - Version 2, June 1991 - - Copyright (C) 1989, 1991 Free Software Foundation, Inc. - 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The licenses for most software are designed to take away your -freedom to share and change it. By contrast, the GNU General Public -License is intended to guarantee your freedom to share and change free -software--to make sure the software is free for all its users. This -General Public License applies to most of the Free Software -Foundation's software and to any other program whose authors commit to -using it. (Some other Free Software Foundation software is covered by -the GNU Library General Public License instead.) You can apply it to -your programs, too. - - When we speak of free software, we are referring to freedom, not -price. Our General Public Licenses are designed to make sure that you -have the freedom to distribute copies of free software (and charge for -this service if you wish), that you receive source code or can get it -if you want it, that you can change the software or use pieces of it -in new free programs; and that you know you can do these things. - - To protect your rights, we need to make restrictions that forbid -anyone to deny you these rights or to ask you to surrender the rights. -These restrictions translate to certain responsibilities for you if you -distribute copies of the software, or if you modify it. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must give the recipients all the rights that -you have. You must make sure that they, too, receive or can get the -source code. And you must show them these terms so they know their -rights. - - We protect your rights with two steps: (1) copyright the software, and -(2) offer you this license which gives you legal permission to copy, -distribute and/or modify the software. - - Also, for each author's protection and ours, we want to make certain -that everyone understands that there is no warranty for this free -software. If the software is modified by someone else and passed on, we -want its recipients to know that what they have is not the original, so -that any problems introduced by others will not reflect on the original -authors' reputations. - - Finally, any free program is threatened constantly by software -patents. We wish to avoid the danger that redistributors of a free -program will individually obtain patent licenses, in effect making the -program proprietary. To prevent this, we have made it clear that any -patent must be licensed for everyone's free use or not licensed at all. - - The precise terms and conditions for copying, distribution and -modification follow. - - GNU GENERAL PUBLIC LICENSE - TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - - 0. This License applies to any program or other work which contains -a notice placed by the copyright holder saying it may be distributed -under the terms of this General Public License. The "Program", below, -refers to any such program or work, and a "work based on the Program" -means either the Program or any derivative work under copyright law: -that is to say, a work containing the Program or a portion of it, -either verbatim or with modifications and/or translated into another -language. (Hereinafter, translation is included without limitation in -the term "modification".) Each licensee is addressed as "you". - -Activities other than copying, distribution and modification are not -covered by this License; they are outside its scope. The act of -running the Program is not restricted, and the output from the Program -is covered only if its contents constitute a work based on the -Program (independent of having been made by running the Program). -Whether that is true depends on what the Program does. - - 1. You may copy and distribute verbatim copies of the Program's -source code as you receive it, in any medium, provided that you -conspicuously and appropriately publish on each copy an appropriate -copyright notice and disclaimer of warranty; keep intact all the -notices that refer to this License and to the absence of any warranty; -and give any other recipients of the Program a copy of this License -along with the Program. - -You may charge a fee for the physical act of transferring a copy, and -you may at your option offer warranty protection in exchange for a fee. - - 2. You may modify your copy or copies of the Program or any portion -of it, thus forming a work based on the Program, and copy and -distribute such modifications or work under the terms of Section 1 -above, provided that you also meet all of these conditions: - - a) You must cause the modified files to carry prominent notices - stating that you changed the files and the date of any change. - - b) You must cause any work that you distribute or publish, that in - whole or in part contains or is derived from the Program or any - part thereof, to be licensed as a whole at no charge to all third - parties under the terms of this License. - - c) If the modified program normally reads commands interactively - when run, you must cause it, when started running for such - interactive use in the most ordinary way, to print or display an - announcement including an appropriate copyright notice and a - notice that there is no warranty (or else, saying that you provide - a warranty) and that users may redistribute the program under - these conditions, and telling the user how to view a copy of this - License. (Exception: if the Program itself is interactive but - does not normally print such an announcement, your work based on - the Program is not required to print an announcement.) - -These requirements apply to the modified work as a whole. If -identifiable sections of that work are not derived from the Program, -and can be reasonably considered independent and separate works in -themselves, then this License, and its terms, do not apply to those -sections when you distribute them as separate works. But when you -distribute the same sections as part of a whole which is a work based -on the Program, the distribution of the whole must be on the terms of -this License, whose permissions for other licensees extend to the -entire whole, and thus to each and every part regardless of who wrote it. - -Thus, it is not the intent of this section to claim rights or contest -your rights to work written entirely by you; rather, the intent is to -exercise the right to control the distribution of derivative or -collective works based on the Program. - -In addition, mere aggregation of another work not based on the Program -with the Program (or with a work based on the Program) on a volume of -a storage or distribution medium does not bring the other work under -the scope of this License. - - 3. You may copy and distribute the Program (or a work based on it, -under Section 2) in object code or executable form under the terms of -Sections 1 and 2 above provided that you also do one of the following: - - a) Accompany it with the complete corresponding machine-readable - source code, which must be distributed under the terms of Sections - 1 and 2 above on a medium customarily used for software interchange; or, - - b) Accompany it with a written offer, valid for at least three - years, to give any third party, for a charge no more than your - cost of physically performing source distribution, a complete - machine-readable copy of the corresponding source code, to be - distributed under the terms of Sections 1 and 2 above on a medium - customarily used for software interchange; or, - - c) Accompany it with the information you received as to the offer - to distribute corresponding source code. (This alternative is - allowed only for noncommercial distribution and only if you - received the program in object code or executable form with such - an offer, in accord with Subsection b above.) - -The source code for a work means the preferred form of the work for -making modifications to it. For an executable work, complete source -code means all the source code for all modules it contains, plus any -associated interface definition files, plus the scripts used to -control compilation and installation of the executable. However, as a -special exception, the source code distributed need not include -anything that is normally distributed (in either source or binary -form) with the major components (compiler, kernel, and so on) of the -operating system on which the executable runs, unless that component -itself accompanies the executable. - -If distribution of executable or object code is made by offering -access to copy from a designated place, then offering equivalent -access to copy the source code from the same place counts as -distribution of the source code, even though third parties are not -compelled to copy the source along with the object code. - - 4. You may not copy, modify, sublicense, or distribute the Program -except as expressly provided under this License. Any attempt -otherwise to copy, modify, sublicense or distribute the Program is -void, and will automatically terminate your rights under this License. -However, parties who have received copies, or rights, from you under -this License will not have their licenses terminated so long as such -parties remain in full compliance. - - 5. You are not required to accept this License, since you have not -signed it. However, nothing else grants you permission to modify or -distribute the Program or its derivative works. These actions are -prohibited by law if you do not accept this License. Therefore, by -modifying or distributing the Program (or any work based on the -Program), you indicate your acceptance of this License to do so, and -all its terms and conditions for copying, distributing or modifying -the Program or works based on it. - - 6. Each time you redistribute the Program (or any work based on the -Program), the recipient automatically receives a license from the -original licensor to copy, distribute or modify the Program subject to -these terms and conditions. You may not impose any further -restrictions on the recipients' exercise of the rights granted herein. -You are not responsible for enforcing compliance by third parties to -this License. - - 7. If, as a consequence of a court judgment or allegation of patent -infringement or for any other reason (not limited to patent issues), -conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot -distribute so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you -may not distribute the Program at all. For example, if a patent -license would not permit royalty-free redistribution of the Program by -all those who receive copies directly or indirectly through you, then -the only way you could satisfy both it and this License would be to -refrain entirely from distribution of the Program. - -If any portion of this section is held invalid or unenforceable under -any particular circumstance, the balance of the section is intended to -apply and the section as a whole is intended to apply in other -circumstances. - -It is not the purpose of this section to induce you to infringe any -patents or other property right claims or to contest validity of any -such claims; this section has the sole purpose of protecting the -integrity of the free software distribution system, which is -implemented by public license practices. Many people have made -generous contributions to the wide range of software distributed -through that system in reliance on consistent application of that -system; it is up to the author/donor to decide if he or she is willing -to distribute software through any other system and a licensee cannot -impose that choice. - -This section is intended to make thoroughly clear what is believed to -be a consequence of the rest of this License. - - 8. If the distribution and/or use of the Program is restricted in -certain countries either by patents or by copyrighted interfaces, the -original copyright holder who places the Program under this License -may add an explicit geographical distribution limitation excluding -those countries, so that distribution is permitted only in or among -countries not thus excluded. In such case, this License incorporates -the limitation as if written in the body of this License. - - 9. The Free Software Foundation may publish revised and/or new versions -of the General Public License from time to time. Such new versions will -be similar in spirit to the present version, but may differ in detail to -address new problems or concerns. - -Each version is given a distinguishing version number. If the Program -specifies a version number of this License which applies to it and "any -later version", you have the option of following the terms and conditions -either of that version or of any later version published by the Free -Software Foundation. If the Program does not specify a version number of -this License, you may choose any version ever published by the Free Software -Foundation. - - 10. If you wish to incorporate parts of the Program into other free -programs whose distribution conditions are different, write to the author -to ask for permission. For software which is copyrighted by the Free -Software Foundation, write to the Free Software Foundation; we sometimes -make exceptions for this. Our decision will be guided by the two goals -of preserving the free status of all derivatives of our free software and -of promoting the sharing and reuse of software generally. - - NO WARRANTY - - 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY -FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN -OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES -PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED -OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS -TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE -PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, -REPAIR OR CORRECTION. - - 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR -REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, -INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING -OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED -TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY -YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER -PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE -POSSIBILITY OF SUCH DAMAGES. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these terms. - - To do so, attach the following notices to the program. It is safest -to attach them to the start of each source file to most effectively -convey the exclusion of warranty; and each file should have at least -the "copyright" line and a pointer to where the full notice is found. - - - Copyright (C) 19yy - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - - -Also add information on how to contact you by electronic and paper mail. - -If the program is interactive, make it output a short notice like this -when it starts in an interactive mode: - - Gnomovision version 69, Copyright (C) 19yy name of author - Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. - This is free software, and you are welcome to redistribute it - under certain conditions; type `show c' for details. - -The hypothetical commands `show w' and `show c' should show the appropriate -parts of the General Public License. Of course, the commands you use may -be called something other than `show w' and `show c'; they could even be -mouse-clicks or menu items--whatever suits your program. - -You should also get your employer (if you work as a programmer) or your -school, if any, to sign a "copyright disclaimer" for the program, if -necessary. Here is a sample; alter the names: - - Yoyodyne, Inc., hereby disclaims all copyright interest in the program - `Gnomovision' (which makes passes at compilers) written by James Hacker. - - , 1 April 1989 - Ty Coon, President of Vice - -This General Public License does not permit incorporating your program into -proprietary programs. If your program is a subroutine library, you may -consider it more useful to permit linking proprietary applications with the -library. If this is what you want to do, use the GNU Library General -Public License instead of this License. diff --git a/external/ruby-pcapx/ChangeLog b/external/ruby-pcapx/ChangeLog deleted file mode 100644 index c9688eede6..0000000000 --- a/external/ruby-pcapx/ChangeLog +++ /dev/null @@ -1,145 +0,0 @@ -2000-08-13 Masaki Fukushima - - * version 0.6 released. - - * packet.c (packet_match): Packet#=~ added. - - * Pcap.c (capture_setfilter): Filter object can be used in - Capture#setfilter. - - * lib/pcaplet.rb: invoke gzip when reading /\.gz$/ file. - Pcaplet.new accept options. - - * Pcap.c: implement Filter logical operation. - (filter_source): Filter#source added. - -2000-08-09 Masaki Fukushima - - * Pcap.c (filter_new): use pcap_compile_nopcap() if available. - -1999-11-08 Masaki Fukushima - - * version 0.5 released. - - * Pcap.c: Call Check_SafeStr() before I/O operation. - - * lib/pcaplet.rb: Use getopts instead of parseparg. - -1999-11-05 Masaki Fukushima - - * Filter document added. - -1999-11-04 Masaki Fukushima - - * Pcap.c (filter_match): datalink and caplen check. - -1999-10-30 Masaki Fukushima - - * Pcap.c (Init_pcap): added Pcap.{lookupdev,lookupnet}. - -1999-10-29 Masaki Fukushima - - * Pcap.c: use RTEST instead of Qtrue/Qfalse test. - -1999-08-27 Masaki Fukushima - - * ip_packet.c (ipaddr_s_new): changed to use gethostbyname(). - - * icmp_packet.c: icmp_type_info lacks type 31-36 hole. - -1999-08-26 Masaki Fukushima - - * version 0.4 released. - - * ICMPPacket document added. - -1999-08-25 Masaki Fukushima - - * udp_packet.c: UdpPacket renamed to UDPPacket. - - * tcp_packet.c: TcpPacket renamed to TCPPacket. - - * ip_packet.c: IpPacket renamed to IPPacket. - -1999-08-24 Masaki Fukushima - - * icmp_packet.c: ICMP support. - -1999-08-18 Masaki Fukushima - - * Pcap.c (Init_pcap): PcapStat is now defined as Pcap::Stat. - -1999-08-17 Masaki Fukushima - - * ip_packet.c (setup_ip_packet): check ip_v == 4 - -1999-08-14 Masaki Fukushima - - * ip_packet.c (setup_ip_packet): ntohs must be used for ip_len. - - * packet.c (Init_packet): Packet#udp? added. - -1999-07-23 Masaki Fukushima - - * extconf.rb: --with-pcap-prefix is changed to --with-pcap-dir - -1999-07-14 Masaki Fukushima - - * ip_packet.c (Init_ip_packet): IP address is now represented by - new class IPAddress implemented in C. IpAddress is obsolete but - remains for backward compatibility. - -1999-07-11 Masaki Fukushima - - * Pcap.c (Init_pcap): Capture includes Enumerable. - -1999-07-02 Masaki Fukushima - - * version 0.3.1 released. - - * Pcap.c: Filter class is added. - - * tcp_packet.c (tcpp_data): data length bug is fixed. - -1999-06-27 Masaki Fukushima - - * Pcap.c (capture_loop): improved to be thread-friendly. - -1999-05-24 Masaki Fukushima - - * version 0.3 released. - - * extconf.rb: --with-pcap-prefix option added. - - * changed to based on ruby-1.3.x. - -1999-04-20 Masaki Fukushima - - * version 0.2 released. - -1999-04-18 Masaki Fukushima - - * UdpPacket documentation added. - -1999-02-08 Masaki Fukushima - - * udp_packet.c: UDP supprot added. - -1998-12-07 Masaki Fukushima - - * version 0.1.1 released. - - * Document about exception classes added. - - * Pcap.c (CheckClass): CheckClass added. - (dumper_dump): check data-link type and caplen. - -1998-12-06 Masaki Fukushima - - * packet.c: Packet#datalink added. - - * English document added. - -1998-12-01 Masaki Fukushima - - * version 0.1 released. diff --git a/external/ruby-pcapx/MANIFEST b/external/ruby-pcapx/MANIFEST deleted file mode 100644 index 9db863d841..0000000000 --- a/external/ruby-pcapx/MANIFEST +++ /dev/null @@ -1,46 +0,0 @@ -MANIFEST -README -README.ja -COPYING -ChangeLog -extconf.rb -ruby_pcap.h -Pcap.c -packet.c -ip_packet.c -tcp_packet.c -udp_packet.c -icmp_packet.c -lib/pcapx_misc.rb -lib/pcapletx.rb -examples/test.rb -examples/tcpdump.rb -examples/httpdump.rb -doc/index.html -doc/Pcap.html -doc/Capture.html -doc/Pcaplet.html -doc/Packet.html -doc/IPPacket.html -doc/TCPPacket.html -doc/UDPPacket.html -doc/ICMPPacket.html -doc/IPAddress.html -doc/Dumper.html -doc/Filter.html -doc/PcapError.html -doc/TruncatedPacket.html -doc-ja/index.html -doc-ja/Pcap.html -doc-ja/Capture.html -doc-ja/Pcaplet.html -doc-ja/Packet.html -doc-ja/IPPacket.html -doc-ja/TCPPacket.html -doc-ja/UDPPacket.html -doc-ja/ICMPPacket.html -doc-ja/IPAddress.html -doc-ja/Dumper.html -doc-ja/Filter.html -doc-ja/PcapError.html -doc-ja/TruncatedPacket.html diff --git a/external/ruby-pcapx/Pcap.c b/external/ruby-pcapx/Pcap.c deleted file mode 100644 index f81a351706..0000000000 --- a/external/ruby-pcapx/Pcap.c +++ /dev/null @@ -1,803 +0,0 @@ -/* - * Pcap.c - * - * $Id: Pcap.c,v 1.10 2000/08/13 05:56:31 fukusima Exp $ - * - * Copyright (C) 1998-2000 Masaki Fukushima - */ - -#include "ruby_pcap.h" -#include "rubysig.h" -#include -#include -#include - -#define DEFAULT_DATALINK DLT_EN10MB -#define DEFAULT_SNAPLEN 68 -#define DEFAULT_PROMISC 1 -#define DEFAULT_TO_MS 1000 -static char pcap_errbuf[PCAP_ERRBUF_SIZE]; - -VALUE mPcap, rbpcap_convert = Qnil; -VALUE ePcapError; -VALUE eTruncatedPacket; -VALUE cFilter; -static VALUE cCapture; -static VALUE cPcapStat; -static VALUE cDumper; - -struct filter_object { - char *expr; - struct bpf_program program; - int datalink; - int snaplen; - VALUE param; - VALUE optimize; - VALUE netmask; -}; - -#define GetFilter(obj, filter) \ - Data_Get_Struct(obj, struct filter_object, filter) - - -static VALUE -pcap_s_lookupdev(self) - VALUE self; -{ - char *dev; - - dev = pcap_lookupdev(pcap_errbuf); - if (dev == NULL) { - rb_raise(ePcapError, "%s", pcap_errbuf); - } - return rb_str_new2(dev); -} - -static VALUE -pcap_s_lookupnet(self, dev) - VALUE self; - VALUE dev; -{ - bpf_u_int32 net, mask, m; - struct in_addr addr; - - Check_Type(dev, T_STRING); - if (pcap_lookupnet(STR2CSTR(dev), &net, &mask, pcap_errbuf) == -1) { - rb_raise(ePcapError, "%s", pcap_errbuf); - } - - addr.s_addr = net; - m = ntohl(mask); - return rb_ary_new3(2, new_ipaddr(&addr), UINT32_2_NUM(m)); -} - -static VALUE -pcap_s_convert(self) - VALUE self; -{ - return rbpcap_convert; -} - -static VALUE -pcap_s_convert_set(self, val) - VALUE self; -{ - rbpcap_convert = val; - return Qnil; -} - -/* - * Capture object - */ - -struct capture_object { - pcap_t *pcap; - bpf_u_int32 netmask; - int dl_type; /* data-link type (DLT_*) */ -}; - -static void -closed_capture() -{ - rb_raise(rb_eRuntimeError, "device is already closed"); -} - -#define GetCapture(obj, cap) {\ - Data_Get_Struct(obj, struct capture_object, cap);\ - if (cap->pcap == NULL) closed_capture();\ -} - -/* called from GC */ -static void -free_capture(cap) - struct capture_object *cap; -{ - DEBUG_PRINT("free_capture"); - if (cap->pcap != NULL) { - DEBUG_PRINT("closing capture"); - rb_thread_fd_close(pcap_fileno(cap->pcap)); - pcap_close(cap->pcap); - cap->pcap = NULL; - } - free(cap); -} - -static VALUE -capture_open_live(argc, argv, class) - int argc; - VALUE *argv; - VALUE class; -{ - VALUE v_device, v_snaplen, v_promisc, v_to_ms; - char *device; - int snaplen, promisc, to_ms; - int rs; - VALUE self; - struct capture_object *cap; - pcap_t *pcap; - bpf_u_int32 net, netmask; - - DEBUG_PRINT("capture_open_live"); - - /* scan arg */ - rs = rb_scan_args(argc, argv, "13", &v_device, &v_snaplen, - &v_promisc, &v_to_ms); - - /* device */ - Check_SafeStr(v_device); - device = RSTRING(v_device)->ptr; - /* snaplen */ - if (rs >= 2) { - Check_Type(v_snaplen, T_FIXNUM); - snaplen = FIX2INT(v_snaplen); - } else { - snaplen = DEFAULT_SNAPLEN; - } - if (snaplen < 0) - rb_raise(rb_eArgError, "invalid snaplen"); - /* promisc */ - if (rs >= 3) { - promisc = RTEST(v_promisc); - } else { - promisc = DEFAULT_PROMISC; - } - /* to_ms */ - if (rs >= 4) { - Check_Type(v_to_ms, T_FIXNUM); - to_ms = FIX2INT(v_to_ms); - } else - to_ms = DEFAULT_TO_MS; - - /* open */ - pcap = pcap_open_live(device, snaplen, promisc, to_ms, pcap_errbuf); - if (pcap == NULL) { - rb_raise(ePcapError, "%s", pcap_errbuf); - } - if (pcap_lookupnet(device, &net, &netmask, pcap_errbuf) == -1) { - netmask = 0; - rb_warning("cannot lookup net: %s\n", pcap_errbuf); - } - - /* setup instance */ - self = Data_Make_Struct(class, struct capture_object, - 0, free_capture, cap); - cap->pcap = pcap; - cap->netmask = netmask; - cap->dl_type = pcap_datalink(pcap); - - return self; -} - -static VALUE -capture_open_offline(class, fname) - VALUE class; - VALUE fname; -{ - VALUE self; - struct capture_object *cap; - pcap_t *pcap; - - DEBUG_PRINT("capture_open_offline"); - - /* open offline */ - Check_SafeStr(fname); - pcap = pcap_open_offline(RSTRING(fname)->ptr, pcap_errbuf); - if (pcap == NULL) { - rb_raise(ePcapError, "%s", pcap_errbuf); - } - - /* setup instance */ - self = Data_Make_Struct(class, struct capture_object, - 0, free_capture, cap); - cap->pcap = pcap; - cap->netmask = 0; - cap->dl_type = pcap_datalink(pcap); - - return self; -} - -static VALUE -capture_close(self) - VALUE self; -{ - struct capture_object *cap; - - DEBUG_PRINT("capture_close"); - GetCapture(self, cap); - - rb_thread_fd_close(pcap_fileno(cap->pcap)); - pcap_close(cap->pcap); - cap->pcap = NULL; - return Qnil; -} - -static void -handler(cap, pkthdr, data) - struct capture_object *cap; - const struct pcap_pkthdr *pkthdr; - const u_char *data; -{ - rb_yield(new_packet(data, pkthdr, cap->dl_type)); -} - -static VALUE -capture_dispatch(argc, argv, self) - int argc; - VALUE *argv; - VALUE self; -{ - VALUE v_cnt; - int cnt; - struct capture_object *cap; - int ret; - - DEBUG_PRINT("capture_dispatch"); - GetCapture(self, cap); - - - /* scan arg */ - if (rb_scan_args(argc, argv, "01", &v_cnt) >= 1) { - FIXNUM_P(v_cnt); - cnt = FIX2INT(v_cnt); - } else - cnt = -1; - - TRAP_BEG; - ret = pcap_dispatch(cap->pcap, cnt, handler, (u_char *)cap); - TRAP_END; - if (ret == -1) - rb_raise(ePcapError, "dispatch: %s", pcap_geterr(cap->pcap)); - - return INT2FIX(ret); -} - -int pcap_read(pcap_t *, int cnt, pcap_handler, u_char *); /* pcap-int.h */ - -static VALUE -capture_loop(argc, argv, self) - int argc; - VALUE *argv; - VALUE self; -{ - VALUE v_cnt; - int cnt; - struct capture_object *cap; - int ret; - - DEBUG_PRINT("capture_loop"); - GetCapture(self, cap); - - - /* scan arg */ - if (rb_scan_args(argc, argv, "01", &v_cnt) >= 1) { - FIXNUM_P(v_cnt); - cnt = FIX2INT(v_cnt); - } else - cnt = -1; - -#if 0 - TRAP_BEG; - ret = pcap_loop(cap->pcap, cnt, handler, (u_char *)cap); - TRAP_END; -#else - if (pcap_file(cap->pcap) != NULL) { - TRAP_BEG; - ret = pcap_loop(cap->pcap, cnt, handler, (u_char *)cap); - TRAP_END; - } else { - int fd = pcap_fileno(cap->pcap); - fd_set rset; - struct timeval tm; - - FD_ZERO(&rset); - tm.tv_sec = 0; - tm.tv_usec = 0; - for (;;) { - do { - FD_SET(fd, &rset); - if (select(fd+1, &rset, NULL, NULL, &tm) == 0) { - rb_thread_wait_fd(fd); - } - TRAP_BEG; - ret = pcap_read(cap->pcap, 1, handler, (u_char *)cap); - TRAP_END; - } while (ret == 0); - if (ret <= 0) - break; - if (cnt > 0) { - cnt -= ret; - if (cnt <= 0) - break; - } - } - } -#endif - return INT2FIX(ret); -} - -static VALUE -capture_setfilter(argc, argv, self) - int argc; - VALUE *argv; - VALUE self; -{ - struct capture_object *cap; - VALUE vfilter, optimize; - char *filter; - int opt; - struct bpf_program program; - - DEBUG_PRINT("capture_setfilter"); - GetCapture(self, cap); - - /* scan arg */ - if (rb_scan_args(argc, argv, "11", &vfilter, &optimize) == 1) { - optimize = Qtrue; - } - - /* check arg */ - if (IsKindOf(vfilter, cFilter)) { - struct filter_object *f; - GetFilter(vfilter, f); - filter = f->expr; - } else { - Check_Type(vfilter, T_STRING); - filter = RSTRING(vfilter)->ptr; - } - opt = RTEST(optimize); - - /* operation */ - if (pcap_compile(cap->pcap, &program, filter, - opt, cap->netmask) < 0) - rb_raise(ePcapError, "setfilter: %s", pcap_geterr(cap->pcap)); - if (pcap_setfilter(cap->pcap, &program) < 0) - rb_raise(ePcapError, "setfilter: %s", pcap_geterr(cap->pcap)); - - return Qnil; -} - -static VALUE -capture_datalink(self) - VALUE self; -{ - struct capture_object *cap; - - DEBUG_PRINT("capture_datalink"); - GetCapture(self, cap); - - return INT2NUM(pcap_datalink(cap->pcap)); -} - -static VALUE -capture_snapshot(self) - VALUE self; -{ - struct capture_object *cap; - - DEBUG_PRINT("capture_snapshot"); - GetCapture(self, cap); - - return INT2NUM(pcap_snapshot(cap->pcap)); -} - -static VALUE -capture_stats(self) - VALUE self; -{ - struct capture_object *cap; - struct pcap_stat stat; - VALUE v_stat; - - DEBUG_PRINT("capture_stats"); - GetCapture(self, cap); - - if (pcap_stats(cap->pcap, &stat) == -1) - return Qnil; - - v_stat = rb_funcall(cPcapStat, rb_intern("new"), 3, - UINT2NUM(stat.ps_recv), - UINT2NUM(stat.ps_drop), - UINT2NUM(stat.ps_ifdrop)); - - return v_stat; -} - -/* - * Dumper object - */ - -struct dumper_object { - pcap_dumper_t *pcap_dumper; - int dl_type; - bpf_u_int32 snaplen; -}; - -static void -closed_dumper() -{ - rb_raise(rb_eRuntimeError, "dumper is already closed"); -} - -#define GetDumper(obj, dumper) {\ - Data_Get_Struct(obj, struct dumper_object, dumper);\ - if (dumper->pcap_dumper == NULL) closed_dumper();\ -} - -/* called from GC */ -static void -free_dumper(dumper) - struct dumper_object *dumper; -{ - DEBUG_PRINT("free_dumper"); - if (dumper->pcap_dumper != NULL) { - DEBUG_PRINT("closing dumper"); - pcap_dump_close(dumper->pcap_dumper); - dumper->pcap_dumper = NULL; - } - free(dumper); -} - -static VALUE -dumper_open(class, v_cap, v_fname) - VALUE class; - VALUE v_cap; - VALUE v_fname; -{ - struct dumper_object *dumper; - struct capture_object *cap; - pcap_dumper_t *pcap_dumper; - VALUE self; - - DEBUG_PRINT("dumper_open"); - - CheckClass(v_cap, cCapture); - GetCapture(v_cap, cap); - Check_SafeStr(v_fname); - - pcap_dumper = pcap_dump_open(cap->pcap, RSTRING(v_fname)->ptr); - if (pcap_dumper == NULL) { - rb_raise(ePcapError, "dumper_open: %s", pcap_geterr(cap->pcap)); - } - - self = Data_Make_Struct(class, struct dumper_object, 0, - free_dumper, dumper); - dumper->pcap_dumper = pcap_dumper; - dumper->dl_type = cap->dl_type; - dumper->snaplen = pcap_snapshot(cap->pcap); - - return self; -} - -static VALUE -dumper_close(self) - VALUE self; -{ - struct dumper_object *dumper; - - DEBUG_PRINT("dumper_close"); - GetDumper(self, dumper); - - pcap_dump_close(dumper->pcap_dumper); - dumper->pcap_dumper = NULL; - return Qnil; -} - -static VALUE -dumper_dump(self, v_pkt) - VALUE self; - VALUE v_pkt; -{ - struct dumper_object *dumper; - struct packet_object *pkt; - - DEBUG_PRINT("dumper_dump"); - GetDumper(self, dumper); - - CheckClass(v_pkt, cPacket); - GetPacket(v_pkt, pkt); - if (pkt->hdr.dl_type != dumper->dl_type) - rb_raise(rb_eArgError, "Cannot dump this packet: data-link type mismatch"); - if (pkt->hdr.pkthdr.caplen > dumper->snaplen) - rb_raise(rb_eArgError, "Cannot dump this packet: too large caplen"); - - pcap_dump((u_char *)dumper->pcap_dumper, &pkt->hdr.pkthdr, pkt->data); - return Qnil; -} - -/* - * Filter object - */ - -/* called from GC */ -static void -mark_filter(filter) - struct filter_object *filter; -{ - rb_gc_mark(filter->param); - rb_gc_mark(filter->optimize); - rb_gc_mark(filter->netmask); -} - -static void -free_filter(filter) - struct filter_object *filter; -{ - free(filter->expr); - free(filter); - /* - * This cause memory leak because filter->program hold some memory. - * We overlook it because libpcap does not implement pcap_freecode(). - */ -} - -static VALUE -filter_new(argc, argv, class) - int argc; - VALUE *argv; - VALUE class; -{ - VALUE self, v_expr, v_optimize, v_capture, v_netmask; - struct filter_object *filter; - struct capture_object *capture; - pcap_t *pcap; - char *expr; - int n, optimize, snaplen, linktype; - bpf_u_int32 netmask; - - n = rb_scan_args(argc, argv, "13", &v_expr, &v_capture, - &v_optimize, &v_netmask); - /* filter expression */ - Check_Type(v_expr, T_STRING); - expr = STR2CSTR(v_expr); - /* capture object */ - if (IsKindOf(v_capture, cCapture)) { - CheckClass(v_capture, cCapture); - GetCapture(v_capture, capture); - pcap = capture->pcap; - } else if (NIL_P(v_capture)) { - /* assume most common case */ - snaplen = DEFAULT_SNAPLEN; - linktype = DEFAULT_DATALINK; - pcap = 0; - } else { - snaplen = NUM2INT(rb_funcall(v_capture, rb_intern("[]"), 1, INT2FIX(0))); - linktype = NUM2INT(rb_funcall(v_capture, rb_intern("[]"), 1, INT2FIX(1))); - pcap = 0; - } - /* optimize flag */ - optimize = 1; - if (n >= 3) { - optimize = RTEST(v_optimize); - } - /* netmask */ - netmask = 0; - if (n >= 4) { - bpf_u_int32 mask = NUM2UINT(v_netmask); - netmask = htonl(mask); - } - - filter = (struct filter_object *)xmalloc(sizeof(struct filter_object)); - if (pcap) { - if (pcap_compile(pcap, &filter->program, expr, optimize, netmask) < 0) - rb_raise(ePcapError, "%s", pcap_geterr(pcap)); - filter->datalink = pcap_datalink(pcap); - filter->snaplen = pcap_snapshot(pcap); - } else { -#ifdef HAVE_PCAP_COMPILE_NOPCAP - if (pcap_compile_nopcap(snaplen, linktype, &filter->program, expr, optimize, netmask) < 0) - /* libpcap-0.5 provides no error report for pcap_compile_nopcap */ - rb_raise(ePcapError, "pcap_compile_nopcap error"); - filter->datalink = linktype; - filter->snaplen = snaplen; -#else - rb_raise(rb_eArgError, "pcap_compile_nopcap needs libpcap-0.5 or later"); -#endif - } - self = Data_Wrap_Struct(class, mark_filter, free_filter, filter); - filter->expr = strdup(expr); - filter->param = v_capture; - filter->optimize = optimize ? Qtrue : Qfalse; - filter->netmask = INT2NUM(ntohl(netmask)); - - return self; -} - -VALUE -filter_match(self, v_pkt) - VALUE self, v_pkt; -{ - struct filter_object *filter; - struct packet_object *pkt; - struct pcap_pkthdr *h; - - GetFilter(self, filter); - CheckClass(v_pkt, cPacket); - GetPacket(v_pkt, pkt); - h = &pkt->hdr.pkthdr; - - if (filter->datalink != pkt->hdr.dl_type) - rb_raise(rb_eRuntimeError, "Incompatible datalink type"); - if (filter->snaplen < h->caplen) - rb_raise(rb_eRuntimeError, "Incompatible snaplen"); - - if (bpf_filter(filter->program.bf_insns, pkt->data, h->len, h->caplen)) - return Qtrue; - else - return Qfalse; -} - -static VALUE -filter_source(self) - VALUE self; -{ - struct filter_object *filter; - - GetFilter(self, filter); - return rb_str_new2(filter->expr); -} - -static VALUE -new_filter(expr, param, optimize, netmask) - char *expr; - VALUE param, optimize, netmask; -{ - return rb_funcall(cFilter, - rb_intern("new"), 4, - rb_str_new2(expr), param, optimize, netmask); -} - -static VALUE -filter_or(self, other) - VALUE self, other; -{ - struct filter_object *filter, *filter2; - char *expr; - - CheckClass(other, cFilter); - GetFilter(self, filter); - GetFilter(other, filter2); - - expr = ALLOCA_N(char, strlen(filter->expr) + strlen(filter2->expr) + 16); - sprintf(expr, "( %s ) or ( %s )", filter->expr, filter2->expr); - return new_filter(expr, filter->param, filter->optimize, filter->netmask); -} - -static VALUE -filter_and(self, other) - VALUE self, other; -{ - struct filter_object *filter, *filter2; - char *expr; - - CheckClass(other, cFilter); - GetFilter(self, filter); - GetFilter(other, filter2); - - expr = ALLOCA_N(char, strlen(filter->expr) + strlen(filter2->expr) + 16); - sprintf(expr, "( %s ) and ( %s )", filter->expr, filter2->expr); - return new_filter(expr, filter->param, filter->optimize, filter->netmask); -} - -static VALUE -filter_not(self) - VALUE self; -{ - struct filter_object *filter; - char *expr; - - GetFilter(self, filter); - expr = ALLOCA_N(char, strlen(filter->expr) + 16); - sprintf(expr, "not ( %s )", filter->expr); - return new_filter(expr, filter->param, filter->optimize, filter->netmask); -} - -/* - * Class definition - */ - -void -Init_PcapX(void) -{ - DEBUG_PRINT("Init_PcapX"); - - /* define module Pcap */ - mPcap = rb_define_module("PcapX"); - rb_define_module_function(mPcap, "lookupdev", pcap_s_lookupdev, 0); - rb_define_module_function(mPcap, "lookupnet", pcap_s_lookupnet, 1); - rb_global_variable(&rbpcap_convert); - rb_define_singleton_method(mPcap, "convert?", pcap_s_convert, 0); - rb_define_singleton_method(mPcap, "convert=", pcap_s_convert_set, 1); - - rb_define_const(mPcap, "DLT_NULL", INT2NUM(DLT_NULL)); - rb_define_const(mPcap, "DLT_EN10MB", INT2NUM(DLT_EN10MB)); - rb_define_const(mPcap, "DLT_EN3MB", INT2NUM(DLT_EN3MB)); - rb_define_const(mPcap, "DLT_AX25", INT2NUM(DLT_AX25)); - rb_define_const(mPcap, "DLT_PRONET", INT2NUM(DLT_PRONET)); - rb_define_const(mPcap, "DLT_CHAOS", INT2NUM(DLT_CHAOS)); - rb_define_const(mPcap, "DLT_IEEE802", INT2NUM(DLT_IEEE802)); - rb_define_const(mPcap, "DLT_ARCNET", INT2NUM(DLT_ARCNET)); - rb_define_const(mPcap, "DLT_SLIP", INT2NUM(DLT_SLIP)); - rb_define_const(mPcap, "DLT_PPP", INT2NUM(DLT_PPP)); - rb_define_const(mPcap, "DLT_FDDI", INT2NUM(DLT_FDDI)); - rb_define_const(mPcap, "DLT_ATM_RFC1483", INT2NUM(DLT_ATM_RFC1483)); -#ifdef DLT_RAW - rb_define_const(mPcap, "DLT_RAW", INT2NUM(DLT_RAW)); - rb_define_const(mPcap, "DLT_SLIP_BSDOS", INT2NUM(DLT_SLIP_BSDOS)); - rb_define_const(mPcap, "DLT_PPP_BSDOS", INT2NUM(DLT_PPP_BSDOS)); -#endif - rb_define_const(mPcap, "DLT_IEEE802_11", INT2NUM(DLT_IEEE802_11)); - rb_define_const(mPcap, "DLT_IEEE802_11_RADIO", INT2NUM(DLT_IEEE802_11_RADIO)); - rb_define_const(mPcap, "DLT_IEEE802_11_RADIO_AVS", INT2NUM(DLT_IEEE802_11_RADIO_AVS)); - rb_define_const(mPcap, "DLT_LINUX_SLL", INT2NUM(DLT_LINUX_SLL)); - rb_define_const(mPcap, "DLT_PRISM_HEADER", INT2NUM(DLT_PRISM_HEADER)); - rb_define_const(mPcap, "DLT_AIRONET_HEADER", INT2NUM(DLT_AIRONET_HEADER)); - - /* define class Capture */ - cCapture = rb_define_class_under(mPcap, "Capture", rb_cObject); - rb_include_module(cCapture, rb_mEnumerable); - rb_define_singleton_method(cCapture, "open_live", capture_open_live, -1); - rb_define_singleton_method(cCapture, "open_offline", capture_open_offline, 1); - rb_define_method(cCapture, "close", capture_close, 0); - rb_define_method(cCapture, "dispatch", capture_dispatch, -1); - rb_define_method(cCapture, "loop", capture_loop, -1); - rb_define_method(cCapture, "each_packet", capture_loop, -1); - rb_define_method(cCapture, "each", capture_loop, -1); - rb_define_method(cCapture, "setfilter", capture_setfilter, -1); - rb_define_method(cCapture, "datalink", capture_datalink, 0); - rb_define_method(cCapture, "snapshot", capture_snapshot, 0); - rb_define_method(cCapture, "snaplen", capture_snapshot, 0); - rb_define_method(cCapture, "stats", capture_stats, 0); - - /* define class Dumper */ - cDumper = rb_define_class_under(mPcap, "Dumper", rb_cObject); - rb_define_singleton_method(cDumper, "open", dumper_open, 2); - rb_define_method(cDumper, "close", dumper_close, 0); - rb_define_method(cDumper, "dump", dumper_dump, 1); - - /* define class Filter */ - cFilter = rb_define_class_under(mPcap, "Filter", rb_cObject); - rb_define_singleton_method(cFilter, "new", filter_new, -1); - rb_define_singleton_method(cFilter, "compile", filter_new, -1); - rb_define_method(cFilter, "=~", filter_match, 1); - rb_define_method(cFilter, "===", filter_match, 1); - rb_define_method(cFilter, "source", filter_source, 0); - rb_define_method(cFilter, "|", filter_or, 1); - rb_define_method(cFilter, "&", filter_and, 1); - rb_define_method(cFilter, "~@", filter_not, 0); - /*rb_define_method(cFilter, "&", filter_and, 1);*/ - - /* define class PcapStat */ - cPcapStat = rb_funcall(rb_cStruct, rb_intern("new"), 4, - Qnil, - ID2SYM(rb_intern("recv")), - ID2SYM(rb_intern("drop")), - ID2SYM(rb_intern("ifdrop"))); - rb_define_const(mPcap, "Stat", cPcapStat); - - /* define exception classes */ - ePcapError = rb_define_class_under(mPcap, "PcapError", rb_eStandardError); - eTruncatedPacket = rb_define_class_under(mPcap, "TruncatedPacket", ePcapError); - - Init_packet(); - rb_f_require(Qnil, rb_str_new2("pcapx_misc")); -} diff --git a/external/ruby-pcapx/README b/external/ruby-pcapx/README deleted file mode 100644 index 8b0a2da13d..0000000000 --- a/external/ruby-pcapx/README +++ /dev/null @@ -1,56 +0,0 @@ -This is a modified version of Masaki Fukushima's ruby-pcap module. - - - -========================= -= README from ruby-pcap = -========================= - -* Introduction - -ruby-pcap is a ruby extension to LBL libpcap (Packet Capture library). -This library also includes classes to access TCP/IP header. - -* Installation - -Requirements: - - - ruby-1.4.x - - libpcap (http://www.tcpdump.org/) - -Compile: - -If ruby supports dynamic link of extension module on your OS, -following commands will install ruby-pcap. - - ruby extconf.rb [options] - make - make install - -You can specify options when you run 'ruby extconf.rb': - -`--with-pcap-dir=PREFIX' - Directory where libpcap is installed. Default is '/usr/local'. - -If dynamic link isn't available, you can link ruby-pcap statically -with ruby. Extract ruby-pcap under the directory 'ext' in ruby source -tree, then build ruby. - -* Usage - -See the documentation under the directory 'doc'. -Directory 'examples' contains some simple scripts. - -* Author - -Masaki Fukushima - -ruby-pcap is copyrighted free software by Masaki Fukushima. - -You can redistribute it and/or modify it under the terms of -the GPL (GNU GENERAL PUBLIC LICENSE). See COPYING file about GPL. - -THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED -WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. See the GPL for -more details. diff --git a/external/ruby-pcapx/doc-ja/Capture.html b/external/ruby-pcapx/doc-ja/Capture.html deleted file mode 100644 index f173a8535b..0000000000 --- a/external/ruby-pcapx/doc-ja/Capture.html +++ /dev/null @@ -1,147 +0,0 @@ - - - -Capture - - -
-

Capture

-
- - パケットキャプチャを表すオブジェクト -
-

スーパークラス:

-
Object
-

インクルードしているモジュール:

-
-
Enumerable
-
-

クラスメソッド:

-
-
-open_live(device[, snaplen[, promisc[, to_ms]]]) -
-

- - デバイスをオープンして Capture オブジェクトを返 - します。 - snaplen, promisc, - to_ms のデフォルト値はそれぞれ 68 オクテット, - true, 1000 ミリ秒です。 -

-
-open_offline(filename) -
-

- - filename で指定されたファイルをオープンして - Captureオブジェクトを返します。 -

-
-

メソッド:

-
-
-close -
-

- - Captureオブジェクトをクローズします。 -

-
-datalink -
-

- - データリンクのタイプを表す整数を返します。 - (DLT_EN10MB 等) -

-
-dispatch([count]) {|packet|...} -
-

- -

- - 各パケットに対して繰り返します。ブロックには - Packetかそのサブクラスのインスタンスが渡されます。 -

- -

- - count には処理するパケットの最大数を指定します。 - count に -1 を指定するとバッファに入っているパ - ケット全てを処理します。count に 0 を指定すると - エラーかファイルの終わりかタイムアウトに達するまでパケット - を処理します。 - count のデフォルト値は -1 です。 -

- -

-
-each_packet([count]) {|packet|...} -
-
-each([count]) {|packet|...} -
-
-loop([count]) {|packet|...} -
-

- -

- - 各パケットに対して繰り返します。ブロックには - Packetかそのサブクラスのインスタンスが渡されます。 -

- -

- - count には処理するパケットの最大数を指定します。 - count に負の数を指定するとエラーかファイルの終わ - りに達するまでパケットを処理します。count のデフォ - ルト値は -1 です。 -

- -

-
-snapshot -
-
-snaplen -
-

- - snapshot の長さを返します。 -

-
-setfilter(filter[, optimize]) -
-

- - filter で指定された文字列、またはFilterを - フィルタとして設定します。 - optimizetrue の場合は最適化を行 - います。optimize のデフォルト値は - true です。 -

-
-stats -
-

- - パケットキャプチャについての統計を含む Struct - を返します。構造体は以下のメンバを持ちます。 -

-
-
recv
受信したパケットの数
drop
取りこぼしたしたパケットの数
-
- -

-
-
-
-

-fukusima@goto.info.waseda.ac.jp
-

- - diff --git a/external/ruby-pcapx/doc-ja/Dumper.html b/external/ruby-pcapx/doc-ja/Dumper.html deleted file mode 100644 index 7a6da5229c..0000000000 --- a/external/ruby-pcapx/doc-ja/Dumper.html +++ /dev/null @@ -1,54 +0,0 @@ - - - -Dumper - - -
-

Dumper

-
- - パケットを tcpdump 形式のファイルに書き出すクラス。生成したファイルは - tcpdump やCapture.open_offlineを使って読むことができます。 -
-

スーパークラス:

-
Object
-

クラスメソッド:

-
-
-open(capture, filename) -
-

- - captureから取り込んだパケットを - filenameに書き出すためのDumperを返し - ます。 -

-
-

メソッド:

-
-
-close -
-

- - Dumperオブジェクトをクローズします。 -

-
-dump(packet) -
-

- - packetをこのDumperに書き出します。 - packetはこのDumperをオープンする時に - 指定したCaptureから取り込まれたものでなければなりま - せん。 -

-
-
-
-

-fukusima@goto.info.waseda.ac.jp
-

- - diff --git a/external/ruby-pcapx/doc-ja/Filter.html b/external/ruby-pcapx/doc-ja/Filter.html deleted file mode 100644 index 94e533a873..0000000000 --- a/external/ruby-pcapx/doc-ja/Filter.html +++ /dev/null @@ -1,112 +0,0 @@ - - - -Filter - - -
-

Filter

-
- - Filter はパケットが、ある条件にマッチするかど - うかを判定します。Filter は実際には - bpf_program へのラッパーとして作られています。 - フィルタの記述方法に関しては tcpdump(1) - を参照して下さい。 -
-

スーパークラス:

-
Object
-

クラスメソッド:

-
-
-compile(expr, capture[, optimize[, netmask]]) -
-
-new(expr, capture[, optimize[, netmask]]) -
-

- -

- - Filterオブジェクトを生成します。 - expr はフィルタの文字列です。capture - は Capture オブジェクトです。optimize - で最適化を行うかどうかを制御します。 - netmask によりローカルネットのネットマスク - を指定します。 -

- -

- - 生成された Filtercapture - から取り込まれたパケットに対してのみ適用できます。 -

- -

- - libpcap-0.5以降 - を使用している場合には capture - の部分に、以下の値を指定することもできます。 -

-
-
[snaplen, datalink]
配列で必要なパラメータを直接与える
省略 (またはnil)
Ethernetでのデフォルトとみなす - ([68, DLT_EN10MB]) -
-
- -

- -

-
-

メソッド:

-
-
-self === packet -
-
-self =~ packet -
-

- - packet がこのフィルタにマッチすればtrueを返 - します。 -

-
-~ self -
-

- - 「 selfではない」という条件を表 - すFilterを返します。 -

-
-self | other -
-

- - 「 selfまたはother 」という条件を表 - すFilterを返します。 -

-
-self & other -
-

- - 「 selfかつother 」という条件を表 - すFilterを返します。 -

-
-source -
-

- - フィルタの元となった文字列を返します。 -

-
-
-
-

-fukusima@goto.info.waseda.ac.jp
-

- - diff --git a/external/ruby-pcapx/doc-ja/ICMPPacket.html b/external/ruby-pcapx/doc-ja/ICMPPacket.html deleted file mode 100644 index 2e7c7c9b8a..0000000000 --- a/external/ruby-pcapx/doc-ja/ICMPPacket.html +++ /dev/null @@ -1,189 +0,0 @@ - - - -ICMPPacket - - -
-

ICMPPacket

-
- -

- - ICMPメッセージを含むパケット。 -

- -

- - ICMPメッセージのフォーマットはICMPタイプによって異なりま - す。そのため特定のICMPタイプのパケットにしか存在しないフィー - ルドがあります。存在しないフィールドにアクセスしようとす - ると例外が発生します。 -

- -

- - どのICMPタイプに対しても有効なフィールドは type, code, - cksum です。 -

- -
-

スーパークラス:

-
IPPacket
-

メソッド:

-
-
-icmp_cksum -
-

- - ICMPチェックサムを返します。 -

-
-icmp_code -
-

- - ICMPコードを返します。 -

-
-icmp_data -
-

- - ICMP_ECHO/ICMP_ECHOREPLYメッセージのデータ部分を - Stringとして返します。 -

-
-icmp_gwaddr -
-

- - ICMP_REDIRECTメッセージのゲートウェイアドレスを - IPAddressとして返します。 -

-
-icmp_id -
-

- - 識別子を返します。 -

-
-icmp_ip -
-

- - 元のIPデータグラムをIPPacketとして返します。 -

-
-icmp_lifetime -
-

- - ICMP_ROUTERADVERTメッセージの有効時間を返します。 -

-
-icmp_nextmtu -
-

- - ICMP_UNREACH_NEEDFRAGメッセージの Next Hop MTU を返しま - す。(参照: rfc1191) -

-
-icmp_num_addrs -
-

- - ICMP_ROUTERADVERTメッセージのアドレス数を返します。 -

-
-icmp_otime -
-
-icmp_rtime -
-
-icmp_ttime -
-

- - ICMP_TSTAMP/ICMP_TSTAMPREPLYメッセージのタイムス - タンプをTimeとして返します。 -

-
-icmp_pptr -
-

- - ICMP_PARAMPROBメッセージのエラーポインタを返します。 -

-
-icmp_radv(nth) -
-

- - ICMP_ROUTERADVERTメッセージのnth番目のアドレ - スエントリを返します。返り値は [address, - preference]なる2要素の配列です。 -

-
-icmp_seq -
-

- - シーケンス番号を返します。 -

-
-icmp_seqle -
-

- -

- - リトルエンディアンとして読みとったシーケンス番号を返し - ます。 -

- -

- - 多くのpingコマンドの実装はシーケンス番 - 号をホストバイトオーダーで書き込みます。したがって、 - リトルエンディアンのホストから送信されたICMPメッセー - ジのシーケンス番号はリトルエンディアンになっている可 - 能性があります。 -

- - -

-
-icmp_type -
-

- - ICMPタイプを返します。 -

-
-icmp_typestr -
-

- - ICMPタイプを表す文字列を返します。(例: "echo reply") -

-
-icmp_wpa -
-

- - ICMP_ROUTERADVERTメッセージのアドレスエントリ長(単位: - 32-bit word)を返します。 -

-
-
-
-

-fukusima@goto.info.waseda.ac.jp
-

- - diff --git a/external/ruby-pcapx/doc-ja/IPAddress.html b/external/ruby-pcapx/doc-ja/IPAddress.html deleted file mode 100644 index 0818f31b31..0000000000 --- a/external/ruby-pcapx/doc-ja/IPAddress.html +++ /dev/null @@ -1,60 +0,0 @@ - - - -IPAddress - - -
-

IPAddress

-
- - IP アドレスを表すオブジェクトです。 -
-

スーパークラス:

-
Object
-

メソッド:

-
-
-self == other -
-

- - 二つの IP アドレスが同じアドレスかどうかを判定します。 -

-
-hostname -
-

- - この IP アドレスに対応するホスト名を返します。 -

-
-to_i -
-

- - IP アドレスの値を整数として返します。 -

-
-to_num_s -
-

- - IP アドレスの値を表す文字列を返します。 -

-
-to_s -
-

- - IP アドレスの値を表す文字列かホスト名を返します。どちらを返 - すかはPcap.convert= で設定します。 -

-
-
-
-

-fukusima@goto.info.waseda.ac.jp
-

- - diff --git a/external/ruby-pcapx/doc-ja/IPPacket.html b/external/ruby-pcapx/doc-ja/IPPacket.html deleted file mode 100644 index 88f19a005a..0000000000 --- a/external/ruby-pcapx/doc-ja/IPPacket.html +++ /dev/null @@ -1,142 +0,0 @@ - - - -IPPacket - - -
-

IPPacket

-
- - IPヘッダを含むパケット。 -
-

スーパークラス:

-
Packet
-

メソッド:

-
-
-ip_data -
-

- - データ部分をStringとして返します。 -

-
-ip_df? -
-

- - Don't Fragment ビットが立っているかどうかを返します。 -

-
-ip_dst -
-
-dst -
-

- - デスティネーション IP アドレスをIPAddress として返します。 -

-
-ip_flags -
-

- - IP フラグビットフィールド (3 bit) の値を返します。 -

-
-ip_hlen -
-

- - ヘッダ長を返します。(単位: 4 octets) -

-
-ip_id -
-

- - Identification フィールドの値を返します。 -

-
-ip_len -
-

- - パケット長を返します。(単位: octet) -

-
-ip_mf? -
-

- - More Fragment ビットが立っているかどうかを返します。 -

-
-ip_off -
-

- - フラグメントオフセットを返します。 -

-
-ip_proto -
-

- - プロトコルフィールドの値を返します。 -

-
-ip_src -
-
-src -
-

- - ソース IP アドレスをIPAddress として返します。 -

-
-ip_sum -
-

- - チェックサムフィールドの値を返します。 -

-
-ip_tos -
-

- - TOSフィールドの値を返します。 -

-
-ip_ttl -
-

- - TTL フィールドの値を返します。 -

-
-ip_ver -
-

- - IP バージョンフィールドの値を返します。 -

-
-to_s -
-

- - 文字列に変換します。 -

-
-
-
-

-fukusima@goto.info.waseda.ac.jp
-

- - diff --git a/external/ruby-pcapx/doc-ja/Packet.html b/external/ruby-pcapx/doc-ja/Packet.html deleted file mode 100644 index 49331b7bcf..0000000000 --- a/external/ruby-pcapx/doc-ja/Packet.html +++ /dev/null @@ -1,101 +0,0 @@ - - - -Packet - - -
-

Packet

-
- - Captureによってキャプチャされたパケットのデータ。 - Packet、およびそのサブクラスはMarshalに対応 - しています。 -
-

スーパークラス:

-
Object
-

メソッド:

-
-
-caplen -
-

- - パケットのキャプチャされている部分の長さを返します。 -

-
-datalink -
-

- - データリンクのタイプを表す整数を返します。 - (DLT_EN10MB 等) -

-
-ip? -
-

- - このパケットがIPPacket - かそのサブクラスのインスタンスであれば - true を返します。 -

-
-len -
-
-length -
-
-size -
-

- - パケット全体の長さを返します。 -

-
-raw_data -
-

- - このパケットの先頭からの生データをStringとして返します。 -

-
-tcp? -
-

- - このパケットがTCPPacketかそのサブクラスのインス - タンスであれば true を返します。 -

-
-time -
-

- - このパケットのタイムスタンプを Time オブジェク - トとして返します。 -

-
-time_i -
-

- - このパケットのタイムスタンプを整数として返します。 -

-
-udp? -
-

- - このパケットがUDPPacketかそのサブクラスのインス - タンスであれば true を返します。 -

-
-
-
-

-fukusima@goto.info.waseda.ac.jp
-

- - diff --git a/external/ruby-pcapx/doc-ja/Pcap.html b/external/ruby-pcapx/doc-ja/Pcap.html deleted file mode 100644 index a6ac6a5c1f..0000000000 --- a/external/ruby-pcapx/doc-ja/Pcap.html +++ /dev/null @@ -1,111 +0,0 @@ - - - -Pcap - - -
-

Pcap

-
- - pcap 全般に関するメソッドや定数を定義しています。 -
-

定数:

-
-
-DLT_NULL -
-
-DLT_EN10MB -
-
-DLT_EN3MB -
-
-DLT_AX25 -
-
-DLT_PRONET -
-
-DLT_CHAOS -
-
-DLT_IEEE802 -
-
-DLT_ARCNET -
-
-DLT_SLIP -
-
-DLT_PPP -
-
-DLT_FDDI -
-
-DLT_ATM_RFC1483 -
-
-DLT_RAW -
-
-DLT_SLIP_BSDOS -
-
-DLT_PPP_BSDOS -
-

- - データリンク層の種類を表す定数。 -

-
-

モジュールメソッド:

-
-
-convert = bool -
-

- - Pcap モジュール中のクラスが IP アドレスなどの数値を - 文字列に変換しようとした時の動作を設定します。true - ならばそのような数値は名前に変換されます。 -

-
-convert? -
-

- - Pcap モジュール中のクラスが IP アドレスなどの数値を - 文字列に変換しようとした時の動作を返します。true - ならばそのような数値は名前に変換されます。 -

-
-lookupdev -
-

- - ネットワークデバイス名を返します。 -

-
-lookupnet(device) -
-

- - [net, mask] なる2要素配列を返します。 - netはネットワーク番号を表す - IPAddressです。 - maskはネットマスクを表すIntegerです。 - 引数deviceによりネットワークデバイス名を指定 - します。 -

-
-
-
-

-fukusima@goto.info.waseda.ac.jp
-

- - diff --git a/external/ruby-pcapx/doc-ja/PcapError.html b/external/ruby-pcapx/doc-ja/PcapError.html deleted file mode 100644 index 2543203534..0000000000 --- a/external/ruby-pcapx/doc-ja/PcapError.html +++ /dev/null @@ -1,21 +0,0 @@ - - - -PcapError - - -
-

PcapError

-
- - pcap に関する例外です。 -
-

スーパークラス:

-
StandardError
-
-
-

-fukusima@goto.info.waseda.ac.jp
-

- - diff --git a/external/ruby-pcapx/doc-ja/Pcaplet.html b/external/ruby-pcapx/doc-ja/Pcaplet.html deleted file mode 100644 index cbea64eacd..0000000000 --- a/external/ruby-pcapx/doc-ja/Pcaplet.html +++ /dev/null @@ -1,113 +0,0 @@ - - - -Pcaplet - - -
-

Pcaplet

-
- -

- - Captureを使うパケット処理ツールの雛形を提供するクラスで - す。 - 使うときは'pcaplet'requireして下 - さい。 -

- -

- - 典型的な使い方: -

-
require 'pcaplet'
-
-my_tool = Pcaplet.new
-my_tool.each_packet {|pkt|
-  # pkt について処理を行なうコード
-}
-my_tool.close
-        
-
- -

- -

- - コマンドラインで指定されたフィルタ、および - 以下のコマンドラインオプションを tcpdump と同様に解釈します。 -

-
-i -r -c -s -n
-
-
- - '-r' オプションでは、gzipで圧縮されたファイルを読 - み込むこともできます。 -

- -
-

スーパークラス:

-
Object
-

クラスメソッド:

-
-
-new([option]) -
-

- - Pcapletオブジェクトを生成します。コマンドライン - の解析とデバイスのオープンが行なわれます。 - optionを指定すると、コマンドラインオプションに - 追加されます。 -

-
-

メソッド:

-
-
-add_filter(filter) -
-

- - コマンドラインで指定されたフィルタ加えて、さらに - filterを追加します。実際にはフィルタを以下のよ - うに設定します。 -

-
"( current_filter ) and ( filter )"
-
-
- -

-
-each_packet {|packet|...} -
-
-each {|packet|...} -
-

- - 各パケットに対して繰り返します。ブロックには - Packetクラスかそのサブクラスのインスタンスが渡されま - す。 -

-
-capture -
-

- - 内部で使用している Capture オブジェクトを返します。 -

-
-close -
-

- - デバイスをクローズします。 -

-
-
-
-

-fukusima@goto.info.waseda.ac.jp
-

- - diff --git a/external/ruby-pcapx/doc-ja/TCPPacket.html b/external/ruby-pcapx/doc-ja/TCPPacket.html deleted file mode 100644 index adbfe1e6c7..0000000000 --- a/external/ruby-pcapx/doc-ja/TCPPacket.html +++ /dev/null @@ -1,148 +0,0 @@ - - - -TCPPacket - - -
-

TCPPacket

-
- - TCPヘッダを含むパケット。 -
-

スーパークラス:

-
IPPacket
-

メソッド:

-
-
-tcp_ack -
-

- - Acknowledgement Number を返します。 -

-
-tcp_data -
-

- - データ部分を String として返します。 -

-
-tcp_data_len -
-

- - データ部分の長さを返します。 -

-
-tcp_dport -
-
-dport -
-

- - デスティネーションポート番号を返します. -

-
-tcp_flags -
-

- - TCP フラグフィールドの値 (6 bit) を返します。 -

-
-tcp_flags_s -
-

- - TCP フラグフィールドの値 (6 bit) を - ".A...F" といった形式の文字列として返します。 -

-
-tcp_fin? -
-
-tcp_syn? -
-
-tcp_rst? -
-
-tcp_psh? -
-
-tcp_ack? -
-
-tcp_urg? -
-

- - フラグが立っていればtrueを,そうでなければ - falseを返します. -

-
-tcp_off -
-
-tcp_hlen -
-

- - TCP データオフセット(TCPヘッダ長)を返します。 -

-
-tcp_seq -
-

- - Sequence Number を返します。 -

-
-tcp_sum -
-

- - Checksum フィールドの値を返します。 -

-
-tcp_sport -
-
-sport -
-

- - ソースポート番号を返します. -

-
-tcp_urp -
-

- - Urgent Pointer フィールドの値を返します。 -

-
-tcp_win -
-

- - Window Size を返します。 -

-
-to_s -
-

- - 文字列に変換します。 -

-
-
-
-

-fukusima@goto.info.waseda.ac.jp
-

- - diff --git a/external/ruby-pcapx/doc-ja/TruncatedPacket.html b/external/ruby-pcapx/doc-ja/TruncatedPacket.html deleted file mode 100644 index b2c085baf2..0000000000 --- a/external/ruby-pcapx/doc-ja/TruncatedPacket.html +++ /dev/null @@ -1,22 +0,0 @@ - - - -TruncatedPacket - - -
-

TruncatedPacket

-
- - 要求されたパケットに関する情報が、キャプチャされたデータ内に - 存在しません。 -
-

スーパークラス:

-
PcapError
-
-
-

-fukusima@goto.info.waseda.ac.jp
-

- - diff --git a/external/ruby-pcapx/doc-ja/UDPPacket.html b/external/ruby-pcapx/doc-ja/UDPPacket.html deleted file mode 100644 index 5bd4103245..0000000000 --- a/external/ruby-pcapx/doc-ja/UDPPacket.html +++ /dev/null @@ -1,73 +0,0 @@ - - - -UDPPacket - - -
-

UDPPacket

-
- - UDPヘッダを含むパケット。 -
-

スーパークラス:

-
IPPacket
-

メソッド:

-
-
-udp_data -
-

- - データ部分を String として返します。 -

-
-udp_dport -
-
-dport -
-

- - デスティネーションポート番号を返します. -

-
-udp_len -
-

- - Lengthフィールドの値を返します。この値はUDPデータグラム - 全体の長さ(単位: オクテット)を表します。 -

-
-udp_sum -
-

- - Checksum フィールドの値を返します。 -

-
-udp_sport -
-
-sport -
-

- - ソースポート番号を返します. -

-
-to_s -
-

- - 文字列に変換します。 -

-
-
-
-

-fukusima@goto.info.waseda.ac.jp
-

- - diff --git a/external/ruby-pcapx/doc-ja/index.html b/external/ruby-pcapx/doc-ja/index.html deleted file mode 100644 index 946f776010..0000000000 --- a/external/ruby-pcapx/doc-ja/index.html +++ /dev/null @@ -1,54 +0,0 @@ - - -Ruby/Pcap Library - - - -

Ruby/Pcap拡張ライブラリ

- -LBL の libpcap (Packet Capture library) への ruby インタフェースです。 - -

モジュール

- - -

クラス

- -以下のクラスは全て Pcap モジュールの下で定義されています。 -したがって使用するときは Pcap モジュールを -include するか、もしくは Pcap::Capture のよ -うに参照してください。 - - - -

例外

- - - -
-

- -fukusima@goto.info.waseda.ac.jp
-

- diff --git a/external/ruby-pcapx/doc/Capture.html b/external/ruby-pcapx/doc/Capture.html deleted file mode 100644 index 19f83ed80b..0000000000 --- a/external/ruby-pcapx/doc/Capture.html +++ /dev/null @@ -1,144 +0,0 @@ - - - -Capture - - -
-

Capture

-
- - Packet Capture Object -
-

Super Class:

-
Object
-

Included Modules:

-
-
Enumerable
-
-

Class Methods:

-
-
-open_live(device[, snaplen[, promisc[, to_ms]]]) -
-

- - Open specified device and return Capture - object. - Default value for snaplen, - promisc and to_ms are 68 octets, - true and 1000 milliseconds. -

-
-open_offline(filename) -
-

- - Open filename and return Capture object. -

-
-

Methods:

-
-
-close -
-

- - Close Capture object. -

-
-datalink -
-

- - Return an integer representing data-link type. - (e.g. DLT_EN10MB) -

-
-dispatch([count]) {|packet|...} -
-

- -

- - Iterate over each packet. The argument given to the block - is an instance of Packet or its sub-class. -

- -

- - count specifies the maximum number of packets to - process. a count of -1 processes all the packets - received in one buffer. a count of 0 processes all - packets until an error occurs, EOF is reached, or the read - times out. - Default of count is -1. -

- -

-
-each_packet([count]) {|packet|...} -
-
-each([count]) {|packet|...} -
-
-loop([count]) {|packet|...} -
-

- -

- - Iterate over each packet. The argument given to the block - is an instance of Packet or its sub-class. -

- -

- - count specifies the maximum number of packets to - process. A negative count processes packets forever - or until EOF is reached. Default of count is -1. -

- -

-
-snapshot -
-
-snaplen -
-

- - Return the snapshot length. -

-
-setfilter(filter[, optimize]) -
-

- - Specify filter as packet filter. - filter can be a string or a Filter object. - optimize controls whether optimization is performed. - Default of optimize is true. -

-
-stats -
-

- - Return a Struct which represents packet statistics. - This struct has following members. -

-
-
recv
number of received packets
drop
number of dropped packets
-
- -

-
-
-
-

-fukusima@goto.info.waseda.ac.jp
-

- - diff --git a/external/ruby-pcapx/doc/Dumper.html b/external/ruby-pcapx/doc/Dumper.html deleted file mode 100644 index 28a84f04e3..0000000000 --- a/external/ruby-pcapx/doc/Dumper.html +++ /dev/null @@ -1,52 +0,0 @@ - - - -Dumper - - -
-

Dumper

-
- - Class to dump packets to tcpdump-format file. Generated file - can be read with tcpdump and Capture.open_offline. -
-

Super Class:

-
Object
-

Class Methods:

-
-
-open(capture, filename) -
-

- - Return a Dumper to dump packets captured by - capture to filename. -

-
-

Methods:

-
-
-close -
-

- - close Dumper. -

-
-dump(packet) -
-

- - Dump packet to this Dumper. - packet must be a packet captured by - Capture specified when opening this Dumper. -

-
-
-
-

-fukusima@goto.info.waseda.ac.jp
-

- - diff --git a/external/ruby-pcapx/doc/Filter.html b/external/ruby-pcapx/doc/Filter.html deleted file mode 100644 index 68e2ea4164..0000000000 --- a/external/ruby-pcapx/doc/Filter.html +++ /dev/null @@ -1,109 +0,0 @@ - - - -Filter - - -
-

Filter

-
- - Filter determines whether a packet satisfies - specified condition. Actually Filter is - wrapper for bpf_program. For details of filter - expression, see tcpdump(1). -
-

Super Class:

-
Object
-

Class Methods:

-
-
-compile(expr, capture[, optimize[, netmask]]) -
-
-new(expr, capture[, optimize[, netmask]]) -
-

- -

- - Create a new Filter object. - expr is a filter string. capture - is a Capture object. optimize - controls optimization of resulting code. - netmask specifies the netmask of the local net. -

- -

- - Created Filter can be applied to packets - captured via capture. -

- -

- - If libpcap-0.5 or later - used, one of following values can be specified - instead of capture: -

-
-
[snaplen, datalink]
an array containing required parameters
omitted (or nil)
Ethernet default - ([68, DLT_EN10MB]) -
-
- -

- -

-
-

Methods:

-
-
-self === packet -
-
-self =~ packet -
-

- - Return true if packet matches this filter. -

-
-~ self -
-

- - Return a Filter which represents - "not self". -

-
-self | other -
-

- - Return a Filter which represents - "self or other". -

-
-self & other -
-

- - Return a Filter which represents - "self and other". -

-
-source -
-

- - Returns the orginal string from which the filter is constructed. -

-
-
-
-

-fukusima@goto.info.waseda.ac.jp
-

- - diff --git a/external/ruby-pcapx/doc/ICMPPacket.html b/external/ruby-pcapx/doc/ICMPPacket.html deleted file mode 100644 index ba99a09edd..0000000000 --- a/external/ruby-pcapx/doc/ICMPPacket.html +++ /dev/null @@ -1,184 +0,0 @@ - - - -ICMPPacket - - -
-

ICMPPacket

-
- -

- - A packet carrying ICMP message. -

- - ICMP message formats are vary according to ICMP type. - Thus some fields exist in certain types of packet. Any - attempt to access nonexistence field raises an exception. -

- -

- - Type, code and cksum fields are valid for any ICMP type. -

- -

- -
-

Super Class:

-
IPPacket
-

Methods:

-
-
-icmp_cksum -
-

- - Return ICMP checksum. -

-
-icmp_code -
-

- - Return ICMP code. -

-
-icmp_data -
-

- - Return data portion of ICMP_ECHO/ICMP_ECHOREPLY - messages as String -

-
-icmp_gwaddr -
-

- - Return gateway address of ICMP_REDIRECT message as - IPAddress. -

-
-icmp_id -
-

- - Return identifier. -

-
-icmp_ip -
-

- - Return original IP Datagram as IPPacket. -

-
-icmp_lifetime -
-

- - Return lifetime of ICMP_ROUTERADVERT message. -

-
-icmp_nextmtu -
-

- - Return Next Hop MTU of ICMP_UNREACH_NEEDFRAG message - (See rfc1191). -

-
-icmp_num_addrs -
-

- - Return number of addresses of ICMP_ROUTERADVERT message. -

-
-icmp_otime -
-
-icmp_rtime -
-
-icmp_ttime -
-

- - Return timestamp of - ICMP_TSTAMP/ICMP_TSTAMPREPLY message as Time. -

-
-icmp_pptr -
-

- - Return error pointer of ICMP_PARAMPROB message. -

-
-icmp_radv(nth) -
-

- - Return nth address entry of - ICMP_ROUTERADVERT message. Returned value is a two - elements array [address, preference]. -

-
-icmp_seq -
-

- - Return sequence number. -

-
-icmp_seqle -
-

- -

- - Return sequence number interpreted as little endian. -

- -

- - No small portion of ping command - implementations write sequence number in host byte - order. Thus the sequence number of ICMP messages - transmitted from little endian host may be in little - endian. -

- -

-
-icmp_type -
-

- - Return ICMP type. -

-
-icmp_typestr -
-

- - Return string describing ICMP type (e.g. "echo reply"). -

-
-icmp_wpa -
-

- - Return word per address entry of ICMP_ROUTERADVERT message. -

-
-
-
-

-fukusima@goto.info.waseda.ac.jp
-

- - diff --git a/external/ruby-pcapx/doc/IPAddress.html b/external/ruby-pcapx/doc/IPAddress.html deleted file mode 100644 index c211041723..0000000000 --- a/external/ruby-pcapx/doc/IPAddress.html +++ /dev/null @@ -1,60 +0,0 @@ - - - -IPAddress - - -
-

IPAddress

-
- - IP Address object. -
-

Super Class:

-
Object
-

Methods:

-
-
-self == other -
-

- - Return true if two addresses are the same address. -

-
-hostname -
-

- - Return host name correspond to this address. -

-
-to_i -
-

- - Return the value of IP address as integer. -

-
-to_num_s -
-

- - Return numerical string representation -

-
-to_s -
-

- - Return numerical string representation or host name. - Behavior of this method is controlled by Pcap.convert=. -

-
-
-
-

-fukusima@goto.info.waseda.ac.jp
-

- - diff --git a/external/ruby-pcapx/doc/IPPacket.html b/external/ruby-pcapx/doc/IPPacket.html deleted file mode 100644 index c553608b56..0000000000 --- a/external/ruby-pcapx/doc/IPPacket.html +++ /dev/null @@ -1,142 +0,0 @@ - - - -IPPacket - - -
-

IPPacket

-
- - A packet carrying IP header. -
-

Super Class:

-
Packet
-

Methods:

-
-
-ip_data -
-

- - Return data part as String. -

-
-ip_df? -
-

- - Return true if Don't Fragment bit is set. -

-
-ip_dst -
-
-dst -
-

- - Return destination IP address as IPAddress. -

-
-ip_flags -
-

- - Return the value of 3-bits IP flag field. -

-
-ip_hlen -
-

- - Return header length. (Unit: 4 octets) -

-
-ip_id -
-

- - Return identification. -

-
-ip_len -
-

- - Return total length. -

-
-ip_mf? -
-

- - Return true if More Fragment bit is set. -

-
-ip_off -
-

- - Return fragment offset. -

-
-ip_proto -
-

- - Return the value of protocol field. -

-
-ip_src -
-
-src -
-

- - Return source IP address as IPAddress. -

-
-ip_sum -
-

- - Return the value of checksum field. -

-
-ip_tos -
-

- - Return the value of TOS field. -

-
-ip_ttl -
-

- - Return TTL. -

-
-ip_ver -
-

- - Return IP version. -

-
-to_s -
-

- - Return string representation. -

-
-
-
-

-fukusima@goto.info.waseda.ac.jp
-

- - diff --git a/external/ruby-pcapx/doc/Packet.html b/external/ruby-pcapx/doc/Packet.html deleted file mode 100644 index 6e958b1042..0000000000 --- a/external/ruby-pcapx/doc/Packet.html +++ /dev/null @@ -1,98 +0,0 @@ - - - -Packet - - -
-

Packet

-
- - Packet captured with Capture object. - Packet and its sub-classes are Marshal compliant. -
-

Super Class:

-
Object
-

Methods:

-
-
-caplen -
-

- - Return captured length. -

-
-datalink -
-

- - Return an integer representing data-link type. - (e.g. DLT_EN10MB) -

-
-ip? -
-

- - Return true if this packet is an instance of - IPPacket or its sub-class. -

-
-len -
-
-length -
-
-size -
-

- - Return total length of packet. -

-
-raw_data -
-

- - Return raw data of packet as String. -

-
-tcp? -
-

- - Return true if this packet is an instance of - TCPPacket or its sub-class. -

-
-time -
-

- - Return timestamp as Time. -

-
-time_i -
-

- - Return timestamp as integer. -

-
-udp? -
-

- - Return true if this packet is an instance of - UDPPacket or its sub-class. -

-
-
-
-

-fukusima@goto.info.waseda.ac.jp
-

- - diff --git a/external/ruby-pcapx/doc/Pcap.html b/external/ruby-pcapx/doc/Pcap.html deleted file mode 100644 index 3323832df8..0000000000 --- a/external/ruby-pcapx/doc/Pcap.html +++ /dev/null @@ -1,113 +0,0 @@ - - - -Pcap - - -
-

Pcap

-
- - Pcap defines general methods and constants related to - pcap. -
-

Constants:

-
-
-DLT_NULL -
-
-DLT_EN10MB -
-
-DLT_EN3MB -
-
-DLT_AX25 -
-
-DLT_PRONET -
-
-DLT_CHAOS -
-
-DLT_IEEE802 -
-
-DLT_ARCNET -
-
-DLT_SLIP -
-
-DLT_PPP -
-
-DLT_FDDI -
-
-DLT_ATM_RFC1483 -
-
-DLT_RAW -
-
-DLT_SLIP_BSDOS -
-
-DLT_PPP_BSDOS -
-

- - Data-link type constants. -

-
-

Module Methods:

-
-
-convert = bool -
-

- - Set the behavior of classes under module Pcap - when they convert IP address or other numbers to string. - Value true means that the numbers are converted - to their symbolic name. -

-
-convert? -
-

- - Return the behavior of classes under module Pcap - when they convert IP address or other numbers to string. - Value true means that the numbers are converted - to their symbolic name. -

-
-lookupdev -
-

- - Return a name of network device. -

-
-lookupnet(device) -
-

- - Return a two-element array - [net, mask]. - net is network number as IPAddress. - mask is netmask as Integer. - Argument device is network device name. -

-
-
-
-

-fukusima@goto.info.waseda.ac.jp
-

- - diff --git a/external/ruby-pcapx/doc/PcapError.html b/external/ruby-pcapx/doc/PcapError.html deleted file mode 100644 index a444e96af4..0000000000 --- a/external/ruby-pcapx/doc/PcapError.html +++ /dev/null @@ -1,21 +0,0 @@ - - - -PcapError - - -
-

PcapError

-
- - Exception about pcap. -
-

Super Class:

-
StandardError
-
-
-

-fukusima@goto.info.waseda.ac.jp
-

- - diff --git a/external/ruby-pcapx/doc/Pcaplet.html b/external/ruby-pcapx/doc/Pcaplet.html deleted file mode 100644 index cca75ba797..0000000000 --- a/external/ruby-pcapx/doc/Pcaplet.html +++ /dev/null @@ -1,108 +0,0 @@ - - - -Pcaplet - - -
-

Pcaplet

-
- -

- - Pcaplet provides a template for packet monitoring tool - using Capture. - You need to require 'pcaplet' to use this class. -

- -

- - Typical usage: -

-
require 'pcaplet'
-
-my_tool = Pcaplet.new
-my_tool.each_packet {|pkt|
-  # code for processing pkt
-}
-my_tool.close
-        
-
- -

- -

- - Pcaplet interprets filter expression specified in - command line and following command line options as tcpdump does. -

-
-i -r -c -s -n
-
-
- - '-r' option can handle gzipped file. -

- -
-

Super Class:

-
Object
-

Class Methods:

-
-
-new([option]) -
-

- - Generate Pcaplet instance. Command line - analysis and device open is performed. - option is added to command line options. -

-
-

Methods:

-
-
-add_filter(filter) -
-

- - Add filter to the filter specified in command line. - Filter is set as follows. -

-
"( current_filter ) and ( filter )"
-
-
- -

-
-each_packet {|packet|...} -
-
-each {|packet|...} -
-

- - Iterate over each packet. The argument given to the block - is an instance of Packet or its sub-class. -

-
-capture -
-

- - Return Capture object which is used internally. -

-
-close -
-

- - Close underlying device. -

-
-
-
-

-fukusima@goto.info.waseda.ac.jp
-

- - diff --git a/external/ruby-pcapx/doc/TCPPacket.html b/external/ruby-pcapx/doc/TCPPacket.html deleted file mode 100644 index 92675b7fa8..0000000000 --- a/external/ruby-pcapx/doc/TCPPacket.html +++ /dev/null @@ -1,147 +0,0 @@ - - - -TCPPacket - - -
-

TCPPacket

-
- - A packet carrying TCP header. -
-

Super Class:

-
IPPacket
-

Methods:

-
-
-tcp_ack -
-

- - Return acknowledgement number. -

-
-tcp_data -
-

- - Return data part as String. -

-
-tcp_data_len -
-

- - Return length of data part. -

-
-tcp_dport -
-
-dport -
-

- - Return destination port number. -

-
-tcp_flags -
-

- - Return the value of 6-bits flag field. -

-
-tcp_flags_s -
-

- - Return the value of 6-bits flag field as string like - ".A...F". -

-
-tcp_fin? -
-
-tcp_syn? -
-
-tcp_rst? -
-
-tcp_psh? -
-
-tcp_ack? -
-
-tcp_urg? -
-

- - Return true if flag is set. -

-
-tcp_off -
-
-tcp_hlen -
-

- - Return TCP data offset (header length). (Unit: 4-octets) -

-
-tcp_seq -
-

- - Return sequence number. -

-
-tcp_sum -
-

- - Return the value of checksum field. -

-
-tcp_sport -
-
-sport -
-

- - Return source port number. -

-
-tcp_urp -
-

- - Return urgent pointer. -

-
-tcp_win -
-

- - Return window size. -

-
-to_s -
-

- - Return string representation. -

-
-
-
-

-fukusima@goto.info.waseda.ac.jp
-

- - diff --git a/external/ruby-pcapx/doc/TruncatedPacket.html b/external/ruby-pcapx/doc/TruncatedPacket.html deleted file mode 100644 index 1a3f672a44..0000000000 --- a/external/ruby-pcapx/doc/TruncatedPacket.html +++ /dev/null @@ -1,22 +0,0 @@ - - - -TruncatedPacket - - -
-

TruncatedPacket

-
- - Requested packet information is not available because necessary data - is truncated out of capture buffer. -
-

Super Class:

-
PcapError
-
-
-

-fukusima@goto.info.waseda.ac.jp
-

- - diff --git a/external/ruby-pcapx/doc/UDPPacket.html b/external/ruby-pcapx/doc/UDPPacket.html deleted file mode 100644 index 3b476eede0..0000000000 --- a/external/ruby-pcapx/doc/UDPPacket.html +++ /dev/null @@ -1,73 +0,0 @@ - - - -UDPPacket - - -
-

UDPPacket

-
- - A packet carrying UDP header. -
-

Super Class:

-
IPPacket
-

Methods:

-
-
-udp_data -
-

- - Return data part as String. -

-
-udp_dport -
-
-dport -
-

- - Return destination port number. -

-
-udp_len -
-

- - Return value of length field. This value represents - the length in octets of this UDP datagram. -

-
-udp_sum -
-

- - Return the value of checksum field. -

-
-udp_sport -
-
-sport -
-

- - Return source port number. -

-
-to_s -
-

- - Return string representation. -

-
-
-
-

-fukusima@goto.info.waseda.ac.jp
-

- - diff --git a/external/ruby-pcapx/doc/index.html b/external/ruby-pcapx/doc/index.html deleted file mode 100644 index 80f0ef882a..0000000000 --- a/external/ruby-pcapx/doc/index.html +++ /dev/null @@ -1,53 +0,0 @@ - - -Ruby/Pcap Library - - - -

Ruby/Pcap extension library

- -Ruby interface to LBL libpcap (Packet Capture library). - -

Modules

- - -

Classes

- -Following classes are defined under module Pcap. -When you use these classes, you need to include module -Pcap or refer them like Pcap::Capture. - - - -

Exceptions

- - - -
-

- -fukusima@goto.info.waseda.ac.jp
-

- diff --git a/external/ruby-pcapx/examples/httpdump.rb b/external/ruby-pcapx/examples/httpdump.rb deleted file mode 100755 index 57a470f32b..0000000000 --- a/external/ruby-pcapx/examples/httpdump.rb +++ /dev/null @@ -1,26 +0,0 @@ -#!/usr/local/bin/ruby -require 'pcaplet' -httpdump = Pcaplet.new('-s 1500') - -HTTP_REQUEST = Pcap::Filter.new('tcp and dst port 80', httpdump.capture) -HTTP_RESPONSE = Pcap::Filter.new('tcp and src port 80', httpdump.capture) - -httpdump.add_filter(HTTP_REQUEST | HTTP_RESPONSE) -httpdump.each_packet {|pkt| - data = pkt.tcp_data - case pkt - when HTTP_REQUEST - if data and data =~ /^GET\s+(\S+)/ - path = $1 - host = pkt.dst.to_s - host << ":#{pkt.dst_port}" if pkt.dport != 80 - s = "#{pkt.src}:#{pkt.sport} > GET http://#{host}#{path}" - end - when HTTP_RESPONSE - if data and data =~ /^(HTTP\/.*)$/ - status = $1 - s = "#{pkt.dst}:#{pkt.dport} < #{status}" - end - end - puts s if s -} diff --git a/external/ruby-pcapx/examples/tcpdump.rb b/external/ruby-pcapx/examples/tcpdump.rb deleted file mode 100755 index 2644382406..0000000000 --- a/external/ruby-pcapx/examples/tcpdump.rb +++ /dev/null @@ -1,25 +0,0 @@ -#!/usr/local/bin/ruby -require 'pcaplet' -include Pcap - -class Time - # tcpdump style format - def to_s - sprintf "%0.2d:%0.2d:%0.2d.%0.6d", hour, min, sec, tv_usec - end -end - -pcaplet = Pcaplet.new -pcaplet.each_packet { |pkt| - print "#{pkt.time} #{pkt}" - if pkt.tcp? - print " (#{pkt.tcp_data_len})" - print " ack #{pkt.tcp_ack}" if pkt.tcp_ack? - print " win #{pkt.tcp_win}" - end - if pkt.ip? - print " (DF)" if pkt.ip_df? - end - print "\n" -} -pcaplet.close diff --git a/external/ruby-pcapx/examples/test.rb b/external/ruby-pcapx/examples/test.rb deleted file mode 100755 index 4c17967147..0000000000 --- a/external/ruby-pcapx/examples/test.rb +++ /dev/null @@ -1,10 +0,0 @@ -#!/usr/local/bin/ruby -require 'pcap' - -dev = Pcap.lookupdev -cap = Pcap::Capture.open_live(dev) -cap.setfilter("ip") -cap.loop do |pkt| - print pkt, "\n" -end -cap.close diff --git a/external/ruby-pcapx/extconf.rb b/external/ruby-pcapx/extconf.rb deleted file mode 100644 index 786bd973d1..0000000000 --- a/external/ruby-pcapx/extconf.rb +++ /dev/null @@ -1,16 +0,0 @@ -require 'mkmf' - -pcap_dir = with_config("pcap-dir", "/usr/local") -pcap_includedir = with_config("pcap-includedir", pcap_dir + "/include") -pcap_libdir = with_config("pcap-libdir", pcap_dir + "/lib") - -$CFLAGS = "-I#{pcap_includedir}" -$LDFLAGS = "-L#{pcap_libdir}" - -have_library("socket", "socket") -have_library("xnet", "gethostbyname") -have_func("hstrerror") -if have_header("pcap.h") && have_library("pcap", "pcap_open_live") - have_func("pcap_compile_nopcap") - create_makefile("PcapX") -end diff --git a/external/ruby-pcapx/icmp_packet.c b/external/ruby-pcapx/icmp_packet.c deleted file mode 100644 index a99e911757..0000000000 --- a/external/ruby-pcapx/icmp_packet.c +++ /dev/null @@ -1,444 +0,0 @@ -/* - * icmp_packet.c - * - * $Id: icmp_packet.c,v 1.1.1.1 1999/10/27 09:54:38 fukusima Exp $ - * - * Copyright (C) 1999 Masaki Fukushima - */ - -#include "ruby_pcap.h" - -/* rfc1256 */ -#ifndef ICMP_ROUTERADVERT -#define ICMP_ROUTERADVERT 9 -#endif -#ifndef ICMP_ROUTERSOLICIT -#define ICMP_ROUTERSOLICIT 10 -#endif - -/* rfc1393 */ -#ifndef ICMP_TROUTE -#define ICMP_TROUTE 30 -#endif - -/* rfc1788 */ -#ifndef ICMP_DOMAIN -#define ICMP_DOMAIN 37 -#endif -#ifndef ICMP_DOMAINREPLY -#define ICMP_DOMAINREPLY 38 -#endif - -/* rfc1700 */ -#ifndef ICMP_UNREACH_NET_UNKNOWN -#define ICMP_UNREACH_NET_UNKNOWN 6 -#endif -#ifndef ICMP_UNREACH_HOST_UNKNOWN -#define ICMP_UNREACH_HOST_UNKNOWN 7 -#endif -#ifndef ICMP_UNREACH_ISOLATED -#define ICMP_UNREACH_ISOLATED 8 -#endif -#ifndef ICMP_UNREACH_NET_PROHIB -#define ICMP_UNREACH_NET_PROHIB 9 -#endif -#ifndef ICMP_UNREACH_HOST_PROHIB -#define ICMP_UNREACH_HOST_PROHIB 10 -#endif -#ifndef ICMP_UNREACH_TOSNET -#define ICMP_UNREACH_TOSNET 11 -#endif -#ifndef ICMP_UNREACH_TOSHOST -#define ICMP_UNREACH_TOSHOST 12 -#endif - -/* rfc1716 */ -#ifndef ICMP_UNREACH_FILTER_PROHIB -#define ICMP_UNREACH_FILTER_PROHIB 13 -#endif -#ifndef ICMP_UNREACH_HOST_PRECEDENCE -#define ICMP_UNREACH_HOST_PRECEDENCE 14 -#endif -#ifndef ICMP_UNREACH_PRECEDENCE_CUTOFF -#define ICMP_UNREACH_PRECEDENCE_CUTOFF 15 -#endif - -#ifndef ICMP_PARAMPROB_OPTABSENT -#define ICMP_PARAMPROB_OPTABSENT 1 -#endif - -#define ICMP_HDR(pkt) ((struct icmp *)LAYER4_HDR(pkt)) -#define ICMP_DATA(pkt) ((u_char *)LAYER5_HDR(pkt)) -#define ICMP_DATALEN(pkt) \ - (ntohs(IP_HDR(pkt)->ip_len) - (IP_HDR(pkt)->ip_hl * 4 + 8)) -#define ICMP_CAPLEN(pkt) (pkt->hdr.pkthdr.caplen - pkt->hdr.layer4_off) - -VALUE cICMPPacket; - -#define CheckTruncateICMP(pkt, need) \ - CheckTruncate(pkt, pkt->hdr.layer4_off, need, "truncated ICMP") - -struct icmp_type_info { - char *name; - VALUE klass; -}; -static struct icmp_type_info icmp_types[] = { - {/* 0 */ "echo reply" }, - {},{}, - {/* 3 */ "unreachable" }, - {/* 4 */ "source quench" }, - {/* 5 */ "redirect" }, - {},{}, - {/* 8 */ "echo request" }, - {/* 9 */ "router advertisement" }, - {/* 10 */ "router solicitation" }, - {/* 11 */ "time exceeded" }, - {/* 12 */ "parameter problem" }, - {/* 13 */ "time stamp request" }, - {/* 14 */ "time stamp reply" }, - {/* 15 */ "information request" }, - {/* 16 */ "information reply" }, - {/* 17 */ "address mask request" }, - {/* 18 */ "address mask reply" }, - {},{},{},{},{},{},{},{},{},{},{}, - {/* 30 */ "traceroute" }, - {},{},{},{},{},{}, - {/* 37 */ "domain name request" }, - {/* 38 */ "domain name reply" } -#define ICMP_TYPE_MAX 38 -}; - -VALUE -setup_icmp_packet(pkt, tl_len) - struct packet_object *pkt; - int tl_len; -{ - VALUE klass = cICMPPacket; - - if (tl_len >= 1) { - struct icmp *icmp = ICMP_HDR(pkt); - if (icmp->icmp_type <= ICMP_TYPE_MAX - && icmp_types[icmp->icmp_type].klass) { - klass = icmp_types[icmp->icmp_type].klass; - } - } - return klass; -} - - -#define ICMPP_METHOD(func, need, val) \ -static VALUE\ -(func)(self)\ - VALUE self;\ -{\ - struct packet_object *pkt;\ - struct icmp *icmp;\ - GetPacket(self, pkt);\ - CheckTruncateICMP(pkt, (need));\ - icmp = ICMP_HDR(pkt);\ - return (val);\ -} - -/* - * Common methods (icmp_type independent) - */ - -ICMPP_METHOD(icmpp_type, 1, INT2FIX(icmp->icmp_type)) -ICMPP_METHOD(icmpp_code, 2, INT2FIX(icmp->icmp_code)) -ICMPP_METHOD(icmpp_cksum, 4, INT2FIX(ntohs(icmp->icmp_cksum))) -ICMPP_METHOD(icmpp_typestr, 1, - (icmp->icmp_type <= ICMP_TYPE_MAX - &&icmp_types[icmp->icmp_type].name) - ? rb_str_new2(icmp_types[icmp->icmp_type].name) - : rb_obj_as_string(INT2FIX(icmp->icmp_type))) - - -/* - * icmp_type specific methods - */ - -ICMPP_METHOD(icmpp_pptr, 5, INT2FIX(icmp->icmp_pptr)) -ICMPP_METHOD(icmpp_gwaddr, 8, new_ipaddr(&icmp->icmp_gwaddr)) -ICMPP_METHOD(icmpp_id, 6, INT2FIX(ntohs(icmp->icmp_id))) -ICMPP_METHOD(icmpp_seq, 8, INT2FIX(ntohs(icmp->icmp_seq))) -#ifdef WORDS_BIGENDIAN -ICMPP_METHOD(icmpp_seqle, 8, INT2FIX(((0x00ff&icmp->icmp_seq)<<8) + - (icmp->icmp_seq >> 8))) -#else -ICMPP_METHOD(icmpp_seqle, 8, INT2FIX(icmp->icmp_seq)) -#endif - -/* rfc1191 */ -struct mtu_discovery { - u_short unused; - u_short nextmtu; -}; -#define MTUD(icmp) ((struct mtu_discovery *)&icmp->icmp_void) - -static VALUE -icmpp_nextmtu(self) - VALUE self; -{ - struct packet_object *pkt; - struct icmp *icmp; - - GetPacket(self, pkt); - CheckTruncateICMP(pkt, 8); - icmp = ICMP_HDR(pkt); - - if (icmp->icmp_code != ICMP_UNREACH_NEEDFRAG) - rb_raise(rb_eRuntimeError, "not ICMP_UNREACH_NEEDFRAG"); - return INT2FIX(ntohs(MTUD(icmp)->nextmtu)); -} - -/* rfc1256 */ -struct ih_rdiscovery { - u_char num_addrs; - u_char wpa; - u_short lifetime; -}; -#define IHRD(icmp) ((struct ih_rdiscovery *)&icmp->icmp_void) - -struct id_rdiscovery { - struct in_addr ird_addr; - long ird_pref; -}; -#define IDRD(icmp) ((struct id_rdiscovery *)icmp->icmp_data) - -ICMPP_METHOD(icmpp_num_addrs, 5, INT2FIX(IHRD(icmp)->num_addrs)) -ICMPP_METHOD(icmpp_wpa, 6, INT2FIX(IHRD(icmp)->wpa)) -ICMPP_METHOD(icmpp_lifetime, 8, INT2FIX(ntohs(IHRD(icmp)->lifetime))) - -static VALUE -icmpp_radv(self, ind) - VALUE self, ind; -{ - struct packet_object *pkt; - struct icmp *icmp; - int i = NUM2INT(ind); - VALUE ary; - - GetPacket(self, pkt); - CheckTruncateICMP(pkt, 5); - if (i > IHRD(icmp)->num_addrs) - rb_raise(rb_eRuntimeError, "num_addrs = %d, requested radv(%d)", - (int)IHRD(icmp)->num_addrs, i); - - CheckTruncateICMP(pkt, 8 + i*8); - icmp = ICMP_HDR(pkt); - - ary = rb_ary_new(); - rb_ary_push(ary, new_ipaddr(&IDRD(icmp)->ird_addr)); - rb_ary_push(ary, INT2NUM(ntohl(IDRD(icmp)->ird_pref))); - return ary; -} - -#define time_new_msec(t) rb_time_new((t)/1000, (t)%1000 * 1000) -ICMPP_METHOD(icmpp_otime, 12, time_new_msec(ntohl(icmp->icmp_otime))) -ICMPP_METHOD(icmpp_rtime, 16, time_new_msec(ntohl(icmp->icmp_rtime))) -ICMPP_METHOD(icmpp_ttime, 20, time_new_msec(ntohl(icmp->icmp_ttime))) - -static VALUE -icmpp_ip(self) - VALUE self; -{ - struct packet_object *pkt; - struct icmp *icmp; - struct pcap_pkthdr pkthdr; - - GetPacket(self, pkt); - CheckTruncateICMP(pkt, 9); - icmp = ICMP_HDR(pkt); - - pkthdr.caplen = ICMP_CAPLEN(pkt) - 8; - pkthdr.len = 0; - pkthdr.ts.tv_sec = 0; - pkthdr.ts.tv_usec = 0; - return new_packet((char *)&icmp->icmp_ip, &pkthdr, DLT_RAW); -} - -ICMPP_METHOD(icmpp_mask, 12, UINT32_2_NUM(ntohl(icmp->icmp_mask))) -ICMPP_METHOD(icmpp_data, 9, rb_str_new(icmp->icmp_data, ICMP_CAPLEN(pkt)-8)) - -/* rfc1393 */ -struct traceroute { - u_short ohc; - u_short rhc; - u_long lspeed; - u_long lmtu; -}; -#define TROUTE(icmp) ((struct traceroute *)icmp->icmp_data) -ICMPP_METHOD(icmpp_ohc, 10, INT2FIX(ntohs(TROUTE(icmp)->ohc))) -ICMPP_METHOD(icmpp_rhc, 12, INT2FIX(ntohs(TROUTE(icmp)->rhc))) -ICMPP_METHOD(icmpp_lspeed, 16, UINT32_2_NUM(ntohl(TROUTE(icmp)->lspeed))) -ICMPP_METHOD(icmpp_lmtu, 20, UINT32_2_NUM(ntohl(TROUTE(icmp)->lmtu))) - -/* rfc1788 */ -struct domain_reply { - u_long ttl; - char names[1]; -}; -#define DOMAIN(icmp) ((struct domain_reply *)icmp->icmp_data) -ICMPP_METHOD(icmpp_ttl, 12, UINT32_2_NUM(ntohl(DOMAIN(icmp)->ttl))) - -void -Init_icmp_packet(void) -{ - VALUE klass; - - rb_define_const(mPcap, "ICMP_ECHOREPLY", INT2NUM(ICMP_ECHOREPLY)); - rb_define_const(mPcap, "ICMP_UNREACH", INT2NUM(ICMP_UNREACH)); - rb_define_const(mPcap, "ICMP_SOURCEQUENCH",INT2NUM(ICMP_SOURCEQUENCH)); - rb_define_const(mPcap, "ICMP_REDIRECT", INT2NUM(ICMP_REDIRECT)); - rb_define_const(mPcap, "ICMP_ECHO", INT2NUM(ICMP_ECHO)); - rb_define_const(mPcap, "ICMP_TIMXCEED", INT2NUM(ICMP_TIMXCEED)); - rb_define_const(mPcap, "ICMP_PARAMPROB", INT2NUM(ICMP_PARAMPROB)); - rb_define_const(mPcap, "ICMP_TSTAMP", INT2NUM(ICMP_TSTAMP)); - rb_define_const(mPcap, "ICMP_TSTAMPREPLY", INT2NUM(ICMP_TSTAMPREPLY)); - rb_define_const(mPcap, "ICMP_IREQ", INT2NUM(ICMP_IREQ)); - rb_define_const(mPcap, "ICMP_IREQREPLY", INT2NUM(ICMP_IREQREPLY)); - rb_define_const(mPcap, "ICMP_MASKREQ", INT2NUM(ICMP_MASKREQ)); - rb_define_const(mPcap, "ICMP_MASKREPLY", INT2NUM(ICMP_MASKREPLY)); - - /* UNREACH codes */ - rb_define_const(mPcap, "ICMP_UNREACH_NET", INT2NUM(ICMP_UNREACH_NET)); - rb_define_const(mPcap, "ICMP_UNREACH_HOST", INT2NUM(ICMP_UNREACH_HOST)); - rb_define_const(mPcap, "ICMP_UNREACH_PROTOCOL", INT2NUM(ICMP_UNREACH_PROTOCOL)); - rb_define_const(mPcap, "ICMP_UNREACH_PORT", INT2NUM(ICMP_UNREACH_PORT)); - rb_define_const(mPcap, "ICMP_UNREACH_NEEDFRAG", INT2NUM(ICMP_UNREACH_NEEDFRAG)); - rb_define_const(mPcap, "ICMP_UNREACH_SRCFAIL", INT2NUM(ICMP_UNREACH_SRCFAIL)); - rb_define_const(mPcap, "ICMP_UNREACH_NET_UNKNOWN", INT2NUM(ICMP_UNREACH_NET_UNKNOWN)); - rb_define_const(mPcap, "ICMP_UNREACH_HOST_UNKNOWN", INT2NUM(ICMP_UNREACH_HOST_UNKNOWN)); - rb_define_const(mPcap, "ICMP_UNREACH_ISOLATED", INT2NUM(ICMP_UNREACH_ISOLATED)); - rb_define_const(mPcap, "ICMP_UNREACH_NET_PROHIB", INT2NUM(ICMP_UNREACH_NET_PROHIB)); - rb_define_const(mPcap, "ICMP_UNREACH_HOST_PROHIB", INT2NUM(ICMP_UNREACH_HOST_PROHIB)); - rb_define_const(mPcap, "ICMP_UNREACH_TOSNET", INT2NUM(ICMP_UNREACH_TOSNET)); - rb_define_const(mPcap, "ICMP_UNREACH_TOSHOST", INT2NUM(ICMP_UNREACH_TOSHOST)); - rb_define_const(mPcap, "ICMP_UNREACH_FILTER_PROHIB", INT2NUM(ICMP_UNREACH_FILTER_PROHIB)); - rb_define_const(mPcap, "ICMP_UNREACH_HOST_PRECEDENCE", INT2NUM(ICMP_UNREACH_HOST_PRECEDENCE)); - rb_define_const(mPcap, "ICMP_UNREACH_PRECEDENCE_CUTOFF", INT2NUM(ICMP_UNREACH_PRECEDENCE_CUTOFF)); - - /* REDIRECT codes */ - rb_define_const(mPcap, "ICMP_REDIRECT_NET", INT2NUM(ICMP_REDIRECT_NET)); - rb_define_const(mPcap, "ICMP_REDIRECT_HOST", INT2NUM(ICMP_REDIRECT_HOST)); - rb_define_const(mPcap, "ICMP_REDIRECT_TOSNET", INT2NUM(ICMP_REDIRECT_TOSNET)); - rb_define_const(mPcap, "ICMP_REDIRECT_TOSHOST", INT2NUM(ICMP_REDIRECT_TOSHOST)); - - /* TIMEXCEED codes */ - rb_define_const(mPcap, "ICMP_TIMXCEED_INTRANS", INT2NUM(ICMP_TIMXCEED_INTRANS)); - rb_define_const(mPcap, "ICMP_TIMXCEED_REASS", INT2NUM(ICMP_TIMXCEED_REASS)); - - /* PARAMPROB code */ - rb_define_const(mPcap, "ICMP_PARAMPROB_OPTABSENT", INT2NUM(ICMP_PARAMPROB_OPTABSENT)); - - cICMPPacket = rb_define_class_under(mPcap, "ICMPPacket", cIPPacket); - rb_define_method(cICMPPacket, "icmp_type", icmpp_type, 0); - rb_define_method(cICMPPacket, "icmp_typestr", icmpp_typestr, 0); - rb_define_method(cICMPPacket, "icmp_code", icmpp_code, 0); - rb_define_method(cICMPPacket, "icmp_cksum", icmpp_cksum, 0); - - klass = rb_define_class_under(mPcap, "ICMPEchoReply", cICMPPacket); - icmp_types[ICMP_ECHOREPLY].klass = klass; - rb_define_method(klass, "icmp_id", icmpp_id, 0); - rb_define_method(klass, "icmp_seq", icmpp_seq, 0); - rb_define_method(klass, "icmp_seqle", icmpp_seqle, 0); - rb_define_method(klass, "icmp_data", icmpp_data, 0); - - klass = rb_define_class_under(mPcap, "ICMPUnreach", cICMPPacket); - icmp_types[ICMP_UNREACH].klass = klass; - rb_define_method(klass, "icmp_nextmtu", icmpp_nextmtu, 0); - rb_define_method(klass, "icmp_ip", icmpp_ip, 0); - - klass = rb_define_class_under(mPcap, "ICMPSourceQuench", cICMPPacket); - icmp_types[ICMP_SOURCEQUENCH].klass = klass; - rb_define_method(klass, "icmp_ip", icmpp_ip, 0); - - klass = rb_define_class_under(mPcap, "ICMPRedirect", cICMPPacket); - icmp_types[ICMP_REDIRECT].klass = klass; - rb_define_method(klass, "icmp_gwaddr", icmpp_gwaddr, 0); - rb_define_method(klass, "icmp_ip", icmpp_ip, 0); - - klass = rb_define_class_under(mPcap, "ICMPEcho", cICMPPacket); - icmp_types[ICMP_ECHO].klass = klass; - rb_define_method(klass, "icmp_id", icmpp_id, 0); - rb_define_method(klass, "icmp_seq", icmpp_seq, 0); - rb_define_method(klass, "icmp_seqle", icmpp_seqle, 0); - rb_define_method(klass, "icmp_data", icmpp_data, 0); - - klass = rb_define_class_under(mPcap, "ICMPRouterAdvert", cICMPPacket); - icmp_types[ICMP_ROUTERADVERT].klass = klass; - rb_define_method(klass, "icmp_num_addrs", icmpp_num_addrs, 0); - rb_define_method(klass, "icmp_wpa", icmpp_wpa, 0); - rb_define_method(klass, "icmp_lifetime", icmpp_lifetime, 0); - rb_define_method(klass, "icmp_radv", icmpp_radv, 1); - - klass = rb_define_class_under(mPcap, "ICMPRouterSolicit", cICMPPacket); - icmp_types[ICMP_ROUTERSOLICIT].klass = klass; - - klass = rb_define_class_under(mPcap, "ICMPTimxceed", cICMPPacket); - icmp_types[ICMP_TIMXCEED].klass = klass; - rb_define_method(klass, "icmp_ip", icmpp_ip, 0); - - klass = rb_define_class_under(mPcap, "ICMPParamProb", cICMPPacket); - icmp_types[ICMP_PARAMPROB].klass = klass; - rb_define_method(klass, "icmp_pptr", icmpp_pptr, 0); - rb_define_method(klass, "icmp_ip", icmpp_ip, 0); - - klass = rb_define_class_under(mPcap, "ICMPTStamp", cICMPPacket); - icmp_types[ICMP_TSTAMP].klass = klass; - rb_define_method(klass, "icmp_id", icmpp_id, 0); - rb_define_method(klass, "icmp_seq", icmpp_seq, 0); - rb_define_method(klass, "icmp_otime", icmpp_otime, 0); - rb_define_method(klass, "icmp_rtime", icmpp_rtime, 0); - rb_define_method(klass, "icmp_ttime", icmpp_ttime, 0); - - klass = rb_define_class_under(mPcap, "ICMPTStampReply", cICMPPacket); - icmp_types[ICMP_TSTAMPREPLY].klass = klass; - rb_define_method(klass, "icmp_id", icmpp_id, 0); - rb_define_method(klass, "icmp_seq", icmpp_seq, 0); - rb_define_method(klass, "icmp_otime", icmpp_otime, 0); - rb_define_method(klass, "icmp_rtime", icmpp_rtime, 0); - rb_define_method(klass, "icmp_ttime", icmpp_ttime, 0); - - klass = rb_define_class_under(mPcap, "ICMPIReq", cICMPPacket); - icmp_types[ICMP_IREQ].klass = klass; - rb_define_method(klass, "icmp_id", icmpp_id, 0); - rb_define_method(klass, "icmp_seq", icmpp_seq, 0); - - klass = rb_define_class_under(mPcap, "ICMPIReqReply", cICMPPacket); - icmp_types[ICMP_IREQREPLY].klass = klass; - rb_define_method(klass, "icmp_id", icmpp_id, 0); - rb_define_method(klass, "icmp_seq", icmpp_seq, 0); - - klass = rb_define_class_under(mPcap, "ICMPMaskReq", cICMPPacket); - icmp_types[ICMP_MASKREQ].klass = klass; - rb_define_method(klass, "icmp_id", icmpp_id, 0); - rb_define_method(klass, "icmp_seq", icmpp_seq, 0); - /*rb_define_method(klass, "icmp_mask", icmpp_mask, 0);*/ - - klass = rb_define_class_under(mPcap, "ICMPMaskReply", cICMPPacket); - icmp_types[ICMP_MASKREPLY].klass = klass; - rb_define_method(klass, "icmp_id", icmpp_id, 0); - rb_define_method(klass, "icmp_seq", icmpp_seq, 0); - /*rb_define_method(klass, "icmp_mask", icmpp_mask, 0);*/ - - klass = rb_define_class_under(mPcap, "ICMPTRoute", cICMPPacket); - icmp_types[ICMP_TROUTE].klass = klass; - rb_define_method(klass, "icmp_id", icmpp_id, 0); - rb_define_method(klass, "icmp_ohc", icmpp_ohc, 0); - rb_define_method(klass, "icmp_rhc", icmpp_rhc, 0); - rb_define_method(klass, "icmp_lspeed", icmpp_lspeed, 0); - rb_define_method(klass, "icmp_lmtu", icmpp_lmtu, 0); - - klass = rb_define_class_under(mPcap, "ICMPDomain", cICMPPacket); - icmp_types[ICMP_DOMAIN].klass = klass; - rb_define_method(klass, "icmp_id", icmpp_id, 0); - rb_define_method(klass, "icmp_seq", icmpp_seq, 0); - - klass = rb_define_class_under(mPcap, "ICMPDomainReply", cICMPPacket); - icmp_types[ICMP_DOMAINREPLY].klass = klass; - rb_define_method(klass, "icmp_id", icmpp_id, 0); - rb_define_method(klass, "icmp_seq", icmpp_seq, 0); - rb_define_method(klass, "icmp_ttl", icmpp_ttl, 0); - /*rb_define_method(klass, "icmp_names", icmpp_names, 0);*/ -} diff --git a/external/ruby-pcapx/ip_packet.c b/external/ruby-pcapx/ip_packet.c deleted file mode 100644 index 5e96ac5d00..0000000000 --- a/external/ruby-pcapx/ip_packet.c +++ /dev/null @@ -1,342 +0,0 @@ -/* - * ip_packet.c - * - * $Id: ip_packet.c,v 1.1.1.1 1999/10/27 09:54:38 fukusima Exp $ - * - * Copyright (C) 1998, 1999 Masaki Fukushima - */ - -#include "ruby_pcap.h" -#include - -VALUE cIPPacket; -static VALUE cIPAddress; - -#define CheckTruncateIp(pkt, need) \ - CheckTruncate(pkt, pkt->hdr.layer3_off, need, "truncated IP") - -VALUE -setup_ip_packet(pkt, nl_len) - struct packet_object *pkt; - int nl_len; -{ - VALUE class; - - DEBUG_PRINT("setup_ip_packet"); - - if (nl_len > 0 && IP_HDR(pkt)->ip_v != 4) { - return cPacket; - } - - class = cIPPacket; - nl_len = MIN(nl_len, ntohs(IP_HDR(pkt)->ip_len)); - if (nl_len > 20) { - int hl = IP_HDR(pkt)->ip_hl * 4; - int tl_len = nl_len - hl; - if (tl_len > 0) { - pkt->hdr.layer4_off = pkt->hdr.layer3_off + hl; - /* if this is fragment zero, setup upper layer */ - if ((ntohs(IP_HDR(pkt)->ip_off) & IP_OFFMASK) == 0) { - switch (IP_HDR(pkt)->ip_p) { - case IPPROTO_TCP: - class = setup_tcp_packet(pkt, tl_len); - break; - case IPPROTO_UDP: - class = setup_udp_packet(pkt, tl_len); - break; - case IPPROTO_ICMP: - class = setup_icmp_packet(pkt, tl_len); - break; - } - } - } - } - - return class; -} - -#define IPP_METHOD(func, need, val) \ -static VALUE\ -(func)(self)\ - VALUE self;\ -{\ - struct packet_object *pkt;\ - struct ip *ip;\ -\ - DEBUG_PRINT(#func);\ - GetPacket(self, pkt);\ - CheckTruncateIp(pkt, (need));\ - ip = IP_HDR(pkt);\ - return (val);\ -} - -IPP_METHOD(ipp_ver, 1, INT2FIX(ip->ip_v)) -IPP_METHOD(ipp_hlen, 1, INT2FIX(ip->ip_hl)) -IPP_METHOD(ipp_tos, 2, INT2FIX(ip->ip_tos)) -IPP_METHOD(ipp_len, 4, INT2FIX(ntohs(ip->ip_len))) -IPP_METHOD(ipp_id, 6, INT2FIX(ntohs(ip->ip_id))) -IPP_METHOD(ipp_flags, 8, INT2FIX((ntohs(ip->ip_off) & ~IP_OFFMASK) >> 13)) -IPP_METHOD(ipp_df, 8, ntohs(ip->ip_off) & IP_DF ? Qtrue : Qfalse) -IPP_METHOD(ipp_mf, 8, ntohs(ip->ip_off) & IP_MF ? Qtrue : Qfalse) -IPP_METHOD(ipp_off, 8, INT2FIX(ntohs(ip->ip_off) & IP_OFFMASK)) -IPP_METHOD(ipp_ttl, 9, INT2FIX(ip->ip_ttl)) -IPP_METHOD(ipp_proto, 10, INT2FIX(ip->ip_p)) -IPP_METHOD(ipp_sum, 12, INT2FIX(ntohs(ip->ip_sum))) -IPP_METHOD(ipp_src, 16, new_ipaddr(&ip->ip_src)) -IPP_METHOD(ipp_dst, 20, new_ipaddr(&ip->ip_dst)) - -static VALUE -ipp_sumok(self) - VALUE self; -{ - struct packet_object *pkt; - struct ip *ip; - int hlen, i, sum; - unsigned short *ipus; - - GetPacket(self, pkt); - CheckTruncateIp(pkt, 20); - ip = IP_HDR(pkt); - - hlen = ip->ip_hl * 4; - CheckTruncateIp(pkt, hlen); - - ipus = (unsigned short *)ip; - sum = 0; - hlen /= 2; /* 16-bit word */ - for (i = 0; i < hlen; i++) { - sum += ntohs(ipus[i]); - sum = (sum & 0xffff) + (sum >> 16); - } - if (sum == 0xffff) - return Qtrue; - return Qfalse; -} - -static VALUE -ipp_data(self) - VALUE self; -{ - struct packet_object *pkt; - struct ip *ip; - int len, hlen; - - DEBUG_PRINT("ipp_data"); - GetPacket(self, pkt); - CheckTruncateIp(pkt, 20); - ip = IP_HDR(pkt); - - hlen = ip->ip_hl * 4; - len = pkt->hdr.pkthdr.caplen - pkt->hdr.layer3_off - hlen; - return rb_str_new((u_char *)ip + hlen, len); -} - -/* - * IPAddress - */ - -/* IPv4 adress (32bit) is stored by immediate value */ -#if SIZEOF_VOIDP < 4 -# error IPAddress assumes sizeof(void *) >= 4 -#endif - -#define GetIPAddress(obj, addr) {\ - Check_Type(obj, T_DATA);\ - addr = (struct in_addr *)&(DATA_PTR(obj));\ -} - -VALUE -new_ipaddr(addr) - struct in_addr *addr; -{ - VALUE self; - - self = Data_Wrap_Struct(cIPAddress, 0, 0, (void *)addr->s_addr); - return self; -} - -#ifndef INADDR_NONE -# define INADDR_NONE (0xffffffff) -#endif -static VALUE -ipaddr_s_new(self, val) - VALUE self, val; -{ - struct in_addr addr; - struct hostent *hent; - char *hname; - - switch(TYPE(val)) { - case T_STRING: - hname = RSTRING(val)->ptr; - hent = gethostbyname(hname); - if (hent == NULL) { - extern int h_errno; - switch (h_errno) { - case HOST_NOT_FOUND: - rb_raise(ePcapError, "host not found: %s", hname); - break; - default: -#ifdef HAVE_HSTRERROR - rb_raise(ePcapError, (char *)hstrerror(h_errno)); -#else - rb_raise(ePcapError, "host not found: %s", hname); -#endif - } - } - addr = *(struct in_addr *)hent->h_addr; - break; - case T_FIXNUM: - case T_BIGNUM: - addr.s_addr = htonl(NUM2ULONG(val)); - break; - default: - rb_raise(rb_eTypeError, "String or Integer required"); - } - return new_ipaddr(&addr); -} - -static VALUE -ipaddr_to_i(self) - VALUE self; -{ - struct in_addr *addr; - - GetIPAddress(self, addr); - return UINT32_2_NUM(ntohl(addr->s_addr)); -} - -static VALUE -ipaddr_num_s(self) - VALUE self; -{ - struct in_addr *addr; - - GetIPAddress(self, addr); - return rb_str_new2(inet_ntoa(*addr)); -} - -static VALUE -ipaddr_hostname(self) - VALUE self; -{ - struct in_addr *addr; - struct hostent *host; - - GetIPAddress(self, addr); - host = gethostbyaddr((char *)&addr->s_addr, sizeof addr->s_addr, AF_INET); - if (host == NULL) - return ipaddr_num_s(self); - return rb_str_new2(host->h_name); -} - -static VALUE -ipaddr_to_s(self) - VALUE self; -{ - if (RTEST(rbpcap_convert)) - return ipaddr_hostname(self); - else - return ipaddr_num_s(self); -} - -static VALUE -ipaddr_equal(self, other) - VALUE self, other; -{ - struct in_addr *addr1; - struct in_addr *addr2; - - GetIPAddress(self, addr1); - if (rb_class_of(other) == cIPAddress) { - GetIPAddress(other, addr2); - if (addr1->s_addr == addr2->s_addr) - return Qtrue; - } - return Qfalse; -} - -static VALUE -ipaddr_hash(self) - VALUE self; -{ - struct in_addr *addr; - - GetIPAddress(self, addr); - return INT2FIX(ntohl(addr->s_addr)); -} - -static VALUE -ipaddr_dump(self, limit) - VALUE self; - VALUE limit; -{ - struct in_addr *addr; - - GetIPAddress(self, addr); - return rb_str_new((char *)addr, sizeof addr); -} - -static VALUE -ipaddr_s_load(klass, str) - VALUE klass; - VALUE str; -{ - struct in_addr addr; - int i; - - if (RSTRING(str)->len != sizeof addr) { - rb_raise(rb_eArgError, "dump format error (IPAddress)"); - } - for (i = 0; i < sizeof addr; i++) { - ((char *)&addr)[i] = RSTRING(str)->ptr[i]; - } - return new_ipaddr(&addr); -} - -void -Init_ip_packet(void) -{ - DEBUG_PRINT("Init_ip_packet"); - - cIPPacket = rb_define_class_under(mPcap, "IPPacket", cPacket); - - rb_define_method(cIPPacket, "ip_ver", ipp_ver, 0); - rb_define_method(cIPPacket, "ip_hlen", ipp_hlen, 0); - rb_define_method(cIPPacket, "ip_tos", ipp_tos, 0); - rb_define_method(cIPPacket, "ip_len", ipp_len, 0); - rb_define_method(cIPPacket, "ip_id", ipp_id, 0); - rb_define_method(cIPPacket, "ip_flags", ipp_flags, 0); - rb_define_method(cIPPacket, "ip_df?", ipp_df, 0); - rb_define_method(cIPPacket, "ip_mf?", ipp_mf, 0); - rb_define_method(cIPPacket, "ip_off", ipp_off, 0); - rb_define_method(cIPPacket, "ip_ttl", ipp_ttl, 0); - rb_define_method(cIPPacket, "ip_proto", ipp_proto, 0); - rb_define_method(cIPPacket, "ip_sum", ipp_sum, 0); - rb_define_method(cIPPacket, "ip_sumok?", ipp_sumok, 0); - rb_define_method(cIPPacket, "ip_src", ipp_src, 0); - rb_define_method(cIPPacket, "src", ipp_src, 0); - rb_define_method(cIPPacket, "ip_dst", ipp_dst, 0); - rb_define_method(cIPPacket, "dst", ipp_dst, 0); - rb_define_method(cIPPacket, "ip_data", ipp_data, 0); - - cIPAddress = rb_define_class_under(mPcap, "IPAddress", rb_cObject); - rb_define_singleton_method(cIPAddress, "new", ipaddr_s_new, 1); - rb_define_method(cIPAddress, "to_i", ipaddr_to_i, 0); - rb_define_method(cIPAddress, "to_s", ipaddr_to_s, 0); - rb_define_method(cIPAddress, "num_s", ipaddr_num_s, 0); - rb_define_method(cIPAddress, "to_num_s", ipaddr_num_s, 0); /* BWC */ - rb_define_method(cIPAddress, "hostname", ipaddr_hostname, 0); - rb_define_method(cIPAddress, "sym_s", ipaddr_hostname, 0); - rb_define_method(cIPAddress, "==", ipaddr_equal, 1); - rb_define_method(cIPAddress, "===", ipaddr_equal, 1); - rb_define_method(cIPAddress, "eql?", ipaddr_equal, 1); - rb_define_method(cIPAddress, "hash", ipaddr_hash, 0); - - rb_define_method(cIPAddress, "_dump", ipaddr_dump, 1); - rb_define_singleton_method(cIPAddress, "_load", ipaddr_s_load, 1); - - Init_tcp_packet(); - Init_udp_packet(); - Init_icmp_packet(); -} diff --git a/external/ruby-pcapx/lib/pcapletx.rb b/external/ruby-pcapx/lib/pcapletx.rb deleted file mode 100644 index 4e9f0bb11e..0000000000 --- a/external/ruby-pcapx/lib/pcapletx.rb +++ /dev/null @@ -1,113 +0,0 @@ -require 'PcapX' -require 'getopts' - -def pcapletx_usage() - $stderr.print <" - end - end - - class IPPacket - def to_s - "#{ip_src} > #{ip_dst}" - end - end - - class TCPPacket - def tcp_data_len - ip_len - 4 * (ip_hlen + tcp_hlen) - end - - def tcp_flags_s - return \ - (tcp_urg? ? 'U' : '.') + - (tcp_ack? ? 'A' : '.') + - (tcp_psh? ? 'P' : '.') + - (tcp_rst? ? 'R' : '.') + - (tcp_syn? ? 'S' : '.') + - (tcp_fin? ? 'F' : '.') - end - - def to_s - "#{src}:#{sport} > #{dst}:#{dport} #{tcp_flags_s}" - end - end - - class UDPPacket - def to_s - "#{src}:#{sport} > #{dst}:#{dport} len #{udp_len} sum #{udp_sum}" - end - end - - class ICMPPacket - def to_s - "#{src} > #{dst}: icmp: #{icmp_typestr}" - end - end - - # - # Backword compatibility - # - IpPacket = IPPacket - IpAddress = IPAddress - TcpPacket = TCPPacket - UdpPacket = UDPPacket - - # IpAddress is now obsolete. - # New class IPAddress is implemented in C. -=begin - class IpAddress - def initialize(a) - raise AurgumentError unless a.is_a?(Integer) - @addr = a - end - - def to_i - return @addr - end - - def ==(other) - @addr == other.to_i - end - - alias === == - alias eql? == - - def to_num_s - return ((@addr >> 24) & 0xff).to_s + "." + - ((@addr >> 16) & 0xff).to_s + "." + - ((@addr >> 8) & 0xff).to_s + "." + - (@addr & 0xff).to_s; - end - - def hostname - addr = self.to_num_s - # "require 'socket'" is here because of the order of - # ext initialization in static linked binary - require 'socket' - begin - return Socket.gethostbyname(addr)[0] - rescue SocketError - return addr - end - end - - def to_s - if Pcap.convert? - return hostname - else - return to_num_s - end - end - end -=end -end - -class Time - # tcpdump style format - def tcpdump - sprintf "%0.2d:%0.2d:%0.2d.%0.6d", hour, min, sec, tv_usec - end -end - -autoload :PcapletX, 'pcapletx' diff --git a/external/ruby-pcapx/packet.c b/external/ruby-pcapx/packet.c deleted file mode 100644 index 2bd78590ef..0000000000 --- a/external/ruby-pcapx/packet.c +++ /dev/null @@ -1,339 +0,0 @@ -/* - * packet.c - * - * $Id: packet.c,v 1.4 2000/08/13 06:56:15 fukusima Exp $ - * - * Copyright (C) 1998-2000 Masaki Fukushima - */ - -#include "ruby.h" -#include "ruby_pcap.h" -#include -#include -#include - -#define DL_HDR(pkt) ((u_char *)LAYER2_HDR(pkt)) -#define DL_DATA(pkt) ((u_char *)LAYER3_HDR(pkt)) - -VALUE cPacket; -static VALUE mMarshal; -int id_load; -int id_dump; - -/* called from GC */ -static void -free_packet(pkt) - struct packet_object *pkt; -{ - DEBUG_PRINT("free_packet"); - free(pkt); -} - -/* called from GC */ -static void -mark_packet(pkt) - struct packet_object *pkt; -{ - DEBUG_PRINT("mark_packet"); - if (pkt->udata != Qnil) - rb_gc_mark(pkt->udata); -} - -struct datalink_type { - int type; - int nltype_off; /* offset of network-layer type field */ - int nl_off; /* offset of network-layer header */ -}; - - -/* supported datalink types */ -static struct datalink_type datalinks[] = { - { DLT_NULL, -2, 4 }, - { DLT_EN10MB, 12, 14 }, - { DLT_IEEE802, 20, 22 }, - { DLT_SLIP, -2, 16 }, - { DLT_PPP, 2, 4 }, -#ifndef PCAP_FDDIPAD - { DLT_FDDI, 19, 21 }, /* 10: DLT_FDDI */ -#else - { DLT_FDDI, 19 + PCAP_FDDIPAD, 21 + PCAP_FDDIPAD }, -#endif - { DLT_ATM_RFC1483, 6, 8 }, - { DLT_RAW, -2, 0 }, - { DLT_SLIP_BSDOS, -2, 24 }, - { DLT_PPP_BSDOS, -2, 24 }, - { DLT_IEEE802_11, -1, 0 }, - { DLT_IEEE802_11_RADIO, -1, 0 }, /* radiotap is padded to 64 bytes */ - { DLT_IEEE802_11_RADIO_AVS, -1, 0 }, - { DLT_LINUX_SLL, -1, 0 }, - { DLT_PRISM_HEADER, -1, 0 }, - { DLT_AIRONET_HEADER, -1, 0 }, - { 255, 0, 0 } -}; - - -VALUE -new_packet(data, pkthdr, dl_type) - const u_char *data; - const struct pcap_pkthdr *pkthdr; - int dl_type; -{ - VALUE class; - struct packet_object *pkt; - int nl_off, nl_len, nltype_off, nl_type, pad, i; - unsigned short *f; - int t = -1; - - DEBUG_PRINT("new_packet"); - - // This is slow and needs to be rewritten - for (i = 0; datalinks[i].type != 255; i++) { - if (datalinks[i].type == dl_type) { - t = i; - break; - } - } - - /* check nework layer type and offset */ - if (t == -1) - rb_raise(ePcapError, "Unknown data-link type (%d)", dl_type); - - nltype_off = datalinks[t].nltype_off; - nl_off = datalinks[t].nl_off; - - /* parse the DLT header to figure it out */ - if (nltype_off == -1) { - - switch(dl_type) { - case DLT_LINUX_SLL: - default: - if (pkthdr->caplen > 16) { - f = (unsigned short *)(data + 4); - i = ntohs(*f); - if (pkthdr->caplen > i + 16 ) { - nltype_off = i + 14; - nl_off = i + 16; - } - } - break; - } - } - - /* assume this is raw IP */ - if (nltype_off == -2) { - nl_type = ETHERTYPE_IP; - /* assume Ether Type value */ - } else if (nltype_off != -1) { - nl_type = ntohs(*(u_short *)(data + nltype_off)); - } - - - /* alloc memory and setup packet_object */ - pad = nl_off % 4; /* align network layer header */ - pkt = xmalloc(sizeof(*pkt) + pad + pkthdr->caplen); - pkt->hdr.version = PACKET_MARSHAL_VERSION; - pkt->hdr.flags = 0; - pkt->hdr.dl_type = dl_type; - pkt->hdr.layer3_off = OFF_NONEXIST; - pkt->hdr.layer4_off = OFF_NONEXIST; - pkt->hdr.layer5_off = OFF_NONEXIST; - pkt->hdr.pkthdr = *pkthdr; - pkt->data = (u_char *)pkt + sizeof(*pkt) + pad; - pkt->udata = Qnil; - - memcpy(pkt->data, data, pkthdr->caplen); - - nl_len = pkthdr->caplen - nl_off; - if (nl_off >= 0 && nl_len > 0) - pkt->hdr.layer3_off = nl_off; - - /* setup upper layer */ - class = cPacket; - if (pkt->hdr.layer3_off != OFF_NONEXIST) { - switch (nl_type) { - case ETHERTYPE_IP: - class = setup_ip_packet(pkt, nl_len); - break; - } - } -#if DEBUG - if (ruby_debug && TYPE(class) != T_CLASS) { - rb_fatal("not class"); - } -#endif - return Data_Wrap_Struct(class, mark_packet, free_packet, pkt); -} - -static VALUE -packet_load(class, str) - VALUE class; - VALUE str; -{ - struct packet_object *pkt = NULL; - struct packet_object_header *hdr; - int version; - u_char *str_ptr; - - DEBUG_PRINT("packet_load"); - - str_ptr = RSTRING(str)->ptr; - hdr = (struct packet_object_header *)str_ptr; - version = hdr->version; - if (version == PACKET_MARSHAL_VERSION) { - bpf_u_int32 caplen; - u_short layer3_off; - int pad; - - caplen = ntohl(hdr->pkthdr.caplen); - layer3_off = ntohs(hdr->layer3_off); - pad = layer3_off % 4; /* align network layer header */ - pkt = (struct packet_object *)xmalloc(sizeof(*pkt) + pad + caplen); - - pkt->hdr.version = PACKET_MARSHAL_VERSION; - pkt->hdr.flags = hdr->flags; - pkt->hdr.dl_type = hdr->dl_type; - pkt->hdr.layer3_off = ntohs(hdr->layer3_off); - pkt->hdr.layer4_off = ntohs(hdr->layer4_off); - pkt->hdr.layer5_off = ntohs(hdr->layer5_off); - pkt->hdr.pkthdr.ts.tv_sec = ntohl(hdr->pkthdr.ts.tv_sec); - pkt->hdr.pkthdr.ts.tv_usec = ntohl(hdr->pkthdr.ts.tv_usec); - pkt->hdr.pkthdr.caplen = ntohl(hdr->pkthdr.caplen); - pkt->hdr.pkthdr.len = ntohl(hdr->pkthdr.len); - - pkt->data = (u_char *)pkt + sizeof(*pkt) + pad; - memcpy(pkt->data, str_ptr + sizeof(*hdr), caplen); - if (PKTFLAG_TEST(pkt, POH_UDATA)) { - int l = sizeof(*hdr) + caplen; - VALUE ustr = rb_str_substr(str, l, RSTRING(str)->len - l); - pkt->udata = rb_funcall(mMarshal, id_load, 1, ustr); - } else { - pkt->udata = Qnil; - } - PKTFLAG_SET(pkt, POH_UDATA, (pkt->udata != Qnil)); - } else { - rb_raise(rb_eArgError, "unknown packet marshal version(0x%x)", version); - } - - if (pkt != NULL) - return Data_Wrap_Struct(class, mark_packet, free_packet, pkt); - else - return Qnil; -} - -static VALUE -packet_dump(self, limit) - VALUE self; - VALUE limit; -{ - struct packet_object *pkt; - struct packet_object_header hdr; - VALUE str; - - DEBUG_PRINT("packet_dump"); - GetPacket(self, pkt); - - hdr.version = PACKET_MARSHAL_VERSION; - hdr.flags = pkt->hdr.flags; - hdr.dl_type = pkt->hdr.dl_type; - hdr.layer3_off = htons(pkt->hdr.layer3_off); - hdr.layer4_off = htons(pkt->hdr.layer4_off); - hdr.layer5_off = htons(pkt->hdr.layer5_off); - hdr.pkthdr.ts.tv_sec = htonl(pkt->hdr.pkthdr.ts.tv_sec); - hdr.pkthdr.ts.tv_usec = htonl(pkt->hdr.pkthdr.ts.tv_usec); - hdr.pkthdr.caplen = htonl(pkt->hdr.pkthdr.caplen); - hdr.pkthdr.len = htonl(pkt->hdr.pkthdr.len); - - str = rb_str_new((char *)&hdr, sizeof(hdr)); - rb_str_cat(str, pkt->data, pkt->hdr.pkthdr.caplen); - if (pkt->udata != Qnil) { - VALUE ustr; - ustr = rb_funcall(mMarshal, id_dump, 1, pkt->udata); - rb_str_concat(str, ustr); - } - return str; -} - -static VALUE -packet_set_udata(self, val) - VALUE self; - VALUE val; -{ - struct packet_object *pkt; - - DEBUG_PRINT("packet_set_udata"); - GetPacket(self, pkt); - - pkt->udata = val; - PKTFLAG_SET(pkt, POH_UDATA, (val != Qnil)); - return val; -} - -static VALUE -packet_match(self, expr) - VALUE self; - VALUE expr; -{ - if (IsKindOf(expr, cFilter)) { - return filter_match(expr, self); - } - rb_raise(rb_eArgError, "Not Filter"); -} - -#define PACKET_METHOD(func, val) \ -static VALUE\ -(func)(self)\ - VALUE self;\ -{\ - struct packet_object *pkt;\ -\ - DEBUG_PRINT(#func);\ - GetPacket(self, pkt);\ - return (val);\ -} - -PACKET_METHOD(packet_get_udata, pkt->udata); -PACKET_METHOD(packet_datalink, INT2FIX(pkt->hdr.dl_type)); -PACKET_METHOD(packet_ip, rb_obj_is_kind_of(self, cIPPacket)); -PACKET_METHOD(packet_tcp, rb_obj_is_kind_of(self, cTCPPacket)); -PACKET_METHOD(packet_udp, rb_obj_is_kind_of(self, cUDPPacket)); -PACKET_METHOD(packet_length, UINT32_2_NUM(pkt->hdr.pkthdr.len)); -PACKET_METHOD(packet_caplen, UINT32_2_NUM(pkt->hdr.pkthdr.caplen)); -PACKET_METHOD(packet_time, rb_time_new(pkt->hdr.pkthdr.ts.tv_sec, - pkt->hdr.pkthdr.ts.tv_usec)); -PACKET_METHOD(packet_time_i, rb_int2inum(pkt->hdr.pkthdr.ts.tv_sec)); -PACKET_METHOD(packet_raw_data, rb_str_new(pkt->data, pkt->hdr.pkthdr.caplen)); - -void -Init_packet(void) -{ - DEBUG_PRINT("Init_packet"); - - /* define class Packet */ - cPacket = rb_define_class_under(mPcap, "Packet", rb_cObject); - - rb_define_singleton_method(cPacket, "_load", packet_load, 1); - rb_define_method(cPacket, "_dump", packet_dump, 1); - /* marshal backward compatibility */ - rb_define_singleton_method(cPacket, "_load_from", packet_load, 1); - rb_define_method(cPacket, "_dump_to", packet_dump, 1); - - rb_define_method(cPacket, "udata", packet_get_udata, 0); - rb_define_method(cPacket, "udata=", packet_set_udata, 1); - rb_define_method(cPacket, "datalink", packet_datalink, 0); - rb_define_method(cPacket, "ip?", packet_ip, 0); - rb_define_method(cPacket, "tcp?", packet_tcp, 0); - rb_define_method(cPacket, "udp?", packet_udp, 0); - rb_define_method(cPacket, "length", packet_length, 0); - rb_define_method(cPacket, "size", packet_length, 0); - rb_define_method(cPacket, "caplen", packet_caplen, 0); - rb_define_method(cPacket, "time", packet_time, 0); - rb_define_method(cPacket, "time_i", packet_time_i, 0); - rb_define_method(cPacket, "raw_data", packet_raw_data, 0); - rb_define_method(cPacket, "=~", packet_match, 1); - - /* mMarshal in ruby/marshal.c is static. Why? */ - mMarshal = rb_eval_string("Marshal"); - id_load = rb_intern("load"); - id_dump = rb_intern("dump"); - Init_ip_packet(); -} diff --git a/external/ruby-pcapx/ruby_pcap.h b/external/ruby-pcapx/ruby_pcap.h deleted file mode 100644 index 254ee5d9f6..0000000000 --- a/external/ruby-pcapx/ruby_pcap.h +++ /dev/null @@ -1,133 +0,0 @@ -/* - * ruby_pcap.h - * - * $Id: ruby_pcap.h,v 1.4 2000/08/13 06:56:15 fukusima Exp $ - * - * Copyright (C) 1998-2000 Masaki Fukushima - */ - -#ifndef RUBY_PCAP_H -#define RUBY_PCAP_H - -#include "ruby.h" -#include -#include -#include -#include -#include -#include -#ifndef IP_OFFMASK -# define IP_OFFMASK 0x1fff -#endif -#ifdef linux -# define __FAVOR_BSD -#endif -#include -#include -#include -#include -#include - -#ifdef DEBUG -# define DEBUG_PRINT(x) \ - ((RTEST(ruby_debug) && RTEST(ruby_verbose))?\ - (fprintf(stderr, "%s\n", x),fflush(stderr)) : 0) -#else -# define DEBUG_PRINT(x) (0) -#endif - -#define UINT32_2_NUM(i) rb_uint2inum(i) -#ifndef UINT2NUM -# define UINT2NUM(i) rb_uint2inum(i) -#endif -#define MIN(x, y) ((x)<(y) ? (x) : (y)) - - -#define PACKET_MARSHAL_VERSION 1 - -/* ruby config.h defines WORDS_BIGENDIAN if big-endian */ -struct packet_object_header { -#ifdef WORDS_BIGENDIAN - u_char version:4; /* marshal format version */ - u_char flags:4; /* flags */ -#else - u_char flags:4; /* flags */ - u_char version:4; /* marshal format version */ -#endif -#define POH_UDATA 0x01 /* flag: user data exists */ -#define POH_RSVD1 0x02 /* (reserved) */ -#define POH_RSVD2 0x03 /* (reserved) */ -#define POH_RSVD3 0x04 /* (reserved) */ - u_char dl_type; /* data-link type (DLT_*) */ - u_short layer3_off; /* layer 3 header offset */ - u_short layer4_off; /* layer 4 header offset */ - u_short layer5_off; /* layer 5 header offset */ -#define OFF_NONEXIST 0xffff /* offset value for non-existent layer */ - struct pcap_pkthdr pkthdr; /* pcap packet header */ -}; - -struct packet_object { - struct packet_object_header hdr; /* packet object header */ - u_char *data; /* packet data */ - VALUE udata; /* user data */ -}; - -#define PKTFLAG_TEST(pkt, flag) ((pkt)->hdr.flags & (flag)) -#define PKTFLAG_SET(pkt, flag, val) \ - ((val) ? ((pkt)->hdr.flags |= (flag)) : ((pkt)->hdr.flags &= ~(flag))) - -#define LAYER2_HDR(pkt) ((pkt)->data) -#define LAYER3_HDR(pkt) ((pkt)->data + (pkt)->hdr.layer3_off) -#define LAYER4_HDR(pkt) ((pkt)->data + (pkt)->hdr.layer4_off) -#define LAYER5_HDR(pkt) ((pkt)->data + (pkt)->hdr.layer5_off) - -#define GetPacket(obj, pkt) Data_Get_Struct(obj, struct packet_object, pkt) -#define Caplen(pkt, from) ((pkt)->hdr.pkthdr.caplen - (from)) -#define CheckTruncate(pkt, from, need, emsg) (\ - (from) + (need) > (pkt)->hdr.pkthdr.caplen ? \ - rb_raise(eTruncatedPacket, (emsg)) : 0 \ -) - -#define IsKindOf(v, class) RTEST(rb_obj_is_kind_of(v, class)) -#define CheckClass(v, class) ((IsKindOf(v, class)) ? 0 :\ - rb_raise(rb_eTypeError, "wrong type %s (expected %s)",\ - rb_class2name(CLASS_OF(v)), rb_class2name(class))) - - -/* Pcap.c */ -extern VALUE mPcap, rbpcap_convert; -extern VALUE ePcapError; -extern VALUE eTruncatedPacket; -extern VALUE cFilter; -void Init_PcapX(void); -VALUE filter_match(VALUE self, VALUE v_pkt); - -/* packet.c */ -extern VALUE cPacket; -void Init_packet(void); -VALUE new_packet(const u_char *, const struct pcap_pkthdr *, int); - -/* ip_packet.c */ -#define IP_HDR(pkt) ((struct ip *)LAYER3_HDR(pkt)) -#define IP_DATA(pkt) ((u_char *)LAYER4_HDR(pkt)) -extern VALUE cIPPacket; -void Init_ip_packet(void); -VALUE setup_ip_packet(struct packet_object *, int); -VALUE new_ipaddr(struct in_addr *); - -/* tcp_packet.c */ -extern VALUE cTCPPacket; -void Init_tcp_packet(void); -VALUE setup_tcp_packet(struct packet_object *, int); - -/* udp_packet.c */ -extern VALUE cUDPPacket; -void Init_udp_packet(void); -VALUE setup_udp_packet(struct packet_object *, int); - -/* icmp_packet.c */ -extern VALUE cICMPPacket; -void Init_icmp_packet(void); -VALUE setup_icmp_packet(struct packet_object *, int); - -#endif /* RUBY_PCAP_H */ diff --git a/external/ruby-pcapx/tcp_packet.c b/external/ruby-pcapx/tcp_packet.c deleted file mode 100644 index e0bf08f55d..0000000000 --- a/external/ruby-pcapx/tcp_packet.c +++ /dev/null @@ -1,121 +0,0 @@ -/* - * tcp_packet.c - * - * $Id: tcp_packet.c,v 1.1.1.1 1999/10/27 09:54:38 fukusima Exp $ - * - * Copyright (C) 1998, 1999 Masaki Fukushima - */ - -#include "ruby_pcap.h" -#include - -#define TCP_HDR(pkt) ((struct tcphdr *)LAYER4_HDR(pkt)) -#define TCP_DATA(pkt) ((u_char *)LAYER5_HDR(pkt)) -#define TCP_DATALEN(pkt) (ntohs(IP_HDR(pkt)->ip_len) - \ - (IP_HDR(pkt)->ip_hl + TCP_HDR(pkt)->th_off) * 4) - -VALUE cTCPPacket; - -#define CheckTruncateTcp(pkt, need) \ - CheckTruncate(pkt, pkt->hdr.layer4_off, need, "truncated TCP") - -VALUE -setup_tcp_packet(pkt, tl_len) - struct packet_object *pkt; - int tl_len; -{ - VALUE class; - - DEBUG_PRINT("setup_tcp_packet"); - - class = cTCPPacket; - if (tl_len > 20) { - int hl = TCP_HDR(pkt)->th_off * 4; - int layer5_len = tl_len - hl; - if (layer5_len > 0) { - pkt->hdr.layer5_off = pkt->hdr.layer4_off + hl; - /* upper layer */ - } - } - return class; -} - -#define TCPP_METHOD(func, need, val) \ -static VALUE\ -(func)(self)\ - VALUE self;\ -{\ - struct packet_object *pkt;\ - struct tcphdr *tcp;\ - DEBUG_PRINT(#func);\ - GetPacket(self, pkt);\ - CheckTruncateTcp(pkt, (need));\ - tcp = TCP_HDR(pkt);\ - return (val);\ -} - -TCPP_METHOD(tcpp_sport, 2, INT2FIX(ntohs(tcp->th_sport))) -TCPP_METHOD(tcpp_dport, 4, INT2FIX(ntohs(tcp->th_dport))) -TCPP_METHOD(tcpp_seq, 8, UINT32_2_NUM(ntohl(tcp->th_seq))) -TCPP_METHOD(tcpp_acknum, 12, UINT32_2_NUM(ntohl(tcp->th_ack))) -TCPP_METHOD(tcpp_off, 13, INT2FIX(tcp->th_off)) -TCPP_METHOD(tcpp_flags, 14, INT2FIX(tcp->th_flags)) -TCPP_METHOD(tcpp_win, 16, INT2FIX(ntohs(tcp->th_win))) -TCPP_METHOD(tcpp_sum, 18, INT2FIX(ntohs(tcp->th_sum))) -TCPP_METHOD(tcpp_urp, 20, INT2FIX(ntohs(tcp->th_urp))) - -#define TCPP_FLAG(func, flag) \ - TCPP_METHOD(func, 14, (tcp->th_flags & flag) ? Qtrue : Qfalse) -TCPP_FLAG(tcpp_fin, TH_FIN) -TCPP_FLAG(tcpp_syn, TH_SYN) -TCPP_FLAG(tcpp_rst, TH_RST) -TCPP_FLAG(tcpp_psh, TH_PUSH) -TCPP_FLAG(tcpp_ack, TH_ACK) -TCPP_FLAG(tcpp_urg, TH_URG) - -static VALUE -tcpp_data(self) - VALUE self; -{ - struct packet_object *pkt; - VALUE v_len; - int len; - - DEBUG_PRINT("tcpp_data"); - GetPacket(self, pkt); - - if (pkt->hdr.layer5_off == OFF_NONEXIST) return Qnil; - - len = MIN(Caplen(pkt, pkt->hdr.layer5_off), TCP_DATALEN(pkt)); - if (len < 1) return Qnil; - return rb_str_new(TCP_DATA(pkt), len); -} - -void -Init_tcp_packet(void) -{ - DEBUG_PRINT("Init_tcp_packet"); - - /* define class TcpPacket */ - cTCPPacket = rb_define_class_under(mPcap, "TCPPacket", cIPPacket); - - rb_define_method(cTCPPacket, "tcp_sport", tcpp_sport, 0); - rb_define_method(cTCPPacket, "sport", tcpp_sport, 0); - rb_define_method(cTCPPacket, "tcp_dport", tcpp_dport, 0); - rb_define_method(cTCPPacket, "dport", tcpp_dport, 0); - rb_define_method(cTCPPacket, "tcp_seq", tcpp_seq, 0); - rb_define_method(cTCPPacket, "tcp_ack", tcpp_acknum, 0); - rb_define_method(cTCPPacket, "tcp_off", tcpp_off, 0); - rb_define_method(cTCPPacket, "tcp_hlen", tcpp_off, 0); - rb_define_method(cTCPPacket, "tcp_flags", tcpp_flags, 0); - rb_define_method(cTCPPacket, "tcp_win", tcpp_win, 0); - rb_define_method(cTCPPacket, "tcp_sum", tcpp_sum, 0); - rb_define_method(cTCPPacket, "tcp_urp", tcpp_urp, 0); - rb_define_method(cTCPPacket, "tcp_fin?", tcpp_fin, 0); - rb_define_method(cTCPPacket, "tcp_syn?", tcpp_syn, 0); - rb_define_method(cTCPPacket, "tcp_rst?", tcpp_rst, 0); - rb_define_method(cTCPPacket, "tcp_psh?", tcpp_psh, 0); - rb_define_method(cTCPPacket, "tcp_ack?", tcpp_ack, 0); - rb_define_method(cTCPPacket, "tcp_urg?", tcpp_urg, 0); - rb_define_method(cTCPPacket, "tcp_data", tcpp_data, 0); -} diff --git a/external/ruby-pcapx/test.rb b/external/ruby-pcapx/test.rb deleted file mode 100644 index 559a9e174a..0000000000 --- a/external/ruby-pcapx/test.rb +++ /dev/null @@ -1,31 +0,0 @@ -#!/usr/bin/env ruby -$:.unshift(File.dirname(__FILE__)) -$:.unshift(File.join(File.dirname(__FILE__), 'lib')) - -require 'pcapletx' -include PcapX - -class Time - # tcpdump style format - def to_s - sprintf "%0.2d:%0.2d:%0.2d.%0.6d", hour, min, sec, tv_usec - end -end - -pcaplet = PcapletX.new(ARGV.join(' ')) - -pcaplet.each_packet do |pkt| - print "#{pkt.time} #{pkt} #{pkt.datalink} #{pkt.raw_data.index("\xff" * 6)}" - if pkt.tcp? - print " (#{pkt.tcp_data_len})" - print " ack #{pkt.tcp_ack}" if pkt.tcp_ack? - print " win #{pkt.tcp_win}" - end - if pkt.ip? - print " (DF)" if pkt.ip_df? - end - print "\n" -end - - -pcaplet.close diff --git a/external/ruby-pcapx/udp_packet.c b/external/ruby-pcapx/udp_packet.c deleted file mode 100644 index 6ce2a42ac5..0000000000 --- a/external/ruby-pcapx/udp_packet.c +++ /dev/null @@ -1,96 +0,0 @@ -/* - * udp_packet.c - * - * $Id: udp_packet.c,v 1.1.1.1 1999/10/27 09:54:38 fukusima Exp $ - * - * Copyright (C) 1999 Masaki Fukushima - */ - -#include "ruby_pcap.h" -#include - -#define UDP_HDR(pkt) ((struct udphdr *)LAYER4_HDR(pkt)) -#define UDP_DATA(pkt) ((u_char *)LAYER5_HDR(pkt)) -#define UDP_LENGTH(pkt) (ntohs(UDP_HDR(pkt)->uh_ulen)) - -VALUE cUDPPacket; - -#define CheckTruncateUdp(pkt, need) \ - CheckTruncate(pkt, pkt->hdr.layer4_off, need, "truncated UDP") - -VALUE -setup_udp_packet(pkt, tl_len) - struct packet_object *pkt; - int tl_len; -{ - VALUE class; - - DEBUG_PRINT("setup_udp_packet"); - - class = cUDPPacket; - if (tl_len > 8) { - int hl = 8; - int layer5_len; - - tl_len = MIN(tl_len, UDP_LENGTH(pkt)); - layer5_len = tl_len - hl; - if (layer5_len > 0) { - pkt->hdr.layer5_off = pkt->hdr.layer4_off + hl; - /* upper layer */ - } - } - return class; -} - -#define UDPP_METHOD(func, need, val) \ -static VALUE\ -(func)(self)\ - VALUE self;\ -{\ - struct packet_object *pkt;\ - struct udphdr *udp;\ - DEBUG_PRINT(#func);\ - GetPacket(self, pkt);\ - CheckTruncateUdp(pkt, (need));\ - udp = UDP_HDR(pkt);\ - return (val);\ -} - -UDPP_METHOD(udpp_sport, 2, INT2FIX(ntohs(udp->uh_sport))) -UDPP_METHOD(udpp_dport, 4, INT2FIX(ntohs(udp->uh_dport))) -UDPP_METHOD(udpp_len, 6, INT2FIX(ntohs(udp->uh_ulen))) -UDPP_METHOD(udpp_sum, 8, INT2FIX(ntohs(udp->uh_sum))) - -static VALUE -udpp_data(self) - VALUE self; -{ - struct packet_object *pkt; - int len; - - DEBUG_PRINT("udpp_data"); - GetPacket(self, pkt); - CheckTruncateUdp(pkt, 8); - - if (pkt->hdr.layer5_off == OFF_NONEXIST) return Qnil; - - len = MIN(Caplen(pkt, pkt->hdr.layer5_off), UDP_LENGTH(pkt)-8); - return rb_str_new(UDP_DATA(pkt), len); -} - -void -Init_udp_packet(void) -{ - DEBUG_PRINT("Init_udp_packet"); - - /* define class UdpPacket */ - cUDPPacket = rb_define_class_under(mPcap, "UDPPacket", cIPPacket); - - rb_define_method(cUDPPacket, "udp_sport", udpp_sport, 0); - rb_define_method(cUDPPacket, "sport", udpp_sport, 0); - rb_define_method(cUDPPacket, "udp_dport", udpp_dport, 0); - rb_define_method(cUDPPacket, "dport", udpp_dport, 0); - rb_define_method(cUDPPacket, "udp_len", udpp_len, 0); - rb_define_method(cUDPPacket, "udp_sum", udpp_sum, 0); - rb_define_method(cUDPPacket, "udp_data", udpp_data, 0); -} diff --git a/lib/msf/ui/gtk2/app.rb b/lib/msf/ui/gtk2/app.rb index 384e1fad1f..a944525247 100644 --- a/lib/msf/ui/gtk2/app.rb +++ b/lib/msf/ui/gtk2/app.rb @@ -285,6 +285,13 @@ module Ui ad.show end + # + # The Online Help link + # + def on_online_activate + Rex::Compat.open_browser('http://metasploit3.com/msf/support') + end + # # Call the refresh method to reload all module # diff --git a/lib/msf/ui/gtk2/frame/modules_tree.rb b/lib/msf/ui/gtk2/frame/modules_tree.rb index b4ec7844fc..9952f136f3 100644 --- a/lib/msf/ui/gtk2/frame/modules_tree.rb +++ b/lib/msf/ui/gtk2/frame/modules_tree.rb @@ -254,69 +254,83 @@ module Gtk2 # def add_modules(filter=/.*/) + + mod_exploits = {} + mod_auxiliary = {} + + if(not (@module_cache and filter == /.*/)) + + framework.exploits.each_module do |mod, obj| - mod_exploits = {} - framework.exploits.each_module do |mod, obj| - - # SEGV :( - # while (Gtk.events_pending?) - # Gtk.main_iteration - # end - - - parts = mod.split("/") - name = parts.pop - ref = mod_exploits - parts.each do |part| - ref[part] ||= {} - ref = ref[part] + # SEGV :( + # while (Gtk.events_pending?) + # Gtk.main_iteration + # end + + + parts = mod.split("/") + name = parts.pop + ref = mod_exploits + parts.each do |part| + ref[part] ||= {} + ref = ref[part] + end + + ins = obj.new + if ( + mod =~ filter or + ins.name =~ filter or + ins.description.gsub(/\s+/, " ") =~ filter or + ins.author_to_s =~ filter or + ins.references.map {|x| x.to_s}.join(" ") =~ filter + ) + ref[name] = obj.new + end + end + + prune_hash("exploits", mod_exploits) + + framework.auxiliary.each_module do |mod, obj| + + # SEGV :( + # while (Gtk.events_pending?) + # Gtk.main_iteration + # end + + parts = mod.split("/") + name = parts.pop + ref = mod_auxiliary + parts.each do |part| + ref[part] ||= {} + ref = ref[part] + end + + ins = obj.new + if ( + mod =~ filter or + ins.name =~ filter or + ins.description.gsub(/\s+/, " ") =~ filter or + ins.author_to_s =~ filter or + ins.references.map {|x| x.to_s}.join(" ") =~ filter + ) + ref[name] = obj.new + end + end + + prune_hash("auxiliary", mod_auxiliary) + + # Cache the entire tree + if(filter == /.*/) + @module_cache ||= {} + @module_cache[:exploits] = mod_exploits + @module_cache[:auxiliary] = mod_auxiliary end - ins = obj.new - if ( - mod =~ filter or - ins.name =~ filter or - ins.description.gsub(/\s+/, " ") =~ filter or - ins.author_to_s =~ filter or - ins.references.map {|x| x.to_s}.join(" ") =~ filter - ) - ref[name] = obj.new - end + else + mod_exploits = @module_cache[:exploits] + mod_auxiliary = @module_cache[:auxiliary] end - prune_hash("exploits", mod_exploits) - - mod_auxiliary = {} - framework.auxiliary.each_module do |mod, obj| - - # SEGV :( - # while (Gtk.events_pending?) - # Gtk.main_iteration - # end - - parts = mod.split("/") - name = parts.pop - ref = mod_auxiliary - parts.each do |part| - ref[part] ||= {} - ref = ref[part] - end - - ins = obj.new - if ( - mod =~ filter or - ins.name =~ filter or - ins.description.gsub(/\s+/, " ") =~ filter or - ins.author_to_s =~ filter or - ins.references.map {|x| x.to_s}.join(" ") =~ filter - ) - ref[name] = obj.new - end - end - - prune_hash("auxiliary", mod_auxiliary) - - add_modules_to_store( @model, nil, "Exploits", mod_exploits, { diff --git a/lib/msf/ui/gtk2/search.rb b/lib/msf/ui/gtk2/search.rb index 611ab8b3af..05534fd750 100644 --- a/lib/msf/ui/gtk2/search.rb +++ b/lib/msf/ui/gtk2/search.rb @@ -60,30 +60,6 @@ module Msf $gtk2driver.module_tree.refresh(filter) $gtk2driver.module_tree.expand - return - - i_type = Msf::Ui::Gtk2::MyModuleTree::TYPE - i_type_dir = Msf::Ui::Gtk2::MyModuleTree::DIR - i_desc = Msf::Ui::Gtk2::MyModuleTree::DESC - i_name = Msf::Ui::Gtk2::MyModuleTree::NAME - i_mod = Msf::Ui::Gtk2::MyModuleTree::MOD - - $gtk2driver.module_model.each do |model, path, iter| - next if iter[i_type] == i_type_dir - if ( iter[i_desc] =~ filter or iter[i_name] =~ filter) - # Its a keeper - else - found.push(iter) - end - end - - # Colorize the Gtk::Entry - state(RUNNING) - - # pass the found array to the MyModuleTree and remove all not matched iter - # and finish by expanding the treeview - $gtk2driver.module_tree.remove(found) - $gtk2driver.module_tree.expand end