1#!/bin/sh 2# 3# Copyright (c) 2018 Intel Corporation 4# 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 8# 9# http://www.apache.org/licenses/LICENSE-2.0 10# 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. 16 17# This script is called by native-posix board when TAP network interface 18# is taken up by Zephyr. The script should setup the host system so that 19# connectivity will work with Zephyr. 20 21while [ $# -gt 0 ]; do 22 case "$1" in 23 -f|--file) 24 CONF_FILE="$2" 25 shift 26 shift;; 27 -i|--interface) 28 # Only first -i option is taken into account. This way 29 # the driver added -i option is ignored if user has specified 30 # the -i option to host setup script command. 31 if [ -z "$IFACE" ]; then 32 IFACE="$2" 33 fi 34 shift 35 shift;; 36 *) 37 shift;; 38 esac 39done 40 41if [ `id -u` != 0 ]; then 42 echo "Warning: This script will need admin rights to setup \ 43network interface!" 44fi 45 46if [ -z "$IFACE" ]; then 47 IFACE="zeth" 48fi 49 50if [ -z "$CONF_FILE" ]; then 51 DIR=`dirname $0` 52 CONF_FILE="$DIR/net_setup_host.conf" 53fi 54 55if [ -f "$CONF_FILE" ]; then 56 . $CONF_FILE 57else 58 echo "Warning: config file $CONF_FILE does not exist!" 59fi 60 61ip link set dev $IFACE up 62 63if [ ! -z "$HWADDR" ]; then 64 ip link set dev $IFACE address $HWADDR 65fi 66 67if [ ! -z "$IPV6_ADDR_1" ]; then 68 ip -6 address add $IPV6_ADDR_1 dev $IFACE 69fi 70 71if [ ! -z "$IPV6_ROUTE_1" ]; then 72 ip -6 route add $IPV6_ROUTE_1 dev $IFACE 73fi 74 75if [ ! -z "$IPV4_ADDR_1" ]; then 76 ip address add $IPV4_ADDR_1 dev $IFACE 77fi 78 79if [ ! -z "$IPV4_ROUTE_1" ]; then 80 ip route add $IPV4_ROUTE_1 dev $IFACE 81fi 82