2 * Routines for NetWare Core Protocol
3 * Gilbert Ramirez <gram@verdict.uthscsa.edu>
5 * $Id: packet-ncp.c,v 1.2 1998/09/27 22:12:33 gerald Exp $
7 * Ethereal - Network traffic analyzer
8 * By Gerald Combs <gerald@unicom.net>
9 * Copyright 1998 Gerald Combs
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
36 #ifdef HAVE_SYS_TYPES_H
37 # include <sys/types.h>
40 #ifdef HAVE_NETINET_IN_H
41 # include <netinet/in.h>
47 /* The information in this module comes from:
48 NetWare LAN Analysis, Second Edition
49 Laura A. Chappell and Dan E. Hakes
51 Novell Press, San Jose.
54 And from the ncpfs source code by Volker Lendecke
64 /* ================================================================= */
66 /* ================================================================= */
68 req_text(u_short req) {
71 static struct req_info reqs[] = {
72 { 0x1111, "Create a service connection" },
73 { 0x2222, "Service request" },
74 { 0x3333, "Service reply" },
75 { 0x5555, "Destroy service connection" },
76 { 0x7777, "Burst mode transfer" },
77 { 0x9999, "Request being processed" },
81 while (reqs[i].text != NULL) {
82 if (reqs[i].req == req) {
91 ncp2222_func(u_short func) {
94 static struct req_info ncp[] = {
95 { 17, "Print and Queue Services" },
96 { 21, "Message Services" },
97 { 22, "File and Directory Services" },
98 { 23, "Binding and Rights Services" },
99 { 34, "Transaction Tacking Services" },
100 { 35, "Apple File Services" },
101 { 86, "Extended Attributes Services" },
102 { 87, "File and Directory Services" },
103 { 88, "Auditing Services" },
104 { 104, "Netware Directory Services" },
105 { 123, "Netware 4.x Statistical Information Services" },
109 while (ncp[i].text != NULL) {
110 if (ncp[i].req == func) {
119 ncp2222_subfunc(u_short func, u_short subfunc) {
121 struct req_info *info_ptr = NULL;
123 /* Accounting Services */
124 static struct req_info ncp_23[] = {
125 { 150, "Get Current Account Status" },
126 { 151, "Submit Account Charge" },
127 { 152, "Submit Account Hold" },
128 { 153, "Submit Account Note" },
132 /* Apple File Services */
133 static struct req_info ncp_35[] = {
134 { 1, "AFP Create Directory" },
135 { 2, "AFP Create File" },
137 { 4, "AFP Get Entry ID from Name" },
138 { 5, "AFP Get File Information" },
139 { 6, "AFP Get Entry ID From NetWare Handle" },
141 { 8, "AFP Open File Fork" },
142 { 9, "AFP Set File Information" },
143 { 10, "AFP Scan File Information" },
144 { 11, "AFP 2.0 Alloc Temporary Directory Handle" },
145 { 12, "AFP Get Entry ID from Name Path" },
146 { 13, "AFP 2.0 Create Directory" },
147 { 14, "AFP 2.0 Create File" },
148 /* ??? { 15, "AFP 2.0 Delete File" }, just guessing */
149 { 16, "AFP 2.0 Set File Information" },
150 { 17, "AFP 2.0 Scan File Information" },
151 { 18, "AFP Get DOS Name from Entry ID" },
152 { 19, "AFP Get Macintosh Info on Deleted File" },
156 /* Auditing Services */
157 static struct req_info ncp_88[] = {
158 { 1, "Query Volume Audit Status" },
159 { 2, "Add Audit Property" },
160 { 3, "Add Auditor Access" },
176 return "Unkown function";
180 while (info_ptr[i].text != NULL) {
181 if (info_ptr[i].req == subfunc) {
182 printf("subfunc=%s\n", info_ptr[i].text);
183 return info_ptr[i].text;
192 dissect_ncp(const u_char *pd, int offset, frame_data *fd, GtkTree *tree) {
194 GtkWidget *ncp_tree, *ti;
198 if (fd->win_info[COL_NUM]) {
199 strcpy(fd->win_info[COL_PROTOCOL], "NCP");
200 strcpy(fd->win_info[COL_INFO], "NCP");
203 ncp_type = pntohs(&pd[offset]);
205 if (ncp_type == 0x1111 || ncp_type == 0x2222 || ncp_type == 0x5555 ||
206 ncp_type == 0x7777) {
209 else if (ncp_type == 0x3333 || ncp_type == 0x9999) {
217 ti = add_item_to_tree(GTK_WIDGET(tree), offset, ncp_hdr,
218 "NetWare Core Protocol");
219 ncp_tree = gtk_tree_new();
220 add_subtree(ti, ncp_tree, ETT_NCP);
222 add_item_to_tree(ncp_tree, offset, 2,
223 "Type: %s", req_text( pntohs( &pd[offset] ) ) );
225 add_item_to_tree(ncp_tree, offset+2, 1,
226 "Sequence Number: %d", pd[offset+2]);
228 add_item_to_tree(ncp_tree, offset+3, 1,
229 "Connection Number Low: %d", pd[offset+3]);
231 add_item_to_tree(ncp_tree, offset+4, 1,
232 "Task Number: %d", pd[offset+4]);
234 add_item_to_tree(ncp_tree, offset+5, 1,
235 "Connection Number High: %d", pd[offset+5]);
238 add_item_to_tree(ncp_tree, offset+6, 1,
239 "Completion Code: %d", pd[offset+6]);
241 add_item_to_tree(ncp_tree, offset+7, 1,
242 "Connection Status: %d", pd[offset+7]);
247 if (ncp_type == 0x2222) {
248 /* my offset is different now */
249 add_item_to_tree(ncp_tree, offset, 1,
250 "Function Code: %s (%d)",
251 ncp2222_func(pd[offset]), pd[offset]);
253 add_item_to_tree(ncp_tree, offset+2, 1,
254 "Subfunction Code: %s (%d)",
255 ncp2222_subfunc(pd[offset], pd[offset+2]), pd[offset+2]);
260 dissect_data(pd, offset, fd, tree);