~ubuntu-branches/ubuntu/natty/ntop/natty

« back to all changes in this revision

Viewing changes to fcUtils.h

  • Committer: Bazaar Package Importer
  • Author(s): Ola Lundqvist
  • Date: 2005-01-30 21:59:13 UTC
  • mfrom: (2.1.1 warty)
  • Revision ID: james.westby@ubuntu.com-20050130215913-xc3ke963bw49b3k4
Tags: 2:3.0-5
* Updated README.Debian file so users will understand what to do at
  install, closes: #291794, #287802.
* Updated ntop init script to give better output.
* Also changed log directory from /var/lib/ntop to /var/log/ntop,
  closes: #252352.
* Quoted the interface list to allow whitespace, closes: #267248.
* Added a couple of logcheck ignores, closes: #269321, #269319.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
 
3
 *                          http://www.ntop.org
 
4
 *
 
5
 * Copyright (C) 2003 Dinesh G. Dutt <ddutt@cisco.com>
 
6
 * Copyright (C) 2003-04 Luca Deri <deri@ntop.org>
 
7
 *
 
8
 * -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
 
9
 *
 
10
 * This program is free software; you can redistribute it and/or modify
 
11
 * it under the terms of the GNU General Public License as published by
 
12
 * the Free Software Foundation; either version 2 of the License, or
 
13
 * (at your option) any later version.
 
14
 *
 
15
 * This program is distributed in the hope that it will be useful,
 
16
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
17
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
18
 * GNU General Public License for more details.
 
19
 *
 
20
 * You should have received a copy of the GNU General Public License
 
21
 * along with this program; if not, write to the Free Software Foundation,
 
22
 * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 
23
 */
 
24
 
 
25
#ifndef __FC_UTILS_H__
 
26
#define __FC_UTILS_H__
 
27
 
 
28
#define FC_ID_SYSTEM_DOMAIN    0xFF
 
29
#define FC_ID_DOMCTLR_AREA     0xFC
 
30
#define FC_BROADCAST_ADDR      "ff.ff.ff"
 
31
#define FC_FAB_CTLR_ADDR       "ff.ff.fd"
 
32
 
 
33
#define MDSHDR_HEADER_SIZE               16
 
34
#define MDSHDR_TRAILER_SIZE              6
 
35
 
 
36
/* SOF Encodings */
 
37
#define MDSHDR_SOFc1                     0x1
 
38
#define MDSHDR_SOFi1                     0x2
 
39
#define MDSHDR_SOFn1                     0x3
 
40
#define MDSHDR_SOFi2                     0x4
 
41
#define MDSHDR_SOFn2                     0x5
 
42
#define MDSHDR_SOFi3                     0x6
 
43
#define MDSHDR_SOFn3                     0x7
 
44
#define MDSHDR_SOFf                      0x8
 
45
#define MDSHDR_SOFc4                     0x9
 
46
#define MDSHDR_SOFi4                     0xa
 
47
#define MDSHDR_SOFn4                     0xb
 
48
 
 
49
/* EOF Encodings */
 
50
#define MDSHDR_EOFt                      0x1
 
51
#define MDSHDR_EOFdt                     0x2
 
52
#define MDSHDR_EOFa                      0x4
 
53
#define MDSHDR_EOFn                      0x3
 
54
#define MDSHDR_EOFdti                    0x6
 
55
#define MDSHDR_EOFni                     0x7
 
56
#define MDSHDR_EOFrt                     0xa
 
57
#define MDSHDR_EOFrti                    0xe
 
58
#define MDSHDR_EOF_UNKNOWN               0xb
 
59
 
 
60
/* R_CTL upper bits creates a classification tree */
 
61
#define FC_RCTL_DEV_DATA       0x00
 
62
#define FC_RCTL_ELS            0x20
 
63
#define FC_RCTL_LINK_DATA      0x30
 
64
#define FC_RCTL_VIDEO          0x40
 
65
#define FC_RCTL_BLS            0x80
 
66
#define FC_RCTL_LINK_CTL       0xC0
 
67
/* XXX - is 0xF0 Extended Routing?  It is in the FC-FS draft on the T11
 
68
   Web site. */
 
69
 
 
70
#define FC_TYPE_CMNSVC         0x0  /* Used in PRLI Svc Param Page */
 
71
 
 
72
/* TYPE definitions for Basic or Extended Link_Data */
 
73
#define FC_TYPE_ELS            0x1
 
74
 
 
75
/* TYPE definitions for FC-4 */
 
76
#define FC_TYPE_LLCSNAP        0x4
 
77
#define FC_TYPE_IP             0x5
 
78
#define FC_TYPE_SCSI           0x8
 
79
#define FC_TYPE_SB_TO_CU       0x1B /* SB3 Control Unit -> Channel */
 
80
#define FC_TYPE_SB_FROM_CU     0x1C /* SB3 Channel -> Control Unit */ 
 
81
#define FC_TYPE_FCCT           0x20
 
82
#define FC_TYPE_SWILS          0x22
 
83
#define FC_TYPE_AL             0x23
 
84
#define FC_TYPE_SNMP           0x24
 
85
 
 
86
/* Derived Frame types (used for ULP demux) */
 
87
#define FC_FTYPE_SWILS         0x1
 
88
#define FC_FTYPE_IP            0x2
 
89
#define FC_FTYPE_SCSI          0x3
 
90
#define FC_FTYPE_BLS           0x4
 
91
#define FC_FTYPE_ELS           0x5
 
92
#define FC_FTYPE_FCCT          0x7
 
93
#define FC_FTYPE_LINKDATA      0x8
 
94
#define FC_FTYPE_VDO           0x9
 
95
#define FC_FTYPE_LINKCTL       0xA
 
96
#define FC_FTYPE_SWILS_RSP     0xB
 
97
#define FC_FTYPE_SBCCS         0xC
 
98
#define FC_FTYPE_UNDEF         0xD
 
99
 
 
100
/* Well-known Address Definitions (in Network order) */
 
101
#define FC_WKA_MULTICAST       0xFFFFF5
 
102
#define FC_WKA_CLKSYNC         0xFFFFF6
 
103
#define FC_WKA_KEYDIST         0xFFFFF7
 
104
#define FC_WKA_ALIAS           0xFFFFF8
 
105
#define FC_WKA_QOSF            0xFFFFF9
 
106
#define FC_WKA_MGMT            0xFFFFFA
 
107
#define FC_WKA_TIME            0xFFFFFB
 
108
#define FC_WKA_DNS             0xFFFFFC
 
109
#define FC_WKA_FABRIC_CTRLR    0xFFFFFD
 
110
#define FC_WKA_FPORT           0xFFFFFE
 
111
#define FC_WKA_BCAST           0xFFFFFF
 
112
 
 
113
#define FC_ELS_CMD_ACC         0x02
 
114
#define FC_ELS_CMD_PLOGI       0x03
 
115
#define FC_ELS_CMD_LOGO        0x05
 
116
#define FC_ELS_CMD_RSCN          0x61
 
117
#define FC_ELS_CMD_SCR           0x62
 
118
 
 
119
/* Well-known GSTYPEs */
 
120
#define FCCT_GSTYPE_KEYSVC   0xF7
 
121
#define FCCT_GSTYPE_ALIASSVC 0xF8
 
122
#define FCCT_GSTYPE_MGMTSVC  0xFA
 
123
#define FCCT_GSTYPE_TIMESVC  0xFB
 
124
#define FCCT_GSTYPE_DIRSVC   0xFC
 
125
 
 
126
/* Well-known GSSUBTYPES */
 
127
/* Actual servers serving the directory service type identified by subtype */ 
 
128
#define FCCT_GSSUBTYPE_DNS  0x02
 
129
#define FCCT_GSSUBTYPE_IP   0x03
 
130
#define FCCT_GSSUBTYPE_FCS  0x01
 
131
#define FCCT_GSSUBTYPE_UNS  0x02
 
132
#define FCCT_GSSUBTYPE_FZS  0x03
 
133
#define FCCT_GSSUBTYPE_AS   0x01
 
134
#define FCCT_GSSUBTYPE_TS   0x01
 
135
 
 
136
#define FCDNS_RPN_ID   0x0212
 
137
#define FCDNS_RNN_ID   0x0213
 
138
#define FCDNS_RCS_ID   0x0214
 
139
#define FCDNS_RFT_ID   0x0217
 
140
#define FCDNS_RSPN_ID  0x0218
 
141
#define FCDNS_RPT_ID   0x021A
 
142
#define FCDNS_RIPP_ID  0x021B
 
143
#define FCDNS_RHA_ID   0x021D
 
144
#define FCDNS_RFD_ID   0x021E
 
145
#define FCDNS_RFF_ID   0x021F
 
146
#define FCDNS_RIP_NN   0x0235
 
147
#define FCDNS_RIPA_NN  0x0236
 
148
#define FCDNS_RSNN_NN  0x0239
 
149
 
 
150
/* Information Categories based on lower 4 bits of R_CTL */
 
151
#define FCP_IU_DATA              0x1
 
152
#define FCP_IU_CONFIRM           0x3
 
153
#define FCP_IU_XFER_RDY          0x5
 
154
#define FCP_IU_CMD               0x6
 
155
#define FCP_IU_RSP               0x7
 
156
 
 
157
/* SWILS Commands */
 
158
#define FC_SWILS_SWRJT          0x01
 
159
#define FC_SWILS_SWACC          0x02
 
160
#define FC_SWILS_ELP            0x10
 
161
#define FC_SWILS_EFP            0x11
 
162
#define FC_SWILS_DIA            0x12
 
163
#define FC_SWILS_RDI            0x13
 
164
#define FC_SWILS_HLO            0x14
 
165
#define FC_SWILS_LSU            0x15
 
166
#define FC_SWILS_LSA            0x16
 
167
#define FC_SWILS_BF             0x17
 
168
#define FC_SWILS_RCF            0x18
 
169
#define FC_SWILS_RSCN           0x1B
 
170
#define FC_SWILS_DRLIR          0x1E
 
171
#define FC_SWILS_DSCN           0x20
 
172
#define FC_SWILS_LOOPD          0x21
 
173
#define FC_SWILS_MR             0x22
 
174
#define FC_SWILS_ACA            0x23
 
175
#define FC_SWILS_RCA            0x24
 
176
#define FC_SWILS_SFC            0x25
 
177
#define FC_SWILS_UFC            0x26
 
178
#define FC_SWILS_ESC            0x30
 
179
 
 
180
#define FC_HDR_SIZE             24
 
181
 
 
182
/* SW_RSCN fields */
 
183
#define FC_SW_RSCN_FABRIC_DETECT 0x01
 
184
#define FC_SW_RSCN_NPORT_DETECT  0x02
 
185
 
 
186
#define FC_SW_RSCN_PORT_ONLINE   0x10
 
187
#define FC_SW_RSCN_PORT_OFFLINE  0x20
 
188
 
 
189
#define CMP_FC_PORT(a,b) \
 
190
        if ((a->hostFcAddress.domain == 0xFF) ||                                        \
 
191
            (b->hostFcAddress.domain == 0xFF)) {                                        \
 
192
            /* Always compare FC_IDs for reserved FC_IDs */                             \
 
193
            rc = memcmp (&a->hostFcAddress, &b->hostFcAddress, LEN_FC_ADDRESS);         \
 
194
        }                                                                               \
 
195
        else {                                                                          \
 
196
            /* Sort such that entries with alias names show up together, then           \
 
197
             * entries with pWWN and finally entries with FC_ID. Within each            \
 
198
             * set, the entries must be correctly sorted.                               \
 
199
             */                                                                         \
 
200
            if ((a->hostResolvedName[0] != '\0') &&                                       \
 
201
                (b->hostResolvedName[0] != '\0')) {                                       \
 
202
                rc = strcmp(a->hostResolvedName, b->hostResolvedName);                      \
 
203
            }                                                                           \
 
204
            else if ((a->hostResolvedName[0] == 0) &&                                     \
 
205
                     (b->hostResolvedName[0] != '\0')) {                                  \
 
206
                rc = 1;        /* Named entries float to top */                         \
 
207
            }                                                                           \
 
208
            else if ((a->hostResolvedName[0] != 0) &&                                     \
 
209
                     (b->hostResolvedName[0] == '\0')) {                                  \
 
210
                rc = -1;        /* Named entries float to top */                        \
 
211
            }                                                                           \
 
212
            else if ((a->pWWN.str[0] != '\0') &&                                        \
 
213
                     (b->pWWN.str[0] != '\0')) {                                        \
 
214
                rc = memcmp (a->pWWN.str, b->pWWN.str, LEN_WWN_ADDRESS);                \
 
215
            }                                                                           \
 
216
            else if ((a->pWWN.str[0] == '\0') &&                                        \
 
217
                     (b->pWWN.str[0] != '\0')) {                                        \
 
218
                rc = 1;  /* pWWN entries float above FC_ID only entries */              \
 
219
            }                                                                           \
 
220
            else if ((a->pWWN.str[0] != '\0') &&                                        \
 
221
                     (b->pWWN.str[0] == '\0')) {                                        \
 
222
                rc = -1;                                                                \
 
223
            }                                                                           \
 
224
            else {                                                                      \
 
225
                rc = memcmp (&a->hostIpAddress, &b->hostIpAddress, LEN_FC_ADDRESS);     \
 
226
            }                                                                           \
 
227
        }
 
228
 
 
229
 
 
230
 
 
231
#endif