NetSim Source Code Help
Loading...
Searching...
No Matches
Ethernet.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  stru_eth_packet
 
struct  stru_eth_bpdu
 
struct  ieee802_1q_tag
 
struct  stru_SwitchTable
 
struct  stru_eth_interface_var
 
struct  stru_ethernet_spt
 
struct  stru_ethernet_lan
 
struct  stru_ethernet_var
 
struct  stru_eth_phy
 

Macros

#define isETHConfigured(d, i)   (DEVICE_MACLAYER(d,i)->nMacProtocolId == MAC_PROTOCOL_IEEE802_3)
 
#define ETH_IFG   0.960
 
#define ETH_HDR_CBPDU   1
 
#define ETH_HDR_VID   2
 
#define ETH_HDR_NW   3
 
#define ETH_BPDU_LEN   60
 
#define IEEE801_1Q_TAG_LEN   4
 
#define VLAN_TPID   0x8100
 
#define SWITCHTABLE_ALLOC()   (ptrSWITCHTABLE)list_alloc(sizeof(SWITCHTABLE),offsetof(SWITCHTABLE,ele))
 
#define SWITCHTABLE_ADD(l, m)   LIST_ADD_LAST((void**)(l),m)
 
#define SWITCHTABLE_NEXT(t)   t=(ptrSWITCHTABLE)LIST_NEXT(t)
 
#define SWITCHTABLE_GET(d, in)   (GET_ETH_LAN(d,in,0)->switchTable)
 
#define SWITCHTABLE_GET_LAN(lan)   (lan->switchTable)
 
#define ETH_PHY_GET(d, i)   ((ptrETH_PHY)DEVICE_PHYLAYER(d,i)->phyVar)
 

Typedefs

typedef enum enum_eth_packet ETH_PACKET
 
typedef enum enum_SwitchingTechnique SWITCHING_TECHNIQUE
 
typedef enum enum_PortState SWITCH_PORTSTATE
 
typedef enum enum_port_type SWITCH_PORTTYPE
 
typedef struct stru_ethernet_lan ETH_LAN
 
typedef struct stru_ethernet_lanptrETH_LAN
 
typedef struct stru_eth_packet ETH_HDR
 
typedef struct stru_eth_packetptrETH_HDR
 
typedef struct stru_eth_bpdu ETH_BPDU
 
typedef struct stru_eth_bpduptrETH_BPDU
 
typedef struct ieee802_1q_tag IEEE801_1Q_TAG
 
typedef struct ieee802_1q_tagptrIEEE801_1Q_TAG
 
typedef struct stru_SwitchTable SWITCHTABLE
 
typedef struct stru_SwitchTableptrSWITCHTABLE
 
typedef struct stru_eth_interface_var ETH_IF
 
typedef struct stru_eth_interface_varptrETH_IF
 
typedef struct stru_ethernet_spt ETH_SPT
 
typedef struct stru_ethernet_sptptrETH_SPT
 
typedef struct stru_ethernet_var ETH_VAR
 
typedef struct stru_ethernet_varptrETH_VAR
 
typedef struct stru_eth_phy ETH_PHY
 
typedef struct stru_eth_phyptrETH_PHY
 

Enumerations

enum  enum_eth_packet { ETH_CONFIGBPDU = MAC_PROTOCOL_IEEE802_3 * 100 + 1 }
 
enum  enum_SwitchingTechnique { SWITCHINGTECHNIQUE_NULL , SWITCHINGTECHNIQUE_STORE_FORWARD , SWITCHINGTECHNIQUE_CUT_THROUGH , SWITCHINGTECHNIQUE_FRAGMENT_FREE }
 
enum  enum_PortState {
  PORTSTATE_DISABLED , PORTSTATE_LISTENING , PORTSTATE_LEARNING , PORTSTATE_FORWARDING ,
  PORTSTATE_BLOCKING
}
 
enum  enum_port_type { PORTTYPE_DESIGNATED , PORTTYPE_NONDESIGNATED , PORTTYPE_ROOT }
 
enum  VLANPORT { VLANPORT_NONE , VLANPORT_ACCESS , VLANPORT_TRUNK }
 

Functions

void set_eth_hdr (NetSim_PACKET *packet, UINT type, void *var, void *(fncopy)(void *), void(*fnfree)(void *))
 
void free_eth_hdr (NetSim_PACKET *packet)
 
void * get_eth_hdr_var (NetSim_PACKET *packet)
 
bool isVLANTagPresent (NetSim_PACKET *packet)
 
ptrSWITCHTABLE SWITCHTABLE_FIND (ptrETH_LAN lan, PNETSIM_MACADDRESS dest)
 
void SWITCHTABLE_NEW (ptrETH_LAN lan, PNETSIM_MACADDRESS dest, NETSIM_ID outport)
 
void switchtable_metrics_print (PMETRICSWRITER metricsWriter)
 
VLANPORT vlan_port_type_from_str (char *val)
 
ptrETH_IF GET_ETH_IF (ptrETH_LAN lan, NETSIM_ID i)
 
ptrETH_LAN GET_ETH_LAN (NETSIM_ID d, NETSIM_ID i, UINT16 vlanId)
 
ptrETH_VAR GET_ETH_VAR (NETSIM_ID d)
 
void SET_ETH_VAR (NETSIM_ID d, ptrETH_VAR var)
 
void FREE_ETH_VAR (NETSIM_ID d)
 
void init_spanning_tree_protocol ()
 
int multicast_config_bpdu ()
 
void process_configbpdu ()
 
void vlan_add_trunk_port (ptrETH_VAR eth, NETSIM_ID in)
 
void vlan_forward_to_all_trunk (NETSIM_ID d, NetSim_PACKET *packet, ptrETH_LAN lan, double time)
 
void vlan_macout_forward_packet (NETSIM_ID d, NETSIM_ID in, UINT16 vlanId, NETSIM_ID incoming, NetSim_PACKET *packet, double time)
 
void vlan_macin_forward_packet ()
 
NETSIM_ID find_forward_interface (ptrETH_LAN lan, NetSim_PACKET *packet)
 
void check_move_frame_up (NETSIM_ID d, NETSIM_ID in, ptrETH_LAN lan, NetSim_PACKET *packet, double time)
 
void forward_frame (NETSIM_ID d, NETSIM_ID in, ptrETH_LAN lan, NetSim_PACKET *packet, double time)
 
void send_to_phy (NETSIM_ID d, NETSIM_ID in, NetSim_PACKET *packet, double time)
 
NETSIM_ID get_interface_id (NETSIM_ID d, NETSIM_ID c)
 
void print_ethernet_log (char *format,...)
 
void print_spanning_tree ()
 
void store_eth_param_macin (NetSim_PACKET *packet, NETSIM_ID devId, NETSIM_ID in, ptrETH_LAN lan)
 
void store_eth_incoming (NetSim_PACKET *packet, NETSIM_ID devId, NETSIM_ID incomingPort, UINT16 vlanId)
 
UINT16 eth_get_incoming_vlanid (NetSim_PACKET *packet, NETSIM_ID devId)
 
NETSIM_ID eth_get_incoming_port (NetSim_PACKET *packet, NETSIM_ID devId)
 
void clear_eth_incoming (NetSim_PACKET *packet)
 

Variables

PNETSIM_MACADDRESS multicastSPTMAC
 

Macro Definition Documentation

◆ ETH_BPDU_LEN

#define ETH_BPDU_LEN   60

Definition at line 104 of file Ethernet.h.

◆ ETH_HDR_CBPDU

#define ETH_HDR_CBPDU   1

Definition at line 75 of file Ethernet.h.

◆ ETH_HDR_NW

#define ETH_HDR_NW   3

Definition at line 77 of file Ethernet.h.

◆ ETH_HDR_VID

#define ETH_HDR_VID   2

Definition at line 76 of file Ethernet.h.

◆ ETH_IFG

#define ETH_IFG   0.960

Definition at line 38 of file Ethernet.h.

◆ ETH_PHY_GET

#define ETH_PHY_GET (   d,
 
)    ((ptrETH_PHY)DEVICE_PHYLAYER(d,i)->phyVar)

Definition at line 224 of file Ethernet.h.

◆ IEEE801_1Q_TAG_LEN

#define IEEE801_1Q_TAG_LEN   4

Definition at line 113 of file Ethernet.h.

◆ isETHConfigured

#define isETHConfigured (   d,
 
)    (DEVICE_MACLAYER(d,i)->nMacProtocolId == MAC_PROTOCOL_IEEE802_3)

Definition at line 34 of file Ethernet.h.

◆ SWITCHTABLE_ADD

#define SWITCHTABLE_ADD (   l,
 
)    LIST_ADD_LAST((void**)(l),m)

Definition at line 125 of file Ethernet.h.

◆ SWITCHTABLE_ALLOC

#define SWITCHTABLE_ALLOC ( )    (ptrSWITCHTABLE)list_alloc(sizeof(SWITCHTABLE),offsetof(SWITCHTABLE,ele))

Definition at line 124 of file Ethernet.h.

◆ SWITCHTABLE_GET

#define SWITCHTABLE_GET (   d,
  in 
)    (GET_ETH_LAN(d,in,0)->switchTable)

Definition at line 127 of file Ethernet.h.

◆ SWITCHTABLE_GET_LAN

#define SWITCHTABLE_GET_LAN (   lan)    (lan->switchTable)

Definition at line 128 of file Ethernet.h.

◆ SWITCHTABLE_NEXT

#define SWITCHTABLE_NEXT (   t)    t=(ptrSWITCHTABLE)LIST_NEXT(t)

Definition at line 126 of file Ethernet.h.

◆ VLAN_TPID

#define VLAN_TPID   0x8100

Definition at line 114 of file Ethernet.h.

Typedef Documentation

◆ ETH_BPDU

typedef struct stru_eth_bpdu ETH_BPDU

◆ ETH_HDR

typedef struct stru_eth_packet ETH_HDR

◆ ETH_IF

◆ ETH_LAN

typedef struct stru_ethernet_lan ETH_LAN

Definition at line 73 of file Ethernet.h.

◆ ETH_PACKET

◆ ETH_PHY

typedef struct stru_eth_phy ETH_PHY

◆ ETH_SPT

typedef struct stru_ethernet_spt ETH_SPT

◆ ETH_VAR

typedef struct stru_ethernet_var ETH_VAR

◆ IEEE801_1Q_TAG

◆ ptrETH_BPDU

typedef struct stru_eth_bpdu * ptrETH_BPDU

◆ ptrETH_HDR

typedef struct stru_eth_packet* ptrETH_HDR

◆ ptrETH_IF

◆ ptrETH_LAN

typedef struct stru_ethernet_lan * ptrETH_LAN

Definition at line 73 of file Ethernet.h.

◆ ptrETH_PHY

typedef struct stru_eth_phy * ptrETH_PHY

◆ ptrETH_SPT

typedef struct stru_ethernet_spt * ptrETH_SPT

◆ ptrETH_VAR

typedef struct stru_ethernet_var* ptrETH_VAR

◆ ptrIEEE801_1Q_TAG

◆ ptrSWITCHTABLE

typedef struct stru_SwitchTable * ptrSWITCHTABLE

◆ SWITCH_PORTSTATE

Enumeration for SWITCH Port state

◆ SWITCH_PORTTYPE

◆ SWITCHING_TECHNIQUE

Enumeration for Switching Technique

◆ SWITCHTABLE

typedef struct stru_SwitchTable SWITCHTABLE

Enumeration Type Documentation

◆ enum_eth_packet

Enumerator
ETH_CONFIGBPDU 

Definition at line 40 of file Ethernet.h.

◆ enum_port_type

Enumerator
PORTTYPE_DESIGNATED 
PORTTYPE_NONDESIGNATED 
PORTTYPE_ROOT 

Definition at line 64 of file Ethernet.h.

◆ enum_PortState

Enumeration for SWITCH Port state

Enumerator
PORTSTATE_DISABLED 
PORTSTATE_LISTENING 
PORTSTATE_LEARNING 
PORTSTATE_FORWARDING 
PORTSTATE_BLOCKING 

Definition at line 55 of file Ethernet.h.

◆ enum_SwitchingTechnique

Enumeration for Switching Technique

Enumerator
SWITCHINGTECHNIQUE_NULL 
SWITCHINGTECHNIQUE_STORE_FORWARD 
SWITCHINGTECHNIQUE_CUT_THROUGH 
SWITCHINGTECHNIQUE_FRAGMENT_FREE 

Definition at line 46 of file Ethernet.h.

◆ VLANPORT

enum VLANPORT
Enumerator
VLANPORT_NONE 
VLANPORT_ACCESS 
VLANPORT_TRUNK 

Definition at line 133 of file Ethernet.h.

Function Documentation

◆ check_move_frame_up()

void check_move_frame_up ( NETSIM_ID  d,
NETSIM_ID  in,
ptrETH_LAN  lan,
NetSim_PACKET packet,
double  time 
)

Definition at line 187 of file Ethernet_Mac.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ clear_eth_incoming()

void clear_eth_incoming ( NetSim_PACKET packet)
Here is the caller graph for this function:

◆ eth_get_incoming_port()

NETSIM_ID eth_get_incoming_port ( NetSim_PACKET packet,
NETSIM_ID  devId 
)
Here is the caller graph for this function:

◆ eth_get_incoming_vlanid()

UINT16 eth_get_incoming_vlanid ( NetSim_PACKET packet,
NETSIM_ID  devId 
)
Here is the caller graph for this function:

◆ find_forward_interface()

NETSIM_ID find_forward_interface ( ptrETH_LAN  lan,
NetSim_PACKET packet 
)

Definition at line 31 of file Ethernet_Mac.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ forward_frame()

void forward_frame ( NETSIM_ID  d,
NETSIM_ID  in,
ptrETH_LAN  lan,
NetSim_PACKET packet,
double  time 
)

Definition at line 252 of file Ethernet_Mac.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ free_eth_hdr()

void free_eth_hdr ( NetSim_PACKET packet)
Here is the caller graph for this function:

◆ FREE_ETH_VAR()

void FREE_ETH_VAR ( NETSIM_ID  d)

◆ get_eth_hdr_var()

void * get_eth_hdr_var ( NetSim_PACKET packet)
Here is the caller graph for this function:

◆ GET_ETH_IF()

ptrETH_IF GET_ETH_IF ( ptrETH_LAN  lan,
NETSIM_ID  i 
)
Here is the caller graph for this function:

◆ GET_ETH_LAN()

ptrETH_LAN GET_ETH_LAN ( NETSIM_ID  d,
NETSIM_ID  i,
UINT16  vlanId 
)
Here is the caller graph for this function:

◆ GET_ETH_VAR()

ptrETH_VAR GET_ETH_VAR ( NETSIM_ID  d)
Here is the caller graph for this function:

◆ get_interface_id()

NETSIM_ID get_interface_id ( NETSIM_ID  d,
NETSIM_ID  c 
)
Here is the caller graph for this function:

◆ init_spanning_tree_protocol()

void init_spanning_tree_protocol ( )

Definition at line 266 of file SpanningTree.c.

Here is the call graph for this function:

◆ isVLANTagPresent()

bool isVLANTagPresent ( NetSim_PACKET packet)

Definition at line 34 of file Vlan.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ multicast_config_bpdu()

int multicast_config_bpdu ( )

Definition at line 301 of file SpanningTree.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ print_ethernet_log()

void print_ethernet_log ( char *  format,
  ... 
)
Here is the caller graph for this function:

◆ print_spanning_tree()

void print_spanning_tree ( )

Definition at line 539 of file SpanningTree.c.

Here is the call graph for this function:

◆ process_configbpdu()

void process_configbpdu ( )

Definition at line 484 of file SpanningTree.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ send_to_phy()

void send_to_phy ( NETSIM_ID  d,
NETSIM_ID  in,
NetSim_PACKET packet,
double  time 
)

Definition at line 41 of file Ethernet_Mac.c.

◆ set_eth_hdr()

void set_eth_hdr ( NetSim_PACKET packet,
UINT  type,
void *  var,
void *  fncopy)(void *,
void(*)(void *)  fnfree 
)
Here is the caller graph for this function:

◆ SET_ETH_VAR()

void SET_ETH_VAR ( NETSIM_ID  d,
ptrETH_VAR  var 
)

◆ store_eth_incoming()

void store_eth_incoming ( NetSim_PACKET packet,
NETSIM_ID  devId,
NETSIM_ID  incomingPort,
UINT16  vlanId 
)

◆ store_eth_param_macin()

void store_eth_param_macin ( NetSim_PACKET packet,
NETSIM_ID  devId,
NETSIM_ID  in,
ptrETH_LAN  lan 
)
Here is the caller graph for this function:

◆ SWITCHTABLE_FIND()

ptrSWITCHTABLE SWITCHTABLE_FIND ( ptrETH_LAN  lan,
PNETSIM_MACADDRESS  dest 
)

Definition at line 18 of file SwitchTable.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ switchtable_metrics_print()

void switchtable_metrics_print ( PMETRICSWRITER  metricsWriter)

Definition at line 59 of file SwitchTable.c.

Here is the call graph for this function:

◆ SWITCHTABLE_NEW()

void SWITCHTABLE_NEW ( ptrETH_LAN  lan,
PNETSIM_MACADDRESS  dest,
NETSIM_ID  outport 
)

Definition at line 30 of file SwitchTable.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ vlan_add_trunk_port()

void vlan_add_trunk_port ( ptrETH_VAR  eth,
NETSIM_ID  in 
)

Definition at line 53 of file Vlan.c.

◆ vlan_forward_to_all_trunk()

void vlan_forward_to_all_trunk ( NETSIM_ID  d,
NetSim_PACKET packet,
ptrETH_LAN  lan,
double  time 
)

Definition at line 106 of file Vlan.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ vlan_macin_forward_packet()

void vlan_macin_forward_packet ( )

Definition at line 179 of file Vlan.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ vlan_macout_forward_packet()

void vlan_macout_forward_packet ( NETSIM_ID  d,
NETSIM_ID  in,
UINT16  vlanId,
NETSIM_ID  incoming,
NetSim_PACKET packet,
double  time 
)

Definition at line 252 of file Vlan.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ vlan_port_type_from_str()

VLANPORT vlan_port_type_from_str ( char *  val)

Definition at line 43 of file Vlan.c.

Variable Documentation

◆ multicastSPTMAC

PNETSIM_MACADDRESS multicastSPTMAC

Definition at line 36 of file Ethernet.h.