<commit_before>#! /bin/sh
##########################################################################
# If not stated otherwise in this file or this component's Licenses.txt
# file the following copyright and licenses apply:
#
# Copyright 2016 RDK Management
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
##########################################################################
. /etc/include.properties
. $RDK_PATH/utils.sh
. /etc/device.properties
if [ $# -eq 0 ]; then
    echo " `/bin/timestamp` Interface not provided"
    exit 1
fi

sysctl -w "net.ipv6.conf.all.forwarding=1"
sysctl -w "net.ipv6.conf.default.forwarding=1"

if [ "$IPV6_INTERFACE" ];then
     ESTB_INTERFACE=$IPV6_INTERFACE
fi

sysctl -w "net.ipv6.conf.$ESTB_INTERFACE.accept_ra=2"
sysctl -w "net.ipv6.conf.$ESTB_INTERFACE.autoconf=0"

interface=$1

# Clear any gloabal prefix address is present
currentGlobalIp=`ifconfig $interface | grep inet6 | grep -i "Global" | tr -s ' ' | cut -d ' ' -f4`
if [ ! -z  "$currentGlobalIp" ]; then
     echo " `/bin/timestamp` Clearing existing prefix $currentGlobalIp from interface $interface"
    /sbin/ip -6 addr del $currentGlobalIp dev $interface
fi


v6prefixfile=/tmp/dibbler/client-AddrMgr.xml
globalip=`grep -F "AddrPrefix" $v6prefixfile | cut -d ">" -f2 | cut -d "<" -f1 `
while [ -z "$globalip" ]
do
     	sleep 10
	echo " `/bin/timestamp`  sleeping for getting prefix "
	globalip=`grep -F "AddrPrefix" $v6prefixfile | cut -d ">" -f2 | cut -d "<" -f1 `
done

if [ -f $v6prefixfile ]; then
    echo "============================================="
    t1t2Timeout=`grep -i 'AddrIA unicast' $v6prefixfile`
    lifeTime=`grep -i 'AddrAddr timestamp' $v6prefixfile`
    duid=`cat /tmp/dibbler/client-duid`
    echo "dhcp server response "
    echo "$t1t2Timeout"
    echo "$lifeTime"
    echo "DUID : $duid"
    echo "============================================="
fi

echo " `/bin/timestamp` prefix = $globalip "
# Save current prefix for tracking ipv6 prefix changes  
echo "$globalip" > /tmp/ipv6_global_prefix.txt
num='1'
globalip=$globalip$num
echo " `/bin/timestamp` Adding existing prefix $globalip for interface $interface"
ip -6 addr add $globalip/64 dev $interface
<commit_msg>Fix delay when response file is not present<commit_after>#! /bin/sh
##########################################################################
# If not stated otherwise in this file or this component's Licenses.txt
# file the following copyright and licenses apply:
#
# Copyright 2016 RDK Management
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
##########################################################################
. /etc/include.properties
. $RDK_PATH/utils.sh
. /etc/device.properties
if [ $# -eq 0 ]; then
    echo " `/bin/timestamp` Interface not provided"
    exit 1
fi

sysctl -w "net.ipv6.conf.all.forwarding=1"
sysctl -w "net.ipv6.conf.default.forwarding=1"

if [ "$IPV6_INTERFACE" ];then
     ESTB_INTERFACE=$IPV6_INTERFACE
fi

sysctl -w "net.ipv6.conf.$ESTB_INTERFACE.accept_ra=2"
sysctl -w "net.ipv6.conf.$ESTB_INTERFACE.autoconf=0"

interface=$1

# Clear any gloabal prefix address is present
currentGlobalIp=`ifconfig $interface | grep inet6 | grep -i "Global" | tr -s ' ' | cut -d ' ' -f4`
if [ ! -z  "$currentGlobalIp" ]; then
     echo " `/bin/timestamp` Clearing existing prefix $currentGlobalIp from interface $interface"
    /sbin/ip -6 addr del $currentGlobalIp dev $interface
fi


v6prefixfile=/tmp/dibbler/client-AddrMgr.xml
if [ -f $v6prefixfile ]; then
    globalip=`grep -F "AddrPrefix" $v6prefixfile | cut -d ">" -f2 | cut -d "<" -f1 `
fi

# Limit the retries. If IP not acquired for more than max retries restart dibbler
retry=0
MAX_RETRY=12
while [ -z "$globalip" ] && [ $retry -lt $MAX_RETRY ]
do
     	sleep 10
        retry=`expr $retry + 1`
	echo " `/bin/timestamp`  sleeping for getting prefix "
        if [ -f $v6prefixfile ]; then
	    globalip=`grep -F "AddrPrefix" $v6prefixfile | cut -d ">" -f2 | cut -d "<" -f1 `
        fi
done

if [ $retry -ge $MAX_RETRY ]; then
    echo " `/bin/timestamp` Delay in getting response from DHCP server. Attempting to restart dibbler client "
    # Recovery mechanism restarts dibbler-client
    dibbler-client stop 
    exit 1
fi

if [ -f $v6prefixfile ]; then
    echo "============================================="
    t1t2Timeout=`grep -i 'AddrIA unicast' $v6prefixfile`
    lifeTime=`grep -i 'AddrAddr timestamp' $v6prefixfile`
    duid=`cat /tmp/dibbler/client-duid`
    echo "dhcp server response "
    echo "$t1t2Timeout"
    echo "$lifeTime"
    echo "DUID : $duid"
    echo "============================================="
fi

echo " `/bin/timestamp` prefix = $globalip "
# Save current prefix for tracking ipv6 prefix changes  
echo "$globalip" > /tmp/ipv6_global_prefix.txt
num='1'
globalip=$globalip$num
echo " `/bin/timestamp` Adding existing prefix $globalip for interface $interface"
ip -6 addr add $globalip/64 dev $interface

{'fraction_non_alphanumeric': 0.18559837728194725, 'fraction_numerical': 0.016734279918864097, 'mean_word_length': 4.096468561584841, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 2}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2179554', 'n_tokens_mistral': 1898, 'n_tokens_neox': 1839, 'n_words': 611}