2 Copyright (c) 2019 AT&T Intellectual Property.
3 Copyright (c) 2019 Nokia.
5 Licensed under the Apache License, Version 2.0 (the "License");
6 you may not use this file except in compliance with the License.
7 You may obtain a copy of the License at
9 http://www.apache.org/licenses/LICENSE-2.0
11 Unless required by applicable law or agreed to in writing, software
12 distributed under the License is distributed on an "AS IS" BASIS,
13 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 See the License for the specific language governing permissions and
15 limitations under the License.
19 # Launch the e2 simulator on ${E2SIM_BIND_ADDR}:${E2SIM_BIND_PORT}
20 # If E2SIM_BIND_ADDR is not supplied, picks the address of the interface
21 # associated with the default route for E2SIM_BIND_AF (either
22 # "inet" [default] or "inet6").
24 if [ -z "${E2SIM_BIND_ADDR}" ]; then
25 if [ `echo "x${E2SIM_BIND_AF}x" | tr [A-Z] [a-z]` != "xinet6x" ]; then
32 LO='00:00:00:00:00:00'
34 if [ -z "${E2SIM_BIND_IF}" ]; then
35 # bind on the address associated with the default route
36 E2SIM_BIND_IF=`ip -br -f ${AF} route show ${DEFROUTE}| sed 's/.*dev[\ ]*\([^\ ]*\).*/\1/'`
37 if [ -z ${E2SIM_BIND_IF} ]; then
38 # this is kinda bogus, but it's the only real fallback: take the first
39 # non-loopback interface.
40 E2SIM_BIND_IF=`ip -f ${AF} -o link list up | grep -v LOOPBACK | head -1 |awk -F: '{print $2}'`
43 E2SIM_BIND_ADDR=`ip -f ${AF} -o addr show ${E2SIM_BIND_IF:-eth0} scope global | sed -e 's/.*inet[6\ ]*\([^\ ]*\)\/.*/\1/'`
46 if [ -z $E2SIM_BIND_ADDR ]; then
47 # search failed. be nondestructively useless.
48 echo "No suitable address found, binding on loopback addess ${LO}"
51 echo "e2sim starting at ${E2SIM_BIND_ADDR}:${E2SIM_PORT:-36421}"
54 ${E2SIM:-/home/e2sim/build/e2sim} ${E2SIM_BIND_ADDR} ${E2SIM_PORT:-36421}