OpenCores
URL https://opencores.org/ocsvn/nemo_emotion/nemo_emotion/trunk

Subversion Repositories nemo_emotion

[/] [nemo_emotion/] [trunk/] [mobile-ip6] - Blame information for rev 4

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 3 mowgly
#!/bin/sh
2
#
3
# Modified in order to implement the NEMO Basic Support Protocol
4
# Nicolas Kerneis 
5
# Laurent Monminoux 
6
#
7
# Load MIPL Mobile IPv6 module
8
#
9
# chkconfig: 345 75 05
10
# description: Automatically loads MIPL Mobile IPv6 kernel module and
11
# configures it. See http://www.mipl.mediapoli.com/ for more information.
12
# config: /etc/sysconfig/network-mip6.conf
13
#
14
# Generated automatically from mobile-ip6.in by configure.
15
 
16
MIPV6_BASE_MODULE=mip6_base
17
MIPV6_MN_MODULE=mip6_mn
18
MIPV6_HA_MODULE=mip6_ha
19
MIPV6_MODULE=
20
 
21
prefix=
22
exec_prefix=${prefix}
23
initdir=/etc/rc.d/init.d
24
sysconfdir=${prefix}/etc
25
 
26
CONFIG_FILE=/etc/sysconfig/network-mip6.conf
27
MIPDIAG=${exec_prefix}/sbin/mipdiag
28
SUBSYS=$1
29
LOCKDIR=/var/lock/subsys
30
 
31
MODPROBE=${exec_prefix}/sbin/modprobe
32
LSMOD=${exec_prefix}/sbin/lsmod
33
 
34
# Test if 'functions' exists. If not, define our own 'action'
35
if test -x /etc/rc.d/init.d/functions ; then
36
    . /etc/rc.d/init.d/functions
37
elif test -x /etc/rc.config ; then
38
    . /etc/rc.config
39
else
40
    action() {
41
        msg=$1
42
        shift
43
        eval "$*" >/dev/null 2>&1
44
        ret=$?
45
        if test $ret = 0 -a "x$*" != "x" ; then
46
            msg=$msg" OK"
47
        else
48
            msg=$msg" Failed"
49
        fi
50
        logger $msg
51
        echo $msg
52
    }
53
fi
54
 
55
if [ -r $CONFIG_FILE ] ; then
56
    . $CONFIG_FILE
57
else
58
    echo "Cannot read configuration file: $CONFIG_FILE"
59
    exit 1
60
fi
61
 
62
for file in $MIPDIAG $MODPROBE $LSMOD ; do
63
    if [ ! -x $file ] ; then
64
        echo "Cannot execute: $file"
65
        exit 1
66
    fi
67
done
68
 
69
if [ "$FUNCTIONALITY" = "mn" ] ; then
70
    MIPV6_MODULE=$MIPV6_MN_MODULE
71
elif [ "$FUNCTIONALITY" = "ha" ] ; then
72
    MIPV6_MODULE=$MIPV6_HA_MODULE
73
else
74
    MIPV6_MODULE=$MIPV6_BASE_MODULE
75
fi
76
 
77
if [ -z "$HOMEADDRESS" -a "$FUNCTIONALITY" = "mn" ] ; then
78
    echo "Home address not set for mobile node"
79
    exit 1
80
fi
81
 
82
case "$1" in
83
    start)
84
        $LSMOD | grep $MIPV6_MODULE &>/dev/null && \
85
            echo "$MIPV6_MODULE already installed" && exit 1
86
 
87
        INSMOD_ARGS=
88
        # NEMO implementation
89
        INSMOD_MR_ARGS=
90
        INSMOD_HA_ARGS=
91
 
92
        if [ -n "$DEBUGLEVEL" ] ; then
93
            INSMOD_ARGS="$INSMOD_ARGS mipv6_debug=$DEBUGLEVEL"
94
        fi
95
 
96
        # NEMO implementation
97
        if [ "$MR" = "yes" ] ; then
98
            INSMOD_MR_ARGS="$INSMOD_MR_ARGS mipv6_is_MR=1"
99
        else
100
            INSMOD_MR_ARGS="$INSMOD_MR_ARGS mipv6_is_MR=0"
101
        fi
102
        # NEMO implementation
103
        if [ "$NEMO_HA_CAPABLE" = "yes" ] ; then
104
            INSMOD_HA_ARGS="$INSMOD_HA_ARGS nemo_ha_capability=1"
105
        else
106
            INSMOD_HA_ARGS="$INSMOD_HA_ARGS nemo_ha_capability=0"
107
        fi
108
 
109
        $MODPROBE $MIPV6_BASE_MODULE $INSMOD_ARGS &> /dev/null
110
        status=$?
111
 
112
        # NEMO implementation
113
        if [ "$FUNCTIONALITY" = "ha" ] ; then
114
            $MODPROBE $MIPV6_MODULE $INSMOD_HA_ARGS &> /dev/null
115
        fi
116
        # NEMO implementation
117
        if [ "$FUNCTIONALITY" = "mn" ] ; then
118
            $MODPROBE $MIPV6_MODULE $INSMOD_MR_ARGS &> /dev/null
119
        fi
120
 
121
        action "Starting Mobile IPv6:" [ $status -eq 0 ] || exit 1
122
 
123
        touch $LOCKDIR/mobile-ip6
124
 
125
        # Temporary kludge to control get the new sysctls working.
126
        # Should probably be integrated into mipdiag at some time.
127
 
128
        if [ "$FUNCTIONALITY" = "ha" ] ; then
129
            if [ -n "$MIN_TUNNEL_NR" ] ; then
130
                echo $MIN_TUNNEL_NR > /proc/sys/net/ipv6/mobility/min_tnls
131
            fi
132
 
133
            if [ -n "$MAX_TUNNEL_NR" ] ; then
134
                echo $MAX_TUNNEL_NR > /proc/sys/net/ipv6/mobility/max_tnls
135
            fi
136
        fi
137
 
138
        if [ "$FUNCTIONALITY" = "mn" ] ; then
139
            [ -n "$HOMEADDRESS" ] && \
140
            $MIPDIAG -i $HOMEDEV -h $HOMEADDRESS -H$HOMEAGENT
141
        fi
142
 
143
        if [ "$FUNCTIONALITY" = "ha" -a -n "$TUNNEL_SITELOCAL" ] ; then
144
            $MIPDIAG -t$TUNNEL_SITELOCAL
145
        fi
146
 
147
        if [ "$FUNCTIONALITY" = "ha" ] ; then
148
            echo 1 > /proc/sys/net/ipv6/conf/all/forwarding
149
        fi
150
        ;;
151
 
152
    stop)
153
        action "Stopping Mobile IPv6:" [ -f $LOCKDIR/mobile-ip6 ] || exit 1
154
 
155
        $MODPROBE -r $MIPV6_MODULE
156
 
157
        rm -f $LOCKDIR/mobile-ip6
158
        exit $?
159
        ;;
160
 
161
    restart)
162
        $0 stop
163
        $0 start
164
        exit $?
165
        ;;
166
 
167
    status)
168
        $LSMOD | grep $MIPV6_MODULE > /dev/null
169
        if [ $? -eq 0 ]; then
170
                echo "$MIPV6_MODULE module is installed..."
171
                exit 0
172
        fi
173
        # See if lock in $LOCKDIR exists
174
        if [ -f $LOCKDIR/mobile-ip6 ]; then
175
                echo "$MIPV6_MODULE module not installed but subsys locked"
176
                exit 2
177
        fi
178
 
179
        echo "$MIPV6_MODULE module is not installed"
180
        exit 3
181
        ;;
182
 
183
    *)
184
        echo "Usage mobile-ip6 {start|stop|status|restart}"
185
        exit 1
186
        ;;
187
esac

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.