Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 15 additions & 9 deletions source/scripts/init/service.d/lan_handler.sh
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,9 @@ case "$1" in
fi
;;
ipv4_*-status)
echo_t "LAN HANDLER : Received $1 event with status $2"
if [ x"up" = x${2} ]; then
echo_t "LAN HANDLER : Handling LAN up event for instance ${1}"
INST=${1#*_}
INST=${INST%-*}
RG_MODE=`syscfg get last_erouter_mode`
Expand All @@ -184,12 +186,14 @@ case "$1" in


if [ xbrlan0 = x${LAN_IFNAME} ]; then
echo_t "LAN HANDLER : Handling LAN up event for brlan0, configuring IPv6 address if needed"
SYSEVT_lan_ipaddr_v6_prev=`sysevent get lan_ipaddr_v6_prev`

if [ "1" = "$(sysevent get ula_ipv6_enabled)" ] && [ "1" != "$(syscfg get Device_Mode)" ]; then
SYSEVT_lan_ipaddr_v6=$(sysevent get ipv6_prefix_ula | cut -d "/" -f 1)
SYSEVT_lan_ipaddr_v6=${SYSEVT_lan_ipaddr_v6}1
else
echo_t "LAN HANDLER : Using global IPv6 address for LAN"
SYSEVT_lan_ipaddr_v6=`sysevent get lan_ipaddr_v6`
fi
SYSEVT_lan_prefix_v6=`sysevent get lan_prefix_v6`
Expand Down Expand Up @@ -255,6 +259,7 @@ case "$1" in
elif [ x"ready" != x`sysevent get start-misc` ] && ( [ "$MANUFACTURE" = "Technicolor" ] || [ "$MANUFACTURE" = "Sercomm" ] ) ; then
#TCH XBx/TCCBR based startup post.d scripts which includes Firewall restart and dhcp start.
sysevent set lan-status started
echo_t "LAN HANDLER : lan status set to started"
firewall
if [ ! -f "$POSTD_START_FILE" ];
then
Expand All @@ -264,6 +269,7 @@ case "$1" in
else
echo_t "LAN HANDLER : Triggering DHCP server using LAN status"
sysevent set lan-status started
echo_t "LAN HANDLER : lan status set to started"
echo_t "LAN HANDLER : Triggering RDKB_FIREWALL_RESTART"
t2CountNotify "RF_INFO_RDKB_FIREWALL_RESTART"
sysevent set firewall-restart
Expand Down Expand Up @@ -314,6 +320,8 @@ case "$1" in
sysevent set firewall-restart
if [ -e "/usr/bin/print_uptime" ]; then
/usr/bin/print_uptime "Laninit_complete"
echo_t "LAN HANDLER : Laninit_complete uptime: $(cut -d. -f1 /proc/uptime)"
echo_t "LAN HANDLER : Checking lan-status after lan init complete, lan-status = $(sysevent get lan-status)"
fi

uptime=$(cut -d. -f1 /proc/uptime)
Expand Down Expand Up @@ -344,7 +352,7 @@ case "$1" in
pnm-status | bring-lan)
if [ -e "/usr/bin/print_uptime" ]; then
/usr/bin/print_uptime "Lan_init_start"
fi
fi
uptime=$(cut -d. -f1 /proc/uptime)
if [ -e "/usr/bin/onboarding_log" ]; then
/usr/bin/onboarding_log "Lan_init_start:$uptime"
Expand All @@ -354,7 +362,6 @@ case "$1" in
if [ -z "$INST" ]
then
echo_t "THE INSTANT=$INST"
echo_t "THE INSTANT=$INST"
#(use a simpler test than this -- but Hacky, since it assumes everything we want is not XB3!!)if [ "$BOX_TYPE" = "TCCBR" ] || [ "$BOX_TYPE" = "XB6" -a "$MANUFACTURE" = "Technicolor" ] || [ "$BOX_TYPE" = "XB7" -a "$MANUFACTURE" = "Technicolor" ] ; then
if ( [ "$BOX_TYPE" != "XB3" ] && ( [ "$MANUFACTURE" = "Technicolor" ] || [ "$MANUFACTURE" = "Sercomm" ] ) ) || [ "$BOX_TYPE" = "rpi" ] || [ "$BOX_TYPE" = "bpi" ]; then
COUNTER=1
Expand All @@ -371,7 +378,7 @@ case "$1" in
echo_t "THE COUNTER =$COUNTER"
done
else
echo_t "RDKB_SYSTEM_BOOT_UP_LOG : INST rerurned null, retrying"
echo_t "RDKB_SYSTEM_BOOT_UP_LOG : INST returned null, retrying"
INST=`psmcli get dmsb.MultiLAN.PrimaryLAN_l3net`
fi

Expand Down Expand Up @@ -436,11 +443,10 @@ case "$1" in
sysevent set primary_lan_l3net $L3NET
fi
fi
elif [ "$BOX_TYPE" = "TCCBR" ]; then
if [ -z "$INST" ]; then
echo "*****SET THE PRIMARY LAN ******" > /dev/null
syseven set primary_lan_l3net 4
fi
fi
if [ -z "$INST" ] && [ "$BOX_TYPE" = "TCCBR" ]; then
echo_t "INST is empty on TCCBR; defaulting primary_lan_l3net to 4"
sysevent set primary_lan_l3net 4
fi

fi
Expand Down Expand Up @@ -565,4 +571,4 @@ case "$1" in
echo "Usage: service-${SERVICE_NAME} [ ${SERVICE_NAME}-start | ${SERVICE_NAME}-stop | ${SERVICE_NAME}-restart]" > /dev/console
exit 3
;;
esac
esac
50 changes: 49 additions & 1 deletion source/scripts/init/service.d/service_lan.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,15 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#######################################################################
log() {
local level="$1"; shift
local message="$*"
local timestamp
local log_file
timestamp=$(date +'%Y-%m-%d %H:%M:%S')
log_file="/tmp/service_lan.log"
echo "$timestamp [$level] $message" | tee -a "$log_file"
Comment on lines +37 to +43
Comment on lines +40 to +43
Comment on lines +40 to +43
}
Comment on lines +36 to +44
Comment on lines +36 to +44
Comment on lines +36 to +44

source /etc/utopia/service.d/interface_functions.sh
source /etc/utopia/service.d/ulog_functions.sh
Expand All @@ -45,6 +54,9 @@ source /lib/rdk/t2Shared_api.sh

SERVICE_NAME="lan"

log INFO "Script started."
echo_t "service_lan: Script started."

subnet() {
if [ "$2" ]; then
NM="$2"
Expand Down Expand Up @@ -664,26 +676,43 @@ service_start ()
{
# echo "lan service start called" > /dev/console
#song: register_docsis_handler
log INFO "Starting LAN service"
echo_t "service_lan: Starting LAN service"
wait_till_end_state ${SERVICE_NAME}

CcspHome_Security=`sysevent get HomeSecuritySupport`
STATUS=`sysevent get ${SERVICE_NAME}-status`
echo_t "Current LAN service status: $STATUS"
log INFO "Current LAN service status: $STATUS"
if [ "started" != "$STATUS" ] ; then
sysevent set ${SERVICE_NAME}-errinfo
sysevent set ${SERVICE_NAME}-status starting
log INFO "LAN service status set to starting"
echo_t "service_lan: LAN service status set to starting"

log INFO "LAN interfaces: $LAN_IFNAMES"
echo_t "service_lan: LAN interfaces: $LAN_IFNAMES"
if [ -n "$LAN_IFNAMES" ]; then
log INFO "Bringing up LAN with bridge"
echo_t "service_lan : Bringing up LAN with bridge"
do_start
else
log INFO "Bringing up LAN without bridge"
echo_t "service_lan : Bringing up LAN without bridge"
do_start_no_bridge
fi
ERR=$?
if [ "$ERR" -ne "0" ] ; then
log ERROR "Unable to bringup lan, error code: $ERR"
echo_t "service_lan : Unable to bringup lan, error code: $ERR"
check_err $? "Unable to bringup lan"
elif [ "" = "$SYSCFG_lan_dhcp_client" -o "0" = "$SYSCFG_lan_dhcp_client" ] ; then
log INFO "LAN service started successfully, setting status to started"
sysevent set ${SERVICE_NAME}-errinfo
sysevent set ${SERVICE_NAME}-status started
#song: add_docsis_bridge
echo_t "service_lan : Triggering RDKB_FIREWALL_RESTART"
log INFO "Triggering RDKB_FIREWALL_RESTART"
t2CountNotify "SYS_SH_RDKB_FIREWALL_RESTART"
sysevent set firewall-restart
fi
Expand Down Expand Up @@ -715,25 +744,44 @@ service_start ()
#--------------------------------------------------------------
service_stop ()
{
log INFO "Stopping LAN service"
echo_t "service_lan: Stopping LAN service"
wait_till_end_state ${SERVICE_NAME}

STATUS=`sysevent get ${SERVICE_NAME}-status`
STATUS=`sysevent get ${SERVICE_NAME}-status`
echo_t "Current LAN service status: $STATUS"
log INFO "Current LAN service status: $STATUS"
if [ "stopped" != "$STATUS" ] ; then
sysevent set ${SERVICE_NAME}-errinfo
sysevent set ${SERVICE_NAME}-status stopping
log INFO "LAN service status set to stopping"
echo_t "service_lan: LAN service status set to stopping"

log INFO "LAN interfaces: $LAN_IFNAMES"
echo_t "service_lan: LAN interfaces: $LAN_IFNAMES"
if [ -n "$LAN_IFNAMES" ]; then
do_stop
log INFO "Bringing down LAN with bridge"
echo_t "service_lan: Bringing down LAN with bridge"
else
do_stop_no_bridge
log INFO "Bringing down LAN without bridge"
echo_t "service_lan: Bringing down LAN without bridge"
fi
ERR=$?
if [ "$ERR" -ne "0" ] ; then
check_err $ERR "Unable to teardown lan"
log ERROR "Unable to teardown lan, error code: $ERR"
echo_t "service_lan: Unable to teardown lan, error code: $ERR"
elif [ "" = "$SYSCFG_lan_dhcp_client" -o "0" = "$SYSCFG_lan_dhcp_client" ] ; then
log INFO "LAN service stopped successfully, setting status to stopped"
echo_t "service_lan: LAN service stopped successfully, setting status to stopped"
sysevent set ${SERVICE_NAME}-errinfo
sysevent set ${SERVICE_NAME}-status stopped
fi
#unregister wecb_master from pmon to let this script to bring it up when lan restart.
log INFO "Unregistering wecb_master from pmon"
echo_t "service_lan : Unregistering web_master from pmon"
/etc/utopia/service.d/pmon.sh unregister wecb_master
#rongwei added
# killall wecb_master 2>/dev/null
Expand Down
18 changes: 18 additions & 0 deletions source/scripts/init/service.d/service_routed.sh
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,19 @@

source /etc/device.properties

log() {
local level="$1"; shift
local message="$*"
local timestamp
local log_file
timestamp=$(date +'%Y-%m-%d %H:%M:%S')
log_file="/tmp/service_routed.log"
echo "$timestamp [$level] $message" | tee -a "$log_file"
Comment on lines +48 to +51
Comment on lines +48 to +51
}
Comment on lines +44 to +52
Comment on lines +44 to +52
Comment on lines +44 to +52

# Start logging
log INFO "Script started."

SERVICE_NAME="routed"
LANULASupport=`sysevent get LANULASupport`
case "$1" in
Expand All @@ -59,19 +72,24 @@ case "$1" in
wan-status)
status=$(sysevent get wan-status)
if [ "$status" == "started" ]; then
log INFO "WAN status started. Starting routed service."
Comment on lines 44 to +75
service_routed start
Comment on lines 44 to 76
elif [ "$status" == "stopped" ]; then
Comment on lines 74 to 77
log INFO "WAN status stopped. Stopping routed service."
service_routed stop
fi
;;
lan-status)
status=$(sysevent get lan-status)
if [ "$status" == "started" ]; then
log INFO "LAN status started. Starting routed service."
service_routed start
if [ "$BOX_TYPE" == "WNXL11BWL" ]; then
log INFO "LAN status started. Starting zebra"
Comment on lines 84 to +88
service_routed radv-start
fi
elif [ "$status" == "stopped" ]; then
Comment on lines 74 to 91
log INFO "LAN status stopped. Stopping routed service."
# As per Sky requirement, radvd should run with ULA prefix though the wan-status is down
if [ "$BOX_TYPE" != "HUB4" ] && [ "$BOX_TYPE" != "SR300" ] && [ "$BOX_TYPE" != "SE501" ] && [ "$BOX_TYPE" != "SR213" ] && [ "$BOX_TYPE" != "WNXL11BWL" ] && [ "$LANULASupport" != "true" ]; then
service_routed stop
Expand Down
26 changes: 26 additions & 0 deletions source/service_deviceMode/service_devicemode.c
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,21 @@
#endif
#include "print_uptime.h"

#define LOG_FILE_ROUTED "/tmp/service_deviceMode.txt"
#define APPLY_PRINT(fmt ...) {\
FILE *logfp = fopen(LOG_FILE_ROUTED , "a+");\
Comment on lines +76 to +77
if (logfp){\
time_t s = time(NULL);\
Comment on lines +75 to +79
struct tm* current_time = localtime(&s);\
fprintf(logfp, "[%02d:%02d:%02d] ",\
current_time->tm_hour,\
current_time->tm_min,\
current_time->tm_sec);\
fprintf(logfp, fmt);\
fclose(logfp);\
Comment on lines +75 to +86
}\
Comment on lines +76 to +87
}\
Comment on lines +75 to +88
Comment on lines +75 to +88
Comment on lines +75 to +88

Comment on lines +76 to +89
#ifndef RETURN_OK
#define RETURN_OK 0
#endif
Expand Down Expand Up @@ -304,18 +319,21 @@

int service_stop(int mode)
{
APPLY_PRINT("%s : Stopping services for mode %d\n", __FUNCTION___, mode);

Check failure

Code scanning / CodeQL

Use of potentially dangerous function Critical

Call to 'localtime' is potentially dangerous.

Check failure

Code scanning / CodeQL

File created without restricting permissions High

A file may be created here with mode 0666, which would make it world-writable.
char buf[256];
Comment on lines 320 to 323
memset(buf,0,sizeof(buf));
switch(mode)
{
case DEVICE_MODE_ROUTER:
{
APPLY_PRINT("%s : Stopping Router Mode Services\n", __FUNCTION__);

Check failure

Code scanning / CodeQL

Use of potentially dangerous function Critical

Call to 'localtime' is potentially dangerous.

Check failure

Code scanning / CodeQL

File created without restricting permissions High

A file may be created here with mode 0666, which would make it world-writable.
sysevent_set(sysevent_fd, sysevent_token, "lan-stop", "", 0);
sysevent_set(sysevent_fd, sysevent_token, "ipv4-down", "5", 0);
#if defined (_COSA_BCM_ARM_)
sysevent_set(sysevent_fd, sysevent_token, "wan-stop", "", 0);
#endif
//lte-1312
APPLY_PRINT("%s : Stopping zebra Process\n", __FUNCTION__);

Check failure

Code scanning / CodeQL

Use of potentially dangerous function Critical

Call to 'localtime' is potentially dangerous.

Check failure

Code scanning / CodeQL

File created without restricting permissions High

A file may be created here with mode 0666, which would make it world-writable.
runCommandInShellBlocking("killall zebra");
snprintf(buf,sizeof(buf),"execute_dir %s stop", ROUTER_MODE_SERVICES_PATH_1);
runCommandInShellBlocking(buf);
Expand Down Expand Up @@ -375,13 +393,15 @@

int service_start(int mode)
{
APPLY_PRINT("%s : Starting services for mode %d\n", __FUNCTION__, mode);

Check failure

Code scanning / CodeQL

Use of potentially dangerous function Critical

Call to 'localtime' is potentially dangerous.

Check failure

Code scanning / CodeQL

File created without restricting permissions High

A file may be created here with mode 0666, which would make it world-writable.
char buf[256];
memset(buf,0,sizeof(buf));
int rc = -1;
switch(mode)
{
case DEVICE_MODE_ROUTER:
{
APPLY_PRINT("%s : Starting Router Mode Services\n", __FUNCTION__);

Check failure

Code scanning / CodeQL

Use of potentially dangerous function Critical

Call to 'localtime' is potentially dangerous.

Check failure

Code scanning / CodeQL

File created without restricting permissions High

A file may be created here with mode 0666, which would make it world-writable.
int bridgemode = 0;
if( 0 == syscfg_get( NULL, "bridge_mode", buf, sizeof(buf) ) )
{
Expand All @@ -391,14 +411,17 @@
runCommandInShellBlocking(buf);
if (bridgemode == 0)
{
APPLY_PRINT("%s : Starting LAN in Router mode\n", __FUNCTION__);

Check failure

Code scanning / CodeQL

Use of potentially dangerous function Critical

Call to 'localtime' is potentially dangerous.

Check failure

Code scanning / CodeQL

File created without restricting permissions High

A file may be created here with mode 0666, which would make it world-writable.
sysevent_set(sysevent_fd, sysevent_token, "lan-start", "", 0);
}
else
{
APPLY_PRINT("%s : Starting Bridge\n", __FUNCTION__);

Check failure

Code scanning / CodeQL

Use of potentially dangerous function Critical

Call to 'localtime' is potentially dangerous.

Check failure

Code scanning / CodeQL

File created without restricting permissions High

A file may be created here with mode 0666, which would make it world-writable.
sysevent_set(sysevent_fd, sysevent_token, "bridge-start", "", 0);
}
// Do wan start only in XB technicolor for xb->xb backup wan testing.
#if defined (_COSA_BCM_ARM_)
APPLY_PRINT("%s : Starting WAN\n", __FUNCTION__);
sysevent_set(sysevent_fd, sysevent_token, "wan-start", "", 0);
#endif
// start ipv4 for XHS
Expand All @@ -418,14 +441,17 @@
#endif
runCommandInShellBlocking("systemctl restart CcspLMLite.service");
#if !defined(_WNXL11BWL_PRODUCT_REQ_)
APPLY_PRINT("%s : Restarting zebra Process\n", __FUNCTION__);

Check failure

Code scanning / CodeQL

Use of potentially dangerous function Critical

Call to 'localtime' is potentially dangerous.

Check failure

Code scanning / CodeQL

File created without restricting permissions High

A file may be created here with mode 0666, which would make it world-writable.
sysevent_set(sysevent_fd, sysevent_token, "zebra-restart", "", 0);
#endif
}
break;
case DEVICE_MODE_EXTENDER:
{
APPLY_PRINT("%s : Starting Extender Mode Services\n", __FUNCTION__);

Check failure

Code scanning / CodeQL

Use of potentially dangerous function Critical

Call to 'localtime' is potentially dangerous.

Check failure

Code scanning / CodeQL

File created without restricting permissions High

A file may be created here with mode 0666, which would make it world-writable.
char tmpbuf[64] = {0};
//lte-1312
APPLY_PRINT("%s : Stopping zebra Process if running\n", __FUNCTION__);

Check failure

Code scanning / CodeQL

Use of potentially dangerous function Critical

Call to 'localtime' is potentially dangerous.

Check failure

Code scanning / CodeQL

File created without restricting permissions High

A file may be created here with mode 0666, which would make it world-writable.
runCommandInShellBlocking("killall zebra");
sysevent_set(sysevent_fd, sysevent_token, "lan-start", "", 0);
sysevent_set(sysevent_fd, sysevent_token, "lan_status-dhcp", "started", 0);
Expand Down
Loading
Loading