2 * Routines for FC Link Control Frames
3 * Copyright 2001, Dinesh G Dutt <ddutt@cisco.com>
5 * $Id: packet-fclctl.c,v 1.2 2003/06/30 21:50:17 guy Exp $
7 * Ethereal - Network traffic analyzer
8 * By Gerald Combs <gerald@ethereal.com>
9 * Copyright 1998 Gerald Combs
11 * This program is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU General Public License
13 * as published by the Free Software Foundation; either version 2
14 * of the License, or (at your option) any later version.
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
34 #ifdef HAVE_SYS_TYPES_H
35 # include <sys/types.h>
38 #ifdef HAVE_NETINET_IN_H
39 # include <netinet/in.h>
44 #ifdef NEED_SNPRINTF_H
45 # include "snprintf.h"
48 #include <epan/packet.h>
50 #include "packet-fc.h"
51 #include "packet-fclctl.h"
53 const value_string fc_lctl_proto_val[] = {
54 {FC_LCTL_ACK1 , "ACK1"},
55 {FC_LCTL_ACK0 , "ACK0"},
56 {FC_LCTL_PRJT , "P_RJT"},
57 {FC_LCTL_FRJT , "F_RJT"},
58 {FC_LCTL_PBSY , "P_BSY"},
59 {FC_LCTL_FBSYL , "F_BSY (Data frame)"},
60 {FC_LCTL_FBSYB , "F_BSY (Link Ctl)"},
61 {FC_LCTL_LCR , "LCR"},
62 {FC_LCTL_NTY , "NTY"},
63 {FC_LCTL_END , "END"},
67 static const value_string fc_lctl_fbsy_val[] = {
68 {FC_LCTL_FBSY_FBSY, "Fabric Busy"},
69 {FC_LCTL_FBSY_NBSY, "N_Port Busy"},
73 static const value_string fc_lctl_pbsy_acode_val[] = {
74 {FC_LCTL_PBSY_ACODE_SEQBSY, "Sequence Marked Busy"},
75 {FC_LCTL_PBSY_ACODE_C2BSY, "Class 2 Frame Busy"},
79 static const value_string fc_lctl_pbsy_rjt_val[] = {
80 {FC_LCTL_PBSY_PORTBSY , "Physical N_Port Busy"},
81 {FC_LCTL_PBSY_RSRCBSY , "N_Port Resource Busy"},
82 {FC_LCTL_PBSY_MCASTBSY, "Partial Multicast Busy"},
83 {FC_LCTL_PBSY_VENDBSY , "Vendor unique Busy"},
87 static const value_string fc_lctl_rjt_acode_val[] = {
88 {FC_LCTL_RJT_ACODE_RETRY, "Retryable Error"},
89 {FC_LCTL_RJT_ACODE_NORETRY, "Non-retryable Error"},
93 static const value_string fc_lctl_rjt_val[] = {
94 {FC_LCTL_RJT_INVSID , "Invalid S_ID"},
95 {FC_LCTL_RJT_INVDID , "Invalid D_ID"},
96 {FC_LCTL_RJT_NPORT_NOTAVAIL_T , "N_Port Not Avail (Temporary)"},
97 {FC_LCTL_RJT_NPORT_NOTAVAIL_P , "N_Port Not Avail (Permanent)"},
98 {FC_LCTL_RJT_CLASS_NOTSUPP , "Class Not Supported"},
99 {FC_LCTL_RJT_DELIM_USERR , "Delimiter Usage Error"},
100 {FC_LCTL_RJT_TYPE_NOTSUPP , "Type Not Supported"},
101 {FC_LCTL_RJT_INV_LCTL , "Invalid Link Ctl Frame"},
102 {FC_LCTL_RJT_INV_RCTL , "Invalid R_CTL"},
103 {FC_LCTL_RJT_INV_FCTL , "Invalid F_CTL"},
104 {FC_LCTL_RJT_INV_OXID , "Invalid OX_ID"},
105 {FC_LCTL_RJT_INV_RXID , "Invalid RX_ID"},
106 {FC_LCTL_RJT_INV_SEQID , "Invalid SEQID"},
107 {FC_LCTL_RJT_INV_DFCTL , "Invalid DF_CTL"},
108 {FC_LCTL_RJT_INV_SEQCNT , "Invalid SEQCNT"},
109 {FC_LCTL_RJT_INV_PARAM , "Invalid Parameter"},
110 {FC_LCTL_RJT_EXCHG_ERR , "Exchange Error"},
111 {FC_LCTL_RJT_PROTO_ERR , "Protocol Error"},
112 {FC_LCTL_RJT_INV_LEN , "Incorrect Length"},
113 {FC_LCTL_RJT_UNEXP_ACK , "Unexpected ACK"},
114 {FC_LCTL_RJT_CLS_NOTSUPP , "Class Not Supported by Entity at 0xFFFFFE"},
115 {FC_LCTL_RJT_LOGI_REQD , "Login Required"},
116 {FC_LCTL_RJT_TOOMANY_SEQ , "Excessive Sequences Attempted"},
117 {FC_LCTL_RJT_EXCHG_NOTESTD , "Exchange Not Established"},
118 {FC_LCTL_RJT_RSVD , "Reserved"},
119 {FC_LCTL_RJT_FPATH_NOTAVAIL , "Fabric Path Not Available"},
120 {FC_LCTL_RJT_INV_VCID , "Invalid VC_ID"},
121 {FC_LCTL_RJT_INV_CSCTL , "Invalid CS_CTL"},
122 {FC_LCTL_RJT_OORSRC , "Insufficient Resources of VC (Class 4)"},
123 {FC_LCTL_RJT_INV_CLASS , "Invalid Class of Service"},
124 {FC_LCTL_RJT_PRMPT_RJT , "Preemption Request Rejected"},
125 {FC_LCTL_RJT_PRMPT_DIS , "Preemption Not Enabled"},
126 {FC_LCTL_RJT_MCAST_ERR , "Multicast Error"},
127 {FC_LCTL_RJT_MCAST_TERM , "Multicast Error Terminate"},
128 {FC_LCTL_RJT_PRLI_REQD , "PRLI Required"},
129 {FC_LCTL_RJT_VEND_ERR , "Vendor Unique Error"},
133 static gchar errstr[64];
136 fclctl_get_typestr (guint8 linkctl_type, guint8 type)
138 if ((linkctl_type == FC_LCTL_FBSYB) ||
139 (linkctl_type == FC_LCTL_FBSYL)) {
140 return (val_to_str ((type & 0xF0), fc_lctl_fbsy_val, "0x%x"));
146 fclctl_get_paramstr (guint32 linkctl_type, guint32 param)
152 if (linkctl_type == FC_LCTL_PBSY) {
153 strcpy (errstr, val_to_str (((param & 0xFF000000) >> 24),
154 fc_lctl_pbsy_acode_val, "0x%x"));
155 len = strlen (errstr);
156 strcpy (&errstr[len], ", ");
157 len = strlen (errstr);
158 strcpy (&errstr[len],
159 val_to_str (((param & 0x00FF0000) >> 16),
160 fc_lctl_pbsy_rjt_val, "0x%x"));
162 else if ((linkctl_type == FC_LCTL_FRJT) ||
163 (linkctl_type == FC_LCTL_PRJT)) {
165 val_to_str (((param & 0xFF000000) >> 24),
166 fc_lctl_rjt_acode_val, "0x%x"));
167 len = strlen (errstr);
168 strcpy (&errstr[len], ", ");
169 len = strlen (errstr);
170 strcpy (&errstr[len],
171 val_to_str (((param & 0x00FF0000) >> 16), fc_lctl_rjt_val,