Ethereal-dev: [ethereal-dev] Update for packet-v120.c
Note: This archive is from the project's previous web site, ethereal.com. This list is no longer active.
From: Bert Driehuis <driehuis@xxxxxxxxxxxxx>
Date: Tue, 14 Dec 1999 01:49:26 +0100 (CET)
I never expected my first cut to hit the tree in 24 hours after posting! You guys are *fast*! By the way, writing the thing wasn't half as heard as I thought. A tribute to the design principle that any decent programmer should be able to pick it up! The attached diff implements unpacking the H octet(s). I also took the opportunity to fix my brain fart in the byte order of the address field; since the bits are interpreted from right to left the bytes should follow that order as well. The diff is relative to current CVS. To answer some older questions, remarks and concerns: - 555-1212, in my recollection, is indeed the directory assistence number that at least some carriers use in the US. In its original place of course was the access number of my company's Portmaster 3. I rarely send packet traces to public forums without taking access numbers (I also try to think of passwords :-) Incidentally, I think an ancient convenant between the motion picture industry and the phone company (yes, that old) dictates that all number used in motion pictures are of the form 555-xxxx. - My query about Q.931 actually presumed the differences I saw between Ethereal and i4btrace stemmed from differences between implementations. Given the history lesson Guy gave, it is quite possible that the stuff I saw just points to unimplemented bits. When I get really bored I'll try to implement as much as possible from EuroISDN in packet-q931.c as possible without clashing with national ISDN. I cannot a priori preclude the possibility that they use the same Q.931! - Some of my mail clients send an "Accept-Language: tr" header just because a long time ago I got fed up with web sites second guessing my language from my domain name, and the language setting from the browser seems to creep into the mail client. - Yes, V.120 for isdn4bsd is coming along nicely now. I just had an entire session using it, and my machine didn't crash until I tried to reconnect without an intervening reboot! This makes my driver as good as the Windows drivers I've seen so far. 'nuf rambling. Cheers, -- Bert Bert Driehuis, MIS -- bert_driehuis@xxxxxxxxxxxxxxxx -- +31-20-3116119 Hi! I'm a signature virus! Copy me to your .signature and help me spread!
*** packet-v120.c Mon Dec 13 00:08:20 1999 --- /work/bertd/build/gnome/ethereal-0.7.9/packet-v120.c Tue Dec 14 01:17:51 1999 *************** *** 3,7 **** * Bert Driehuis <driehuis@xxxxxxxxxxxxx> * ! * $Id: packet-v120.c,v 1.2 1999/12/12 23:08:20 guy Exp $ * * Ethereal - Network traffic analyzer --- 3,7 ---- * Bert Driehuis <driehuis@xxxxxxxxxxxxx> * ! * $Id: $ * * Ethereal - Network traffic analyzer *************** *** 44,51 **** --- 44,55 ---- static int hf_v120_address = -1; static int hf_v120_control = -1; + static int hf_v120_header = -1; static gint ett_v120 = -1; static gint ett_v120_address = -1; static gint ett_v120_control = -1; + static gint ett_v120_header = -1; + + void dissect_v120_header(const u_char *pd, int offset, frame_data *fd, proto_tree *tree); void *************** *** 100,104 **** "V.120"); v120_tree = proto_item_add_subtree(ti, ett_v120); ! addr = pd[0] << 8 | pd[1]; sprintf(info, "LLI: %d C/R: %s", ((pd[0] & 0xfc) << 5) | ((pd[1] & 0xfe) >> 1), --- 104,108 ---- "V.120"); v120_tree = proto_item_add_subtree(ti, ett_v120); ! addr = pd[1] << 8 | pd[0]; sprintf(info, "LLI: %d C/R: %s", ((pd[0] & 0xfc) << 5) | ((pd[1] & 0xfe) >> 1), *************** *** 106,135 **** tc = proto_tree_add_item_format(v120_tree, ett_v120_address, 0, 2, ! "Address field: %s (0x%02X)", info, addr); address_tree = proto_item_add_subtree(tc, ett_v120_address); proto_tree_add_text(address_tree, 0, 2, ! decode_boolean_bitfield(addr, 0x0200, 2*8, "Response", "Command"), NULL); sprintf(info, "LLI: %d", ((pd[0] & 0xfc) << 5) | ((pd[1] & 0xfe) >> 1)); proto_tree_add_text(address_tree, 0, 2, ! decode_numeric_bitfield(addr, 0xfcfe, 2*8, info)); proto_tree_add_text(address_tree, 0, 2, ! decode_boolean_bitfield(addr, 0x0100, 2*8, "EA0 = 1 (Error)", "EA0 = 0"), NULL); proto_tree_add_text(address_tree, 0, 2, ! decode_boolean_bitfield(addr, 0x01, 2*8, "EA1 = 1", "EA1 = 0 (Error)"), NULL); ! /* TODO: parse octets 4 & 5. Not that they're used in ! practice, but it looks so professional. */ } else ! v120_tree = NULL; dissect_xdlc_control(pd, 2, fd, v120_tree, hf_v120_control, ett_v120_control, is_response, v120len == 3 ? FALSE : TRUE); - - /* not end of frame ==> X.25 */ } void proto_register_v120(void) { --- 110,189 ---- tc = proto_tree_add_item_format(v120_tree, ett_v120_address, 0, 2, ! "Address field: %s", info); address_tree = proto_item_add_subtree(tc, ett_v120_address); proto_tree_add_text(address_tree, 0, 2, ! decode_boolean_bitfield(addr, 0x0002, 2*8, "Response", "Command"), NULL); sprintf(info, "LLI: %d", ((pd[0] & 0xfc) << 5) | ((pd[1] & 0xfe) >> 1)); proto_tree_add_text(address_tree, 0, 2, ! decode_numeric_bitfield(addr, 0xfefc, 2*8, info)); proto_tree_add_text(address_tree, 0, 2, ! decode_boolean_bitfield(addr, 0x0001, 2*8, "EA0 = 1 (Error)", "EA0 = 0"), NULL); proto_tree_add_text(address_tree, 0, 2, ! decode_boolean_bitfield(addr, 0x0100, 2*8, "EA1 = 1", "EA1 = 0 (Error)"), NULL); ! if (v120len == 5) ! dissect_v120_header(pd, 4, fd, v120_tree); } else ! v120_tree = NULL; dissect_xdlc_control(pd, 2, fd, v120_tree, hf_v120_control, ett_v120_control, is_response, v120len == 3 ? FALSE : TRUE); } void + dissect_v120_header(const u_char *pd, int offset, frame_data *fd, proto_tree *tree) + { + char info[80]; + int header_len, nbits; + int header; + proto_tree *h_tree, *tc; + + if (pd[offset] & 0x80) { + header_len = 1; + header = pd[offset]; + } else { + header_len = 2; + header = pd[offset] | pd[offset + 1] << 8; + } + nbits = header_len * 8; + sprintf(info, "Header: B: %d F: %d", pd[offset] & 0x02 ? 1:0, + pd[offset] & 0x01 ? 1:0); + tc = proto_tree_add_item_format(tree, ett_v120_header, + offset, header_len, + "Header octet: %s (0x%02X)", info, pd[offset]); + h_tree = proto_item_add_subtree(tc, ett_v120_header); + proto_tree_add_text(h_tree, offset, header_len, + decode_boolean_bitfield(header, 0x80, nbits, + "No extension octet", "Extension octet follows"), NULL); + proto_tree_add_text(h_tree, offset, header_len, + decode_boolean_bitfield(header, 0x40, nbits, + "Break condition", "No break condition"), NULL); + sprintf(info, "Error control C1/C2: %d", (header & 0x0c) >> 2); + proto_tree_add_text(h_tree, offset, header_len, + decode_numeric_bitfield(header, 0x0c, nbits, info)); + proto_tree_add_text(h_tree, offset, header_len, + decode_boolean_bitfield(header, 0x02, nbits, + "Segmentation bit B", "No segmentation bit B"), NULL); + proto_tree_add_text(h_tree, offset, header_len, + decode_boolean_bitfield(header, 0x01, nbits, + "Segmentation bit F", "No segmentation bit F"), NULL); + if (header_len == 2) { + proto_tree_add_text(h_tree, offset, header_len, + decode_boolean_bitfield(header, 0x8000, nbits, + "E", "E bit not set (Error)"), NULL); + proto_tree_add_text(h_tree, offset, header_len, + decode_boolean_bitfield(header, 0x4000, nbits, + "DR", "No DR"), NULL); + proto_tree_add_text(h_tree, offset, header_len, + decode_boolean_bitfield(header, 0x2000, nbits, + "SR", "No SR"), NULL); + proto_tree_add_text(h_tree, offset, header_len, + decode_boolean_bitfield(header, 0x1000, nbits, + "RR", "No RR"), NULL); + } + } + void proto_register_v120(void) { *************** *** 141,144 **** --- 195,201 ---- { "Control Field", "v120.control", FT_STRING, BASE_NONE, NULL, 0x0, "" }}, + { &hf_v120_header, + { "Header Field", "v120.header", FT_STRING, BASE_NONE, NULL, 0x0, + "" }}, }; static gint *ett[] = { *************** *** 146,149 **** --- 203,207 ---- &ett_v120_address, &ett_v120_control, + &ett_v120_header, };
- Follow-Ups:
- Re: [ethereal-dev] Update for packet-v120.c
- From: Guy Harris
- Re: [ethereal-dev] Update for packet-v120.c
- Prev by Date: Re: [ethereal-dev] GTK Segfault!
- Next by Date: [ethereal-dev] feature request for wiretap/ethereal
- Previous by thread: [ethereal-dev] http://netgroup-serv.polito.it/windump/
- Next by thread: Re: [ethereal-dev] Update for packet-v120.c
- Index(es):