Skip to content
Snippets Groups Projects
Commit 2141e10b authored by Florian Pose's avatar Florian Pose
Browse files

Configuring EoE bridge at startup.

parent 55f64546
No related branches found
No related tags found
No related merge requests found
......@@ -66,14 +66,14 @@ case "$1" in
start)
echo -n "Starting EtherCAT master "
if [ ! $DEVICE_INDEX ]; then
if [ -z "$DEVICE_INDEX" ]; then
echo "ERROR: DEVICE_INDEX not set!"
/bin/false
rc_status -v
rc_exit
fi
if [ ! $EOE_DEVICES ]; then
if [ -z "$EOE_DEVICES" ]; then
EOE_DEVICES=0
fi
......@@ -99,6 +99,50 @@ case "$1" in
rc_exit
fi
# Build EoE bridge
if [ -n "$EOE_BRIDGE" ]; then
EOE_INTERFACES=`/sbin/ifconfig -a | grep -o -E "^eoe[0-9]+ "`
# add bridge, if it does not already exist
if ! /sbin/brctl show | grep -E -q "^$EOE_BRIDGE"; then
if ! /sbin/brctl addbr $EOE_BRIDGE; then
/bin/false
rc_status -v
rc_exit
fi
fi
# free all interfaces of their addresses and add them to the bridge
for interface in $EOE_INTERFACES $EOE_EXTRA_INTERFACES; do
if ! /sbin/ifconfig $interface 0.0.0.0 up; then
/bin/false
rc_status -v
rc_exit
fi
if ! /sbin/brctl show | grep -E -q "^$EOE_BRIDGE.*$interface"; then
if ! /sbin/brctl addif $EOE_BRIDGE $interface; then
/bin/false
rc_status -v
rc_exit
fi
fi
done
if [ -n "$EOE_IP_ADDRESS" -a -n "$EOE_IP_NETMASK" ]; then
if ! /sbin/ifconfig $EOE_BRIDGE $EOE_IP_ADDRESS \
netmask $EOE_IP_NETMASK; then
/bin/false
rc_status -v
rc_exit
fi
fi
if ! /sbin/ifconfig $EOE_BRIDGE up; then
/bin/false
rc_status -v
rc_exit
fi
fi
rc_status -v
;;
......
......@@ -18,4 +18,34 @@
#
#EOE_DEVICES=0
#
# Bridge all EoE interfaces after master startup
# This variable shall contain the name of the EoE bridge to set up.
# If the variable is empty or undefined, no EoE bridge will be built.
#
#EOE_BRIDGE=eoebr0
#
# IP address of the EoE bridge
# Set both EOE_IP_ADDRESS and EOE_IP_NETMASK to let the local host communicate
# with devices on the EoE bridge.
#
#EOE_IP_ADDRESS=192.168.X.X
#
# IP netmask of the EoE bridge
# See EOE_IP_ADDRESS.
#
#EOE_IP_NETMASK=255.255.255.0
#
# List of extra interfaces to include in the EoE bridge.
# Set this to interconnect the EoE bridge with other local interfaces.
# If EOE_BRIDGE is empty or undefined, setting this variable has no effect.
# Important: The IP address of these interfaces will be cleared. Set
# EOE_IP_ADDRESS and EOE_IP_NETMASK accordingly to enable IP traffic to
# extra interfaces.
#
#EOE_EXTRA_INTERFACES=eth0
#------------------------------------------------------------------------------
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment