a long time ago there was a function ethernet_server_two_port() provided by module_ethernet, to have 2 ethernet ports interacting as a kind of hub/switch.
Code: Select all
/** Dual MII port MAC/ethernet server.
*
* This function provides both MII layer and MAC layer functionality.
* It runs in 7 threads and communicates to clients over the channel array
* parameters.
*
* \param mii1 The first mii interface resources that the
* server will connect to
* \param mii2 The second mii interface resources that the
* server will connect to
* \param mac_address The mac_address the server will use.
* This should be a two-word array that stores the
* 6-byte macaddr in a little endian manner (so
* reinterpreting the array as a char array is as
* one would expect)
* \param rx An array of chanends to connect to clients of
* the server who wish to receive packets.
* \param num_rx The number of clients connected to the rx array
* \param tx An array of chanends to connect to clients of
* the server who wish to transmit packets.
* \param num_tx The number of clients connected to the txx array
* \param smi1 An optional parameter of resources to connect
* to the first PHY (via SMI) to check when the link
* is up.
* \param smi2 An optional parameter of resources to connect
* to a second PHY (via SMI) to check when the link
* is up.
* \param connect_status An optional parameter of a channel that is
* signalled when the link goes up or down
* (requires the smi parameter to be supplied).
*
* The clients connected via the rx/tx channels can communicate with the
* server using the APIs found in ethernet_rx_client.h and ethernet_tx_client.h
*
* If the smi and connect_status parameters are supplied then the
* connect_status channel will output when the link goes up or down.
* The channel will output a zero byte, followed by the status (1 for up,
* 0 for down), followed by a zero byte, followed by an END control token.,
*
* The following code snippet is an example of how to receive this update:
*
* \verbatim
* (void) inuchar(connect_status);
* new_status = inuchar(c);
* (void) inuchar(c, 0);
* (void) inct(c);
* \endverbatim
**/
void ethernet_server_two_port(mii_interface_t &mii1,
mii_interface_t &mii2,
chanend rx[],
int num_rx,
chanend tx[],
int num_tx,
smi_interface_t &?smi1,
smi_interface_t &?smi2,
chanend ?connect_status,
CLIENT_INTERFACE(configInterface, iConfigFilter),
CLIENT_INTERFACE(configInterface, iConfigRx),
CLIENT_INTERFACE(configInterface, iConfigTx));
Thanks
Armin