Ethereal-dev: Re: [ethereal-dev] Hello and a patch
Note: This archive is from the project's previous web site, ethereal.com. This list is no longer active.
From: James Coe <jammer@xxxxxxx>
Date: Mon, 06 Dec 1999 20:57:06 -0600
-------- Original Message -------- X-Mozilla-Status: 8011 X-Mozilla-Status2: 00000000 Message-ID: <384C7706.C11C0256@xxxxxxx> Date: Mon, 06 Dec 1999 20:55:03 -0600 From: James Coe <jammer@xxxxxxx> X-Mailer: Mozilla 4.61 [en] (X11; I; Linux 2.2.10 i586) X-Accept-Language: en MIME-Version: 1.0 To: Guy Harris <guy@xxxxxxxxxx> Subject: Re: [ethereal-dev] Hello and a patch References: <199912070256.SAA14429@tooting> Content-Type: multipart/mixed;boundary="------------F2BDC3CDAD20B83CBC34C82E" Guy Harris wrote: > > I am attaching a patch for the latest source tree to this message. The > > patch adds the 0.3 alpha version of my dissector for Service Location > > Protocol (SRVLOC) on port 427. It also modifies the NetWare Core > > Protocol (NCP) dissector to allow it to decode NCP over IP on port 524. > > "packet-srvloc.c" itself doesn't appear to be in the patch. Hmm. I guess the CVS diff didn't pick it up for some reason. I am attaching a patch file for Makefile.in and the source for packet-srvloc to this message. Jamie.
/* packet-srvloc.c * Routines for SRVLOC (Service Location Protocol) packet dissection * Copyright 1999, James Coe <jammer@xxxxxxx> * * NOTE: This is Alpha software not all features have been verified yet. * In particular I have not had an opportunity to see how it * responds to SRVLOC over TCP. * * $Id: packet-srvloc.c,v 0.3 1999/12/05 02:20:27 coe Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@xxxxxxxxxx> * Copyright 1998 Gerald Combs * * 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. */ #ifdef HAVE_CONFIG_H # include "config.h" #endif #include <stdio.h> #include <stdlib.h> #ifdef HAVE_SYS_TYPES_H # include <sys/types.h> #endif #ifdef HAVE_NETINET_IN_H # include <netinet/in.h> #endif #ifdef NEED_SNPRINTF_H # ifdef HAVE_STDARG_H # include <stdarg.h> # else # include <varargs.h> # endif # include "snprintf.h" #endif #include <string.h> #include <glib.h> #include "packet.h" #include "packet-ipv6.h" int proto_srvloc = -1; int hf_srvloc_version = -1; int hf_srvloc_function = -1; int hf_srvloc_flags = -1; int hf_srvloc_error = -1; static gint ett_srvloc = -1; // Define function types #define SRVREQ 1 #define SRVRPLY 2 #define SRVREG 3 #define SRVDEREG 4 #define SRVACK 5 #define ATTRRQST 6 #define ATTRRPLY 7 #define DAADVERT 8 #define SRVTYPERQST 9 #define SRVTYPERPLY 10 // Create protocol header structure struct srvloc_hdr { guint8 version; guint8 function; guint16 length; guint8 flags; guint8 dialect; u_char language[2]; guint16 encoding; guint16 xid; }; // List to resolve function numbers to names static const value_string srvlocfunctionvals[] = { { SRVREQ, "Service Request" }, { SRVRPLY, "Service Reply" }, { SRVREG, "Service Registration" }, { SRVDEREG, "Service Deregister" }, { SRVACK, "Service Acknowledge" }, { ATTRRQST, "Attribute Request" }, { ATTRRPLY, "Attribute Reply" }, { DAADVERT, "DA Advertisement" }, { SRVTYPERQST, "Service Type Request" }, { SRVTYPERPLY, "Service Type Reply" }, }; // List to resolve flag values to names // Define Error Codes #define SUCCESS 0 #define LANG_NOT_SPTD 1 #define PROT_PARSE_ERR 2 #define INVLD_REG 3 #define SCOPE_NOT_SPTD 4 #define CHRSET_NOT_UND 5 #define AUTH_ABSENT 6 #define AUTH_FAILED 7 // List to resolve error codes to names static const value_string srvloc_errs[] = { { SUCCESS, "No Error" }, { LANG_NOT_SPTD, "Language not supported" }, { PROT_PARSE_ERR, "Protocol parse error" }, { INVLD_REG, "Invalid registration" }, { SCOPE_NOT_SPTD, "Scope not supported" }, { CHRSET_NOT_UND, "Character set not understood" }, { AUTH_ABSENT, "Authentication absent" }, { AUTH_FAILED, "Authentication failed" }, }; // Packet dissection routine called by tcp & udp when port 427 detected void dissect_srvloc(const u_char *pd, int offset, frame_data *fd, proto_tree *tree) { proto_item *ti; proto_tree *srvloc_tree; struct srvloc_hdr srvloc_hdr; int count; int length; if (check_col(fd, COL_PROTOCOL)) col_add_str(fd, COL_PROTOCOL, "SRVLOC"); if (check_col(fd, COL_INFO)) col_add_str(fd, COL_INFO, "Service Location Protocol"); if (tree) { ti = proto_tree_add_item(tree, proto_srvloc, offset, END_OF_FRAME, NULL); srvloc_tree = proto_item_add_subtree(ti, ett_srvloc); if ( END_OF_FRAME > sizeof(srvloc_hdr) ) { memcpy( &srvloc_hdr, &pd[offset], sizeof(srvloc_hdr) ); srvloc_hdr.length = ntohs(srvloc_hdr.length); srvloc_hdr.encoding = ntohs(srvloc_hdr.encoding); srvloc_hdr.xid = ntohs(srvloc_hdr.xid); proto_tree_add_item(srvloc_tree, hf_srvloc_version, offset, 1, srvloc_hdr.version); proto_tree_add_item(srvloc_tree, hf_srvloc_function, offset + 1, 1, srvloc_hdr.function); proto_tree_add_text(srvloc_tree, offset + 2, 2, "Length: %d",srvloc_hdr.length); proto_tree_add_item(srvloc_tree, hf_srvloc_flags, offset + 4, 1, srvloc_hdr.flags); proto_tree_add_text(srvloc_tree, offset + 4, 0, "Overflow %d... .xxx", (srvloc_hdr.flags & 0x80) >> 7 ); proto_tree_add_text(srvloc_tree, offset + 4, 0, "Monolingual .%d.. .xxx", (srvloc_hdr.flags & 0x40) >> 6 ); proto_tree_add_text(srvloc_tree, offset + 4, 0, "URL Authentication Present ..%d. .xxx", (srvloc_hdr.flags & 0x20) >> 5 ); proto_tree_add_text(srvloc_tree, offset + 4, 0, "Attribute Authentication Present ...%d .xxx", (srvloc_hdr.flags & 0x10) >> 4 ); proto_tree_add_text(srvloc_tree, offset + 4, 0, "Fresh Service Entry .... %dxxx", (srvloc_hdr.flags & 0x08) >> 3 ); proto_tree_add_text(srvloc_tree, offset + 5, 1, "Dialect: %d",srvloc_hdr.dialect); proto_tree_add_text(srvloc_tree, offset + 6, 2, "Language: %s", format_text(srvloc_hdr.language,2)); proto_tree_add_text(srvloc_tree, offset + 8, 2, "Encoding: %d", srvloc_hdr.encoding); proto_tree_add_text(srvloc_tree, offset + 10, 2, "Transaction ID: %d", srvloc_hdr.xid); offset += 12; } else { proto_tree_add_text(srvloc_tree, offset, END_OF_FRAME, "Invalid Packet: Length less than header."); }; if (( srvloc_hdr.length - 12 ) == END_OF_FRAME ) { switch (srvloc_hdr.function) { case SRVREQ: proto_tree_add_text(srvloc_tree, offset, 0, "Service Request"); length = pntohs(&pd[offset]); proto_tree_add_text(srvloc_tree, offset, 2, "Previous Response List Length: %d", length); offset += 2; proto_tree_add_text(srvloc_tree, offset, length, "Previous Response List: %s", format_text(&pd[offset], length)); offset += length; length = pntohs(&pd[offset]); proto_tree_add_text(srvloc_tree, offset, 2, "Predicate length: %d", length); offset += 2; proto_tree_add_text(srvloc_tree, offset, length, "Predicate: %s", format_text(&pd[offset], length)); offset += length; break; case SRVRPLY: proto_tree_add_text(srvloc_tree, offset, 0, "Service Reply"); proto_tree_add_item(srvloc_tree, hf_srvloc_error, offset, 2, pd[offset]);; offset += 2; proto_tree_add_text(srvloc_tree, offset, 2, "URL Count: %d", pntohs(&pd[offset])); offset += 2; for (count = pntohs(&pd[offset]) + 1; count > 0; count--, offset++) { proto_tree_add_text(srvloc_tree, offset, 2, "URL lifetime: %d", pntohs(&pd[offset])); offset += 2; length = pntohs(&pd[offset]); proto_tree_add_text(srvloc_tree, offset, 2, "URL length: %d", length); offset += 2; proto_tree_add_text(srvloc_tree, offset, length, "Service URL: %s", format_text(&pd[offset], length)); offset += length; }; break; case SRVREG: proto_tree_add_text(srvloc_tree, offset, 0, "Service Registration"); proto_tree_add_text(srvloc_tree, offset, 2, "URL lifetime: %d", pntohs(&pd[offset])); offset += 2; length = pntohs(&pd[offset]); proto_tree_add_text(srvloc_tree, offset, 2, "URL length: %d", length); offset += 2; proto_tree_add_text(srvloc_tree, offset, length, "Service URL: %s", format_text(&pd[offset], length)); offset += length; length = pntohs(&pd[offset]); proto_tree_add_text(srvloc_tree, offset, 2, "Attribute List length: %d", length); offset += 2; proto_tree_add_text(srvloc_tree, offset, length, "Attribute List: %s", format_text(&pd[offset], length)); offset += length; break; case SRVDEREG: proto_tree_add_text(srvloc_tree, offset, 0, "Service Deregister"); length = pntohs(&pd[offset]); proto_tree_add_text(srvloc_tree, offset, 2, "URL length: %d", length); offset += 2; proto_tree_add_text(srvloc_tree, offset, length, "Service URL: %s", format_text(&pd[offset], length)); offset += length; length = pntohs(&pd[offset]); proto_tree_add_text(srvloc_tree, offset, 2, "Attribute List length: %d", length); offset += 2; proto_tree_add_text(srvloc_tree, offset, length, "Attribute List: %s", format_text(&pd[offset], length)); offset += length; break; case SRVACK: proto_tree_add_text(srvloc_tree, offset, 0, "Service Acknowledge"); proto_tree_add_item(srvloc_tree, hf_srvloc_error, offset, 2, pd[offset]);; offset += 2; break; case ATTRRQST: proto_tree_add_text(srvloc_tree, offset, 0, "Attribute Request"); length = pntohs(&pd[offset]); proto_tree_add_text(srvloc_tree, offset, 2, "Previous Response List Length: %d", length); offset += 2; proto_tree_add_text(srvloc_tree, offset, length, "Previous Response List: %s", format_text(&pd[offset], length)); offset += length; length = pntohs(&pd[offset]); proto_tree_add_text(srvloc_tree, offset, 2, "URL length: %d", length); offset += 2; proto_tree_add_text(srvloc_tree, offset, length, "Service URL: %s", format_text(&pd[offset], length)); offset += length; length = pntohs(&pd[offset]); proto_tree_add_text(srvloc_tree, offset, 2, "Scope List Length: %d", length); offset += 2; proto_tree_add_text(srvloc_tree, offset, length, "Scope Response List: %s", format_text(&pd[offset], length)); offset += length; length = pntohs(&pd[offset]); proto_tree_add_text(srvloc_tree, offset, 2, "Attribute List length: %d", length); offset += 2; proto_tree_add_text(srvloc_tree, offset, length, "Attribute List: %s", format_text(&pd[offset], length)); offset += length; break; case ATTRRPLY: proto_tree_add_text(srvloc_tree, offset, 0, "Attribute Reply"); proto_tree_add_item(srvloc_tree, hf_srvloc_error, offset, 2, pd[offset]);; offset += 2; length = pntohs(&pd[offset]); proto_tree_add_text(srvloc_tree, offset, 2, "Attribute List length: %d", length); offset += 2; proto_tree_add_text(srvloc_tree, offset, length, "Attribute List: %s", format_text(&pd[offset], length)); offset += length; break; case DAADVERT: proto_tree_add_text(srvloc_tree, offset, 0, "DA Advertisement"); proto_tree_add_item(srvloc_tree, hf_srvloc_error, offset, 2, pd[offset]);; offset += 2; length = pntohs(&pd[offset]); proto_tree_add_text(srvloc_tree, offset, 2, "URL length: %d", length); offset += 2; proto_tree_add_text(srvloc_tree, offset, length, "Service URL: %s", format_text(&pd[offset], length)); offset += length; length = pntohs(&pd[offset]); proto_tree_add_text(srvloc_tree, offset, 2, "Scope List Length: %d", length); offset += 2; proto_tree_add_text(srvloc_tree, offset, length, "Scope Response List: %s", format_text(&pd[offset], length)); offset += length; break; case SRVTYPERQST: proto_tree_add_text(srvloc_tree, offset, 0, "Service Type Request"); length = pntohs(&pd[offset]); proto_tree_add_text(srvloc_tree, offset, 2, "Previous Response List Length: %d", length); offset += 2; proto_tree_add_text(srvloc_tree, offset, length, "Previous Response List: %s", format_text(&pd[offset], length)); offset += length; length = pntohs(&pd[offset]); proto_tree_add_text(srvloc_tree, offset, 2, "Naming Authority List length: %d", length); offset += 2; proto_tree_add_text(srvloc_tree, offset, length, "Naming Authority List: %s", format_text(&pd[offset], length)); offset += length; length = pntohs(&pd[offset]); proto_tree_add_text(srvloc_tree, offset, 2, "Scope List Length: %d", length); offset += 2; proto_tree_add_text(srvloc_tree, offset, length, "Scope Response List: %s", format_text(&pd[offset], length)); offset += length; break; case SRVTYPERPLY: proto_tree_add_text(srvloc_tree, offset, 0, "Service Type Reply"); proto_tree_add_item(srvloc_tree, hf_srvloc_error, offset, 2, pd[offset]);; offset += 2; proto_tree_add_text(srvloc_tree, offset, 2, "Service Type Count: %d", pntohs(&pd[offset])); offset += 2; for (count = pntohs(&pd[offset]) + 1; count > 0; count--, offset++) { length = pntohs(&pd[offset]); proto_tree_add_text(srvloc_tree, offset, 2, "Service Type List length: %d", length); offset += 2; proto_tree_add_text(srvloc_tree, offset, length, "Service Type List: %s", format_text(&pd[offset], length)); offset += length; }; break; default: proto_tree_add_text(srvloc_tree, offset, END_OF_FRAME, "Unknown Function Type"); }; } else { proto_tree_add_text(srvloc_tree, offset, END_OF_FRAME,"Invalid packet: Bad length value"); }; }; }; // Register protocol with Ethereal. void proto_register_srvloc(void) { static hf_register_info hf[] = { { &hf_srvloc_version, { "Version", "srvloc.version", FT_UINT8, BASE_DEC, NULL, 0x0, "" } }, {&hf_srvloc_function, {"Function", "srvloc.function", FT_UINT8, BASE_DEC, VALS(srvlocfunctionvals), 0x0, ""} }, {&hf_srvloc_flags, {"Flags", "srvloc.flags", FT_UINT8, BASE_HEX, NULL, 0x0, ""} }, {&hf_srvloc_error, {"Error Code", "srvloc.err", FT_UINT8, BASE_DEC, VALS(srvloc_errs), 0x0, ""} }, }; static gint *ett[] = { &ett_srvloc, }; proto_srvloc = proto_register_protocol("Service Location Protocol", "srvloc"); proto_register_field_array(proto_srvloc, hf, array_length(hf)); proto_register_subtree_array(ett, array_length(ett)); };
--- Makefile.in~ Mon Dec 6 17:57:53 1999 +++ Makefile.in Mon Dec 6 19:17:08 1999 @@ -123,7 +123,7 @@ # Any POSIX-compatible YACC should honor the -p flag YFLAGS = -d -p dfilter_ -DISSECTOR_SOURCES = packet-aarp.c packet-afs.c packet-afs.h packet-arp.c packet-arp.h packet-ascend.c packet-atalk.c packet-atalk.h packet-atm.c packet-auto_rp.c packet-bgp.c packet-bgp.h packet-bootp.c packet-bootparams.c packet-bootparams.h packet-bpdu.c packet-cdp.c packet-clip.c packet-data.c packet-dns.c packet-dns.h packet-eth.c packet-fddi.c packet-ftp.c packet-giop.c packet-gre.c packet-hsrp.c packet-http.c packet-icmpv6.c packet-icp.c packet-icq.c packet-imap.c packet-ip.c packet-ip.h packet-ipp.c packet-ipsec.c packet-ipv6.c packet-ipv6.h packet-ipx.c packet-ipx.h packet-irc.c packet-isakmp.c packet-lapb.c packet-lapd.c packet-llc.c packet-lpd.c packet-mapi.c packet-mount.c packet-mount.h packet-nbipx.c packet-nbns.c packet-ncp.c packet-ncp.h packet-netbios.c packet-netbios.h packet-nfs.c packet-nfs.h packet-nlm.c packet-nlm.h packet-nntp.c packet-ntp.c packet-ntp.h packet-null.c packet-osi.c packet-ospf.c packet-ospf.h packet-pim.c packet-pop.c packet-portmap.c packet-portmap.h packet-ppp.c packet-pppoe.c packet-pptp.c packet-q2931.c packet-q931.c packet-q931.h packet-radius.c packet-raw.c packet-rip.c packet-rip.h packet-ripng.c packet-ripng.h packet-rpc.c packet-rpc.h packet-rsvp.c packet-rsvp.h packet-rtsp.c packet-rx.c packet-rx.h packet-sap.c packet-sdp.c packet-smb.c packet-sna.c packet-sna.h packet-snmp.c packet-snmp.h packet-sscop.c packet-stat.c packet-stat.h packet-tacacs.c packet-tcp.c packet-telnet.c packet-tftp.c packet-tns.c packet-tns.h packet-tr.c packet-trmac.c packet-udp.c packet-vines.c packet-vines.h packet-vlan.c packet-vrrp.c packet-x25.c packet-yhoo.c packet-yhoo.h packet-ypbind.c packet-ypbind.h packet-ypserv.c packet-ypserv.h packet-ypxfr.c packet-ypxfr.h +DISSECTOR_SOURCES = packet-aarp.c packet-afs.c packet-afs.h packet-arp.c packet-arp.h packet-ascend.c packet-atalk.c packet-atalk.h packet-atm.c packet-auto_rp.c packet-bgp.c packet-bgp.h packet-bootp.c packet-bootparams.c packet-bootparams.h packet-bpdu.c packet-cdp.c packet-clip.c packet-data.c packet-dns.c packet-dns.h packet-eth.c packet-fddi.c packet-ftp.c packet-giop.c packet-gre.c packet-hsrp.c packet-http.c packet-icmpv6.c packet-icp.c packet-icq.c packet-imap.c packet-ip.c packet-ip.h packet-ipp.c packet-ipsec.c packet-ipv6.c packet-ipv6.h packet-ipx.c packet-ipx.h packet-irc.c packet-isakmp.c packet-lapb.c packet-lapd.c packet-llc.c packet-lpd.c packet-mapi.c packet-mount.c packet-mount.h packet-nbipx.c packet-nbns.c packet-ncp.c packet-ncp.h packet-netbios.c packet-netbios.h packet-nfs.c packet-nfs.h packet-nlm.c packet-nlm.h packet-nntp.c packet-ntp.c packet-ntp.h packet-null.c packet-osi.c packet-ospf.c packet-ospf.h packet-pim.c packet-pop.c packet-portmap.c packet-portmap.h packet-ppp.c packet-pppoe.c packet-pptp.c packet-q2931.c packet-q931.c packet-q931.h packet-radius.c packet-raw.c packet-rip.c packet-rip.h packet-ripng.c packet-ripng.h packet-rpc.c packet-rpc.h packet-rsvp.c packet-rsvp.h packet-rtsp.c packet-rx.c packet-rx.h packet-sap.c packet-sdp.c packet-smb.c packet-sna.c packet-sna.h packet-snmp.c packet-snmp.h packet-srvloc.c packet-sscop.c packet-stat.c packet-stat.h packet-tacacs.c packet-tcp.c packet-telnet.c packet-tftp.c packet-tns.c packet-tns.h packet-tr.c packet-trmac.c packet-udp.c packet-vines.c packet-vines.h packet-vlan.c packet-vrrp.c packet-x25.c packet-yhoo.c packet-yhoo.h packet-ypbind.c packet-ypbind.h packet-ypserv.c packet-ypserv.h packet-ypxfr.c packet-ypxfr.h ethereal_SOURCES = alignment.h asn1.c asn1.h capture.c capture.h colors.c colors.h column.c column.h conversation.c conversation.h dfilter-int.h dfilter-grammar.y dfilter-scanner.l dfilter.c dfilter.h ethertype.c etypes.h file.c file.h follow.c follow.h globals.h inet_v6defs.h ipproto.c ipv4.c ipv4.h packet.c packet.h prefs.c prefs.h print.c print.h proto.c proto.h ps.c ps.h register.c register.h resolv.c resolv.h smb.h summary.c summary.h timestamp.h util.c util.h xdlc.c xdlc.h $(DISSECTOR_SOURCES) @@ -173,7 +173,7 @@ packet-pptp.o packet-q2931.o packet-q931.o packet-radius.o packet-raw.o \ packet-rip.o packet-ripng.o packet-rpc.o packet-rsvp.o packet-rtsp.o \ packet-rx.o packet-sap.o packet-sdp.o packet-smb.o packet-sna.o \ -packet-snmp.o packet-sscop.o packet-stat.o packet-tacacs.o packet-tcp.o \ +packet-snmp.o packet-srvloc.o packet-sscop.o packet-stat.o packet-tacacs.o packet-tcp.o \ packet-telnet.o packet-tftp.o packet-tns.o packet-tr.o packet-trmac.o \ packet-udp.o packet-vines.o packet-vlan.o packet-vrrp.o packet-x25.o \ packet-yhoo.o packet-ypbind.o packet-ypserv.o packet-ypxfr.o @@ -228,7 +228,7 @@ .deps/packet-raw.P .deps/packet-rip.P .deps/packet-ripng.P \ .deps/packet-rpc.P .deps/packet-rsvp.P .deps/packet-rtsp.P \ .deps/packet-rx.P .deps/packet-sap.P .deps/packet-sdp.P \ -.deps/packet-smb.P .deps/packet-sna.P .deps/packet-snmp.P \ +.deps/packet-smb.P .deps/packet-sna.P .deps/packet-snmp.P packet-srvloc.P\ .deps/packet-sscop.P .deps/packet-stat.P .deps/packet-tacacs.P \ .deps/packet-tcp.P .deps/packet-telnet.P .deps/packet-tftp.P \ .deps/packet-tns.P .deps/packet-tr.P .deps/packet-trmac.P \
- Follow-Ups:
- Re: [ethereal-dev] Hello and a patch
- From: Guy Harris
- Re: [ethereal-dev] Hello and a patch
- Prev by Date: Re: [ethereal-dev] Hello and a patch
- Next by Date: Re: [ethereal-dev] Hello and a patch
- Previous by thread: Re: [ethereal-dev] Hello and a patch
- Next by thread: Re: [ethereal-dev] Hello and a patch
- Index(es):