-
Notifications
You must be signed in to change notification settings - Fork 2
/
fcoed.h
113 lines (98 loc) · 3.23 KB
/
fcoed.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
#ifndef _FCOED_H
#define _FCOED_H
/*
* Copyright (C) 2010 Michael Brown <[email protected]>.
*
* 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 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., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include <stdint.h>
#include <net/if.h>
#include <netinet/if_ether.h>
#include <pcap.h>
#include "list.h"
/** PID file name */
#define PIDFILE_NAME "/var/run/fcoed.pid"
/** Maximum capture length */
#define PCAP_LEN 65535 /* Maximum possible packet length */
/** Advertisement period in milliseconds */
#define FKA_ADV_PERIOD 8000
/** printf() format for MAC addresses */
#define MAC_FMT "%02x:%02x:%02x:%02x:%02x:%02x"
/** printf() arguments for MAC addresses */
#define MAC_ARGS(mac) \
(mac)[0], (mac)[1], (mac)[2], (mac)[3], (mac)[4], (mac)[5]
/** Mark an argument as unused */
#define __unused __attribute__ (( unused ))
/** Define ETH_P_FCOE and ETH_P_FIP if necessary */
#ifndef ETH_P_FCOE
#define ETH_P_FCOE 0x8906
#endif
#ifndef ETH_P_FIP
#define ETH_P_FIP 0x8914
#endif
#ifndef ETH_P_8021Q
#define ETH_P_8021Q 0x8100
#endif
/** An interface on which fcoed operates */
struct fcoed_interface {
/** List of interfaces */
struct list_head list;
/** Interface name */
char name[IF_NAMESIZE];
/** Packet capture interface */
pcap_t *pcap;
/** Packet capture file descriptor */
int fd;
/** List of FCoE N_Ports */
struct list_head ports;
};
/** An FCoE N_Port */
struct fcoed_port {
/** List of FCoE N_Ports on this interface */
struct list_head list;
/** Port ID */
struct fc_port_id port_id;
/** FCoE MAC address */
uint8_t mac[ETH_ALEN];
/** Real MAC address */
uint8_t real_mac[ETH_ALEN];
/** VLAN tag, if present */
uint16_t vlan;
};
extern struct fc_map fc_map;
extern struct fc_port_id fc_f_port_id;
extern uint8_t fc_f_mac[ETH_ALEN];
extern union fcoe_name fc_f_node_wwn;
extern union fcoe_name fc_f_port_wwn;
extern struct fc_port_id fc_ls_port_id;
extern struct fc_port_id fc_gs_port_id;
extern int allow_spma;
extern int fc_vlan;
extern void logmsg ( int level, const char *format, ... )
__attribute__ (( format ( printf, 2, 3 ) ));
extern void random_ether_addr ( uint8_t *mac );
extern int add_port ( struct fcoed_interface *intf, uint16_t vlan,
uint8_t *real_mac, uint8_t *mac,
struct fcoed_port **port );
extern int find_port_by_mac ( uint8_t *mac, struct fcoed_interface **intf,
struct fcoed_port **port );
extern int find_port_by_real_mac ( uint8_t *real_mac,
struct fcoed_interface **intf,
struct fcoed_port **port );
extern int find_port_by_id ( struct fc_port_id *port_id,
struct fcoed_interface **intf,
struct fcoed_port **port );
extern void remove_port ( struct fcoed_port *port );
#endif /* _FCOED_H */