aboutsummaryrefslogtreecommitdiffstats
path: root/packet-ip.c
AgeCommit message (Collapse)AuthorFilesLines
2001-10-01Have a flag in the "packet_info" structure, which indicates whether theGuy Harris1-2/+16
stuff currently being dissected is part of a packet included in an error packet (e.g., an ICMP Unreachable packet). Have the TCP dissector not bother doing reassembly if the TCP segment is part of an error packet, rather than an actual TCP transmission; other dissectors might want to treat those packets specially as well. Add to the "tcpinfo" structure a flag indicating whether the URG flag was set, rather than having the zero or non-zero value of the urgent pointer indicate that. (Yes, at least as I read RFC 793, a zero urgent pointer value isn't useful, as it means "the stuff before this segment is urgent", but it's certainly possible to put onto the wire a TCP segment with URG set and a zero urgent pointer.) Don't dissect the TCP header by grabbing the entire header with "tvb_memcpy()" and then pulling stuff out of it - extract stuff with individual tvbuff calls, and put stuff into the protocol tree and the Info column as we extract it, so that we can dissect a partial header. This lets us, for example, get the source and destination ports from the TCP header of the part of a TCP segment included in a minimum-length ICMPv4 error packet. svn path=/trunk/; revision=3986
2001-09-27When dissecting an ICMP datagram that contains part of an IP datagram,Guy Harris1-5/+57
hand the (possibly-partial) IP datagram to the IP dissector, as we do for IPv6 datagrams inside ICMPv6 and CLNP datagrams inside CLNP ER PDUs. When dissecting IPv6 datagrams inside ICMPv6 and CLNP datagrams inside CLNP ER PDUs, catch the ReportedLengthError exception and ignore it, as they don't guarantee that all of the original PDU is present. svn path=/trunk/; revision=3960
2001-07-20Get rid of some unused variables.Guy Harris1-2/+1
svn path=/trunk/; revision=3744
2001-06-29Create a routine to do the tvbuff-length-adjusting andGuy Harris1-26/+4
"pinfo->{len,captured_len}"-adjusting currently done by the IP dissector, make the IP dissector call that rather than doing the work itself, make the IPv6 dissector call that rather than just adjusting the tvbuff length itself, and make the IPX dissector call that rather than just adjusting "pi.{len,captured_len}" itself. This cleans things up a bit, and causes trailers to be properly reported in IPX-over-Ethernet frames. svn path=/trunk/; revision=3621
2001-06-19More signed vs. unsigned cleanups, and initialization cleanups, fromGuy Harris1-3/+4
Joerg Mayer. svn path=/trunk/; revision=3578
2001-06-18From Joerg Mayer: explicitly fill in all members of aGuy Harris1-37/+37
"header_field_info" structure, including the ones that are later set by the routines to register fields. svn path=/trunk/; revision=3561
2001-06-08Don't display the data portion of an ER NPDU - we dissect it as a CLNPGuy Harris1-2/+2
PDU. svn path=/trunk/; revision=3527
2001-06-08Move the fragment reassembly code into "reassemble.c" andGuy Harris1-323/+22
"reassemble.h", and remove IPv4 dependencies from it. Use it for OSI CLNP segment reassembly as well. svn path=/trunk/; revision=3525
2001-06-05There is no string value assigned to the "ip.fragment.error",Guy Harris1-8/+8
"ip.fragment", and "ip.fragments" fields, so make them FT_NONE, not FT_STRING. (Otherwise, if you try to do a "Match Selected" on them, we dump core because the value is a null pointer and we try to dereference it.) svn path=/trunk/; revision=3512
2001-05-23Add tree summary information similar to what's in packet-tcp.c.Gerald Combs1-3/+17
svn path=/trunk/; revision=3436
2001-05-20Rewritten IGMP dissector, from Ronnie Sahlberg.Guy Harris1-131/+1
svn path=/trunk/; revision=3426
2001-04-18IP fragment reassembly, from Ronnie Sahlberg.Guy Harris1-34/+545
svn path=/trunk/; revision=3324
2001-04-17Move the declaration of "ipprotostr()" out of "epan/packet.h" into a newGuy Harris1-1/+2
"ipproto.h" header file. svn path=/trunk/; revision=3313
2001-03-28Use "proto_tree_add_boolean_hidden()", notGuy Harris1-3/+3
"proto_tree_add_item_hidden()", to add the "checksum bad" flags to packets; the value should be "TRUE", not the numerical value of the checksum field. svn path=/trunk/; revision=3202
2001-03-28If the IP header length is < 20, don't try to dissect the header (otherGuy Harris1-4/+17
than, well, dissecting the header length field), just show the packet has having a bogus IP header length. svn path=/trunk/; revision=3198
2001-03-15Add a new Wiretap encapsulation type for Cisco HDLC. Map the NetBSDGuy Harris1-2/+2
DLT_HDLC to it. Make a separate dissector for Cisco HDLC, and add a dissector for Cisco SLARP. Have the PPP dissector call the Cisco HDLC dissector if the address field is the Cisco HDLC unicast or multicast address. Use the Cisco HDLC dissector for the Cisco HDLC Wiretap encapsulation type. Add a new dissector table "chdlctype", for Cisco HDLC packet types (they're *almost* the same as Ethernet types, but 0x8035 is SLARP, not Reverse ARP, and 0x2000 is the Cisco Discovery protocol, for example), replacing "fr.chdlc". Have a "chdlctype()" routine, similar to "ethertype()", used both by the Cisco HDLC and Frame Relay dissectors. Have a "chdlc_vals[]" "value_string" table for Cisco HDLC types and protocol names. Split the packet type field in the Frame Relay dissector into separate SNAP and Cisco HDLC fields, and give them the Ethernet type and Cisco HDLC type "value_string" tables, respectively. svn path=/trunk/; revision=3133
2001-03-05IP_PROTO_IPV4 and IP_PROTO_IPIP are both 4; there's no need to registerGuy Harris1-2/+1
both of them as dissected by the IP dissector. svn path=/trunk/; revision=3105
2001-02-28Add hidden fields for bad checksums to various IP-family protocols.Guy Harris1-6/+6
Initialize the "hf_" value for "icmp.checksum_bad" to -1, the way all other "hf_" values are initialized, and declare it and "ip.checksum_bad" to have base BASE_NONE, not 4. svn path=/trunk/; revision=3087
2001-02-21Initialize hf_ip_checksum_bad to -1 like all other fields.Gilbert Ramirez1-2/+2
svn path=/trunk/; revision=3064
2001-02-21Change from James E. Flemer to add hidden Boolean fields that are set ifGuy Harris1-1/+14
the IP or ICMP checksum is bad. svn path=/trunk/; revision=3063
2001-01-22Remove more "CHECK_DISPLAY_AS_DATA()" calls and "pinfo->current_proto ="Guy Harris1-15/+3
statements. Move the setting of the Protocol column in various dissectors before anything is fetched from the packet, and also clear the Info column at that point in those and some other dissectors, so that if an exception is thrown, the columns don't reflect the previous protocol. Make the IP dissector static, as it's called only via dissector tables or dissector handles. Also make the "dissect the TOS field as the DiffServ DS field" flag static, as it's not referred to outside of "packet-ip.c". In the NCP dissector, refer to the port type through "pinfo" rather than through the global "pi", as it's a tvbuffified dissector. svn path=/trunk/; revision=2929
2001-01-13Make GRE use a dissector table for its protocol types, and registerGuy Harris1-4/+6
dissectors for protcools that can be encapsulated inside GRE in that table. Fix a bug in the handling of WCCPv2 IP encapsulation (it was constructing the next tvbuff before, rather than after, advancing the offset past the redirection header). svn path=/trunk/; revision=2893
2001-01-10Make the stuff to handle SNAP frames (OUI, PID, payload) a routine ofGuy Harris1-2/+6
its own; it's used not only by LLC, but by Frame Relay with RFC 2427 and ATM with RFC 2684. Support for RFC 2427-encapsulation Frame Relay packets, from Paul Ionescu. Get rid of the CISCO_IP PPP protocol type - Cisco HDLC uses, in most cases, Ethernet packet types, so use ETHERTYPE_IP instead (they're both 0x0800). svn path=/trunk/; revision=2854
2001-01-09Add an additional "protocol index" argument to "{old_}dissector_add()",Guy Harris1-11/+11
"{old_}heur_dissector_add()", "{old_}conv_dissector_add()", and "register_dissector()", so that an entry in those tables has associated with it the protocol index of the protocol the dissector handles (or -1, if there is no protocol index for it). This is for future use in a number of places. (Arguably, "proto_register_protocol()" should take a dissector pointer as an argument, but 1) it'd have to handle both regular and heuristic dissectors; 2) making it take either a "dissector_t" or a union of that and a "heur_dissector_t" introduces some painful header-file interdependencies so I'm punting on that for now. As with other Ethereal internal APIs, these APIs are subject to change in the future, at least until Ethereal 1.0 comes out....) svn path=/trunk/; revision=2849
2001-01-03Ensure that all value_string arrays end in {0, NULL}. Dissectors got awayGilbert Ramirez1-2/+4
with not terminating their arrays because they knew the limits of the value used to look up strings in the value_string array, but the dfilter_expr_dlg does not know these limits and must rely on the terminating {0, NULL} record. Also, in SNA fixed a bug in which a field should have been defined as FT_UINT8 but was defined as FT_BOOLEAN. In WTP, fixed a value string which had duplicate keys. svn path=/trunk/; revision=2817
2001-01-03Add a new "prefs_register_protocol()" routine, which is likeGuy Harris1-2/+2
"prefs_register_module()" except that it takes a protocol index as returned by "proto_register_protocol()" as its first argument, rather than taking two character strings as arguments as its first two arguments, and uses the protocol's abbreviation as the name to use for preferences in the preferences file and the "-o" flag and uses the protocol's short name as the name to use in the tabs in the "Edit->Preferences" window. svn path=/trunk/; revision=2812
2001-01-03Have "proto_register_protocol()" build a list of data structures forGuy Harris1-5/+6
protocols, in addition to adding structures to the list of filterable fields. Give it an extra argument that specifies a "short name" for the protocol, for use in such places as pinfo->current_proto; the dialog box for constructing filters; the preferences tab for the protocol; and so on (although we're not yet using it in all those places). Make the preference name that appears in the preferences file and the command line for the DIAMETER protocol "diameter", not "Diameter"; the convention is that the name in question be all-lower-case. Make some routines and variables that aren't exported static. Update a comment in the ICP dissector to make it clear that the dissector won't see fragments other than the first fragment of a fragmented datagram. svn path=/trunk/; revision=2810
2000-12-29If we get an exception when dissecting a packet, append "[Short Frame]"Guy Harris1-7/+14
or "[Malformed Frame]" to the Info column. Make some dissectors set the Protocol column and clear the Info column before fetching anything from the tvbuff they were handed, so that if the frame is short or malformed, it'll be marked as being the right top-level protocol, and the Info column won't have cruft left over from the previous protocol. svn path=/trunk/; revision=2800
2000-12-14Fix a typo in a comment.Guy Harris1-2/+2
svn path=/trunk/; revision=2758
2000-12-14PPP patches from Burke Lau to:Guy Harris1-1/+2
add FCS checking; support Cisco HDLC format in the PPP dissector; handle MPLS-over-PPP. svn path=/trunk/; revision=2754
2000-12-13Added support for Router-Alert IP option (RFC2113)Ashok Narayanan1-2/+25
svn path=/trunk/; revision=2753
2000-12-13Don't check the checksum of ICMP datagrams that are fragmentedGuy Harris1-5/+4
(unlikely, perhaps even forbidden, but not impossible). svn path=/trunk/; revision=2752
2000-12-13Add code to check the checksums of TCP segments and UDP datagrams;Guy Harris1-45/+17
replace the existing checksummer with a modified version of the BSD checksumming code. Add a flag to the "packet_info" structure to indicate that a packet is the first fragment of a fragmented datagram, so that the checksummers won't try to checksum those. (It doesn't seem to add a lot of CPU overhead, so we don't introduce a flag to disable it, yet. Further checks may be necessary to see whether the overhead is just swamped by other overheads when scanning through a capture dissecting all frames, or if it truly is negligible.) Make the Boolean preference option controlling whether to make the top-level protocol tree item for TCP display a packet summary static to the TCP dissector (it doesn't need to be accessible outside the TCP dissector). svn path=/trunk/; revision=2751
2000-12-08When printing an address mask in hex, zero-pad it, don't blank-pad it.Guy Harris1-2/+2
svn path=/trunk/; revision=2747
2000-12-04Add a "col_clear()" routine, to clear a column; it appears (and itGuy Harris1-9/+9
doesn't just seem to be a profiling artifact) that, at least on FreeBSD 3.4, it's significantly more efficient to clear out a column by stuffing a '\0' into the first byte of the column data than to do so by copying a null string (I guess when copying one byte, the fixed overhead of the procedure call and of "strcpy()" is significant). Have the TCP dissector set the Protocol column, and clear the Info column, before doing anything that might cause an exception to be thrown, so that if we *do* get an exception thrown, the frame at least shows up as TCP. Instead of, in the TCP dissector, constructing a string and then stuffing it into the Info column, just append to the Info column, which avoids one string copy. Pass a "frame_data" pointer to dissectors for TCP and IP (and PPP) options, so they can use it to append to the Info column. svn path=/trunk/; revision=2744
2000-11-19For each column, have both a buffer into which strings for that columnGuy Harris1-5/+5
can be put, and a pointer to the string for the column, which might or might not point to that buffer. Add a routine "col_set_str()", which sets the string for the column to the string passed to it as an argument; it should only be handed a static string (a string constant would be ideal). It doesn't do any copying, so it's faster than "col_add_str()". Make the routines that append to columns check whether the pointer to the string for the column points to the buffer for the column and, if not, copy the string for the column to the buffer for the column so that you can append to it (so you can use "col_set_str()" and then use "col_append_str()" or "col_append_fstr()"). Convert a bunch of "col_add_str()" calls that take a string constant as an argument to "col_set_str()" calls. Convert some "col_add_fstr()" calls that take a string constant as the only argument - i.e., the format string doesn't have any "%" slots into which to put strings for subsequent arguments to "col_set_str()" calls (those calls are just like "col_add_str()" calls). Replace an END_OF_FRAME reference in a tvbuffified dissector with a "tvb_length(tvb)" call. svn path=/trunk/; revision=2670
2000-11-18Tvbuffify the IP, ICMP, TCP, UDP, OSI CLNP, OSI COTP, OSI CLTP, and OSIGuy Harris1-228/+229
ESIS dissectors. Register the IP dissector and have dissectors that call it directly (rather than through a port table) call it through a handle. Add a routine "tvb_set_reported_length()" which a dissector can use if it was handed a tvbuff that contains more data than is actually in its part of the packet - for example, handing a padded Ethernet frame to IP; the routine sets the reported length of the tvbuff (and also adjusts the actual length, as appropriate). Then use it in IP. Given that, "ethertype()" can determine how much of the Ethernet frame was actually part of an IP datagram (and can do the same for other protocols under Ethernet that use "tvb_set_reported_length()"; have it return the actual length, and have "dissect_eth()" and "dissect_vlan()" use that to mark trailer data in Ethernet II frames as well as in 802.3 frames. svn path=/trunk/; revision=2658
2000-11-17Give the "null" link-layer header dissector a dissector table, and putGuy Harris1-1/+3
the BSD AF_ type values it uses into an "aftypes.h" header file for dissectors that register themselves in that dissector table include. svn path=/trunk/; revision=2653
2000-10-21Check ICMP checksum. XXX - won't work if the ICMP packet is inside aGuy Harris1-4/+26
fragmented IP datagram, although that's probably extremely unlikely. svn path=/trunk/; revision=2522
2000-09-16Apply the patch for ECN in the IP header fromRichard Sharpe1-9/+19
Ulrich Kiermayr <kie@thp.univie.ac.at> svn path=/trunk/; revision=2441
2000-08-13Add the "Edit:Protocols..." feature which currently only implementsLaurent Deniel1-1/+7
the following: It is now possible to enable/disable a particular protocol decoding (i.e. the protocol dissector is void or not). When a protocol is disabled, it is displayed as Data and of course, all linked sub-protocols are disabled as well. Disabling a protocol could be interesting: - in case of buggy dissectors - in case of wrong heuristics - for performance reasons - to decode the data as another protocol (TODO) Currently (if I am not wrong), all dissectors but NFS can be disabled (and dissectors that do not register protocols :-) I do not like the way the RPC sub-dissectors are disabled (in the sub-dissectors) since this could be done in the RPC dissector itself, knowing the sub-protocol hfinfo entry (this is why, I've not modified the NFS one yet). Two functions are added in proto.c : gboolean proto_is_protocol_enabled(int n); void proto_set_decoding(int n, gboolean enabled); and two MACROs which can be used in dissectors: OLD_CHECK_DISPLAY_AS_DATA(index, pd, offset, fd, tree) CHECK_DISPLAY_AS_DATA(index, tvb, pinfo, tree) See also the XXX in proto_dlg.c and proto.c around the new functions. svn path=/trunk/; revision=2267
2000-08-11Miscellaneous code cleaningLaurent Deniel1-9/+4
- add <stdarg.h> or <varargs.h> in snprintf.h and remove those inclusions in the other #ifdef NEED_SNPRINTF_H codes - remove the check of multiple inclusions in source (.c) code (there is a bit loss of _cpp_ performance, but I prefer the gain of code reading and maintenance; and nowadays, disk caches and VM are correctly optimized ;-). - protect all (well almost) header files against multiple inclusions - add header (i.e. GPL license) in some include files - reorganize a bit the way header files are included: First: #include <system_include_files> #include <external_package_include_files (e.g. gtk, glib etc.)> Then #include "ethereal_include_files" with the correct HAVE_XXX or NEED_XXX protections. - add some HAVE_XXX checks before including some system header files - add the same HAVE_XXX in wiretap as in ethereal Please forgive me, if I break something (I've only compiled and regression tested on Linux). svn path=/trunk/; revision=2254
2000-08-07Allow either old-style (pre-tvbuff) or new-style (tvbuffified)Guy Harris1-22/+15
dissectors to be registered as dissectors for particular ports, registered as heuristic dissectors, and registered as dissectors for conversations, and have routines to be used both by old-style and new-style dissectors to call registered dissectors. Have the code that calls those dissectors translate the arguments as necessary. (For conversation dissectors, replace "find_conversation_dissector()", which just returns a pointer to the dissector, with "old_try_conversation_dissector()" and "try_conversation_dissector()", which actually call the dissector, so that there's a single place at which we can do that translation. Also make "dissector_lookup()" static and, instead of calling it and, if it returns a non-null pointer, calling that dissector, just use "old_dissector_try_port()" or "dissector_try_port()", for the same reason.) This allows some dissectors that took old-style arguments and immediately translated them to new-style arguments to just take new-style arguments; make them do so. It also allows some new-style dissectors not to have to translate arguments before calling routines to look up and call dissectors; make them not do so. Get rid of checks for too-short frames in new-style dissectors - the tvbuff code does those checks for you. Give the routines to register old-style dissectors, and to call dissectors from old-style dissectors, names beginning with "old_", with the routines for new-style dissectors not having the "old_". Update the dissectors that use those routines appropriately. Rename "dissect_data()" to "old_dissect_data()", and "dissect_data_tvb()" to "dissect_data()". svn path=/trunk/; revision=2218
2000-08-05Make the ICMP top-of-protocol-tree item cover the entire rest of theGuy Harris1-2/+2
packet, not just the first 4 bytes of the ICMP packet. svn path=/trunk/; revision=2211
2000-08-05Make "ip_checksum()" take just pointer and length arguments, and makeGuy Harris1-31/+37
"ip_checksum_shouldbe()" compute the correct checksum given the computed whole-packet checksum and the value of the checksum field; that scheme can be better extended in the future to handle checksums other than the IP header checksum, e.g. ICMP, UDP, and TCP checksums (although we'd want a somewhat more optimized checksumming routine for that, and perhaps have an option to control whether to do checksum checking on TCP and UDP packets, as that could be expensive). That requires that we remember the value of the computed checksum, not just check it against 0; that renders "ip_checksum_state()" uninteresting, as we can just compare the value against 0 in line. svn path=/trunk/; revision=2210
2000-08-04Clean up the checksumming stuff a bit:Guy Harris1-27/+29
have "ip_checksum()" compute the checksum of the IP header; have "ip_checksum_state()" call "ip_checksum()" and then return TRUE if the result is 0 and FALSE otherwise; have "ip_checksum_shouldbe()" save the current value of the checksum field in the header, set that field to 0, call "ip_checksum()" to get the checksum, restore the value of the checksum field in the header to the saved value, and then return what "ip_checksum()" returned; rather than having duplicated code to compute checksums. svn path=/trunk/; revision=2206
2000-08-04If IP checksum is incorrect, show what correct value should be.Gilbert Ramirez1-9/+37
From "Johannes Hennecke" <Johannes.Hennecke@elsa.de> svn path=/trunk/; revision=2202
2000-07-05Add support for a global "ethereal.conf" preferences file, stored in theGuy Harris1-1/+10
same directory as the "manuf" file ("/etc" or "/usr/local/etc", most likely). Add a mechanism to allow modules (e.g., dissectors) to register preference values, which: can be put into the global or the user's preference file; can be set from the command line, with arguments to the "-o" flag; can be set from tabs in the "Preferences" dialog box. Use that mechanism to register the "Decode IPv4 TOS field as DiffServ field" variable for IP as a preference. Stuff that still needs to be done: documenting the API for registering preferences; documenting the "-o" values in the man page (probably needs a flag similar to "-G", and a Perl script to turn the output into documentation as is done with the list of field); handling error checking for numeric values (range checking, making sure that if the user changes the variable from the GUI they change it to a valid numeric value); using the callbacks to, for example, update the display when preferences are changed (could be expensive); panic if the user specifies a numeric value with a base other than 10, 8, or 16. We may also want to clean up the existing wired-in preferences not to take effect the instant you tweak the widget, and to add an "Apply" button to the "Preferences" dialog. svn path=/trunk/; revision=2117
2000-06-20tvbuffify the IGMP dissector. There's still plenty more to do insideGilbert Ramirez1-32/+33
packet-ip.c. svn path=/trunk/; revision=2082
2000-06-13tos_str is no longer used. it was superseded by iptos_vals.Jun-ichiro itojun Hagino1-27/+1
svn path=/trunk/; revision=2064