diff --git a/source/scripts/init/c_registration/15_dhcpv6_client.c b/source/scripts/init/c_registration/15_dhcpv6_client.c index 0ec17f83..b33d10f1 100644 --- a/source/scripts/init/c_registration/15_dhcpv6_client.c +++ b/source/scripts/init/c_registration/15_dhcpv6_client.c @@ -57,7 +57,7 @@ const char* SERVICE_CUSTOM_EVENTS[] = { "lan-status|/usr/bin/service_dhcpv6_client", NULL }; -#elif defined(CISCO_CONFIG_DHCPV6_PREFIX_DELEGATION) +#elif defined(CISCO_CONFIG_DHCPV6_PREFIX_DELEGATION) || defined(_ONESTACK_PRODUCT_REQ_) const char* SERVICE_CUSTOM_EVENTS[] = { "erouter_mode-updated|/etc/utopia/service.d/service_dhcpv6_client.sh", "phylink_wan_state|/etc/utopia/service.d/service_dhcpv6_client.sh", diff --git a/source/scripts/init/c_registration/15_dhcpv6_server.c b/source/scripts/init/c_registration/15_dhcpv6_server.c index 0c45dfcd..02d341e9 100644 --- a/source/scripts/init/c_registration/15_dhcpv6_server.c +++ b/source/scripts/init/c_registration/15_dhcpv6_server.c @@ -35,10 +35,17 @@ #include #include "srvmgr.h" +#ifdef _ONESTACK_PRODUCT_REQ_ +#include +#endif const char* SERVICE_NAME = "dhcpv6_server"; const char* SERVICE_DEFAULT_HANDLER = "/etc/utopia/service.d/service_dhcpv6_server.sh"; +#if defined(_ONESTACK_PRODUCT_REQ_) +const char** SERVICE_CUSTOM_EVENTS = NULL; +#endif + #if defined(_CBR_PRODUCT_REQ_) && !defined(_CBR2_PRODUCT_REQ_) const char* SERVICE_CUSTOM_EVENTS[] = { "dhcpv6_option_changed|/usr/bin/service_ipv6", @@ -47,11 +54,29 @@ const char* SERVICE_CUSTOM_EVENTS[] = { "dhcpv6_server-restart|/usr/bin/service_ipv6", NULL }; -#elif defined (CISCO_CONFIG_DHCPV6_PREFIX_DELEGATION) +#elif defined(CISCO_CONFIG_DHCPV6_PREFIX_DELEGATION) const char* SERVICE_CUSTOM_EVENTS[] = { "dhcpv6_option_changed|/etc/utopia/service.d/service_dhcpv6_server.sh|NULL|"TUPLE_FLAG_EVENT, NULL }; +#elif defined(_ONESTACK_PRODUCT_REQ_) +const char* SERVICE_CUSTOM_EVENTS_RESIDENTIAL[] = { + "lan-status|/etc/utopia/service.d/service_dhcpv6_server.sh", + "ipv6_nameserver|/etc/utopia/service.d/service_dhcpv6_server.sh", + "ipv6_domain|/etc/utopia/service.d/service_dhcpv6_server.sh", + "ipv6_ntp_server|/etc/utopia/service.d/service_dhcpv6_server.sh", + "dhcp_domain|/etc/utopia/service.d/service_dhcpv6_server.sh", + "current_lan_ipv6address|/etc/utopia/service.d/service_dhcpv6_server.sh", + NULL + }; +const char* SERVICE_CUSTOM_EVENTS_BUSINESS[] = { + "dhcpv6_server-start|/etc/utopia/service.d/service_dhcpv6_server_bci.sh", + "dhcpv6_server-stop|/etc/utopia/service.d/service_dhcpv6_server_bci.sh", + "dhcpv6_server-restart|/etc/utopia/service.d/service_dhcpv6_server_bci.sh", + "ipv6_prefix_delegation|/etc/utopia/service.d/service_dhcpv6_server_bci.sh", + "dhcpv6_option_changed|/etc/utopia/service.d/service_dhcpv6_server_bci.sh|NULL|"TUPLE_FLAG_EVENT, + NULL + }; #else const char* SERVICE_CUSTOM_EVENTS[] = { "lan-status|/etc/utopia/service.d/service_dhcpv6_server.sh", @@ -64,8 +89,21 @@ const char* SERVICE_CUSTOM_EVENTS[] = { }; #endif +#if defined(_ONESTACK_PRODUCT_REQ_) +static void init_service_custom_events(void) +{ + if (isFeatureSupportedInCurrentMode(FEATURE_IPV6_DELEGATION)) { + SERVICE_CUSTOM_EVENTS = SERVICE_CUSTOM_EVENTS_BUSINESS; + } else { + SERVICE_CUSTOM_EVENTS = SERVICE_CUSTOM_EVENTS_RESIDENTIAL; + } +} +#endif void srv_register(void) { +#if defined(_ONESTACK_PRODUCT_REQ_) + init_service_custom_events(); +#endif sm_register(SERVICE_NAME, SERVICE_DEFAULT_HANDLER, SERVICE_CUSTOM_EVENTS); } diff --git a/source/scripts/init/c_registration/20_routing.c b/source/scripts/init/c_registration/20_routing.c index b68ce5fc..2386bcf6 100644 --- a/source/scripts/init/c_registration/20_routing.c +++ b/source/scripts/init/c_registration/20_routing.c @@ -40,11 +40,16 @@ #endif #include "srvmgr.h" #include "secure_wrapper.h" +#ifdef _ONESTACK_PRODUCT_REQ_ +#include +#endif #define SERVICE_NAME "routed" #define SERVICE_DEFAULT_HANDLER "/etc/utopia/service.d/service_routed.sh" - -#ifdef CISCO_CONFIG_DHCPV6_PREFIX_DELEGATION +#if defined(_ONESTACK_PRODUCT_REQ_) +const char** SERVICE_CUSTOM_EVENTS = NULL; +#endif +#if defined(CISCO_CONFIG_DHCPV6_PREFIX_DELEGATION) const char* SERVICE_CUSTOM_EVENTS[] = { "wan-status|/etc/utopia/service.d/service_routed.sh", "lan-status|/etc/utopia/service.d/service_routed.sh", @@ -54,6 +59,33 @@ const char* SERVICE_CUSTOM_EVENTS[] = { "staticroute-restart|/etc/utopia/service.d/service_routed.sh|NULL|"TUPLE_FLAG_EVENT, NULL }; +#elif defined(_ONESTACK_PRODUCT_REQ_) +const char* SERVICE_CUSTOM_EVENTS_RESIDENTIAL[] = { + "wan-status|/etc/utopia/service.d/service_routed.sh", + "lan-status|/etc/utopia/service.d/service_routed.sh", + "ipv6_nameserver|/etc/utopia/service.d/service_routed.sh", + "ipv6_prefix|/etc/utopia/service.d/service_routed.sh", + "ripd-restart|/etc/utopia/service.d/service_routed.sh|NULL|"TUPLE_FLAG_EVENT, + "zebra-restart|/etc/utopia/service.d/service_routed.sh|NULL|"TUPLE_FLAG_EVENT, + "staticroute-restart|/etc/utopia/service.d/service_routed.sh|NULL|"TUPLE_FLAG_EVENT, + #ifdef WAN_FAILOVER_SUPPORTED + "routeset-ula|/usr/bin/service_routed|NULL|"TUPLE_FLAG_EVENT, + "routeunset-ula|/usr/bin/service_routed|NULL|"TUPLE_FLAG_EVENT, + #endif + NULL + }; +const char* SERVICE_CUSTOM_EVENTS_BUSINESS[] = { + "wan-status|/etc/utopia/service.d/service_routed_bci.sh", + "lan-status|/etc/utopia/service.d/service_routed_bci.sh", + "dhcpv6_option_changed|/etc/utopia/service.d/service_routed_bci.sh|NULL|"TUPLE_FLAG_EVENT, + "ripd-restart|/etc/utopia/service.d/service_routed_bci.sh|NULL|"TUPLE_FLAG_EVENT, + "zebra-restart|/etc/utopia/service.d/service_routed_bci.sh|NULL|"TUPLE_FLAG_EVENT, + "staticroute-restart|/etc/utopia/service.d/service_routed_bci.sh|NULL|"TUPLE_FLAG_EVENT, + "ipv6_prefix_delegation|/etc/utopia/service.d/service_routed_bci.sh|NULL|"TUPLE_FLAG_EVENT, + NULL + }; + + #else const char* SERVICE_CUSTOM_EVENTS[] = { "wan-status|/etc/utopia/service.d/service_routed.sh", @@ -72,7 +104,21 @@ const char* SERVICE_CUSTOM_EVENTS[] = { #endif +#if defined(_ONESTACK_PRODUCT_REQ_) +static void init_service_custom_events(void) +{ + if (isFeatureSupportedInCurrentMode(FEATURE_IPV6_DELEGATION)) { + SERVICE_CUSTOM_EVENTS = SERVICE_CUSTOM_EVENTS_BUSINESS; + } else { + SERVICE_CUSTOM_EVENTS = SERVICE_CUSTOM_EVENTS_RESIDENTIAL; + } +} +#endif + void srv_register(void) { +#if defined(_ONESTACK_PRODUCT_REQ_) + init_service_custom_events(); +#endif // not sure is the rm is necessary anymore // system("rm -Rf /etc/iproute2/rt_tables"); DBG_PRINT("20_routing : %s Entry\n", __FUNCTION__); diff --git a/source/scripts/init/c_registration/Makefile.am b/source/scripts/init/c_registration/Makefile.am index ab532c93..f270b700 100644 --- a/source/scripts/init/c_registration/Makefile.am +++ b/source/scripts/init/c_registration/Makefile.am @@ -132,3 +132,6 @@ endif if ENABLE_HOTSPOT_SERVICE 15_hotspot_SOURCES = 15_hotspot.c endif +if ONESTACK_PRODUCT_REQ +LDFLAGS += -lrdkb_feature_mode_gate +endif diff --git a/source/scripts/init/service.d/service_dhcpv6_server_bci.sh b/source/scripts/init/service.d/service_dhcpv6_server_bci.sh index e83f1dc7..463fac25 100755 --- a/source/scripts/init/service.d/service_dhcpv6_server_bci.sh +++ b/source/scripts/init/service.d/service_dhcpv6_server_bci.sh @@ -262,21 +262,21 @@ service_init case "$1" in "${SERVICE_NAME}-start") -if [ "$MODEL_NUM" = "DPC3941B" ] || [ "$MODEL_NUM" = "DPC3939B" ] || [ "$MODEL_NUM" = "CGA4131COM" ] || [ "$MODEL_NUM" = "CGA4332COM" ]; then +if [ "$MODEL_NUM" = "DPC3941B" ] || [ "$MODEL_NUM" = "DPC3939B" ] || [ "$MODEL_NUM" = "CGA4131COM" ] || [ "$MODEL_NUM" = "CGA4332COM" ] || [ "$MODEL_NUM" = "SG417DBCT" ]; then service_ipv6 start else service_ipv6 dhcpv6s-start fi ;; "${SERVICE_NAME}-stop") -if [ "$MODEL_NUM" = "DPC3941B" ] || [ "$MODEL_NUM" = "DPC3939B" ] || [ "$MODEL_NUM" = "CGA4131COM" ] || [ "$MODEL_NUM" = "CGA4332COM" ]; then +if [ "$MODEL_NUM" = "DPC3941B" ] || [ "$MODEL_NUM" = "DPC3939B" ] || [ "$MODEL_NUM" = "CGA4131COM" ] || [ "$MODEL_NUM" = "CGA4332COM" ] || [ "$MODEL_NUM" = "SG417DBCT" ]; then service_ipv6 stop else service_ipv6 dhcpv6s-stop fi ;; "${SERVICE_NAME}-restart") -if [ "$MODEL_NUM" = "DPC3941B" ] || [ "$MODEL_NUM" = "DPC3939B" ] || [ "$MODEL_NUM" = "CGA4131COM" ] || [ "$MODEL_NUM" = "CGA4332COM" ]; then +if [ "$MODEL_NUM" = "DPC3941B" ] || [ "$MODEL_NUM" = "DPC3939B" ] || [ "$MODEL_NUM" = "CGA4131COM" ] || [ "$MODEL_NUM" = "CGA4332COM" ] || [ "$MODEL_NUM" = "SG417DBCT" ]; then service_ipv6 restart else service_ipv6 dhcpv6s-restart @@ -285,11 +285,13 @@ fi #---------------------------------------------------------------------------------- # Add other event entry points here #---------------------------------------------------------------------------------- - + ipv6_prefix_delegation) + service_ipv6 restart + ;; # ipv6_nameserver|ipv6_dnssl) # service_ipv6 dhcpv6s-restart dhcpv6_option_changed) -if [ "$MODEL_NUM" = "DPC3941B" ] || [ "$MODEL_NUM" = "DPC3939B" ] || [ "$MODEL_NUM" = "CGA4131COM" ] || [ "$MODEL_NUM" = "CGA4332COM" ]; then +if [ "$MODEL_NUM" = "DPC3941B" ] || [ "$MODEL_NUM" = "DPC3939B" ] || [ "$MODEL_NUM" = "CGA4131COM" ] || [ "$MODEL_NUM" = "CGA4332COM" ] || [ "$MODEL_NUM" = "SG417DBCT" ]; then service_ipv6 restart else service_ipv6 dhcpv6s-restart diff --git a/source/scripts/init/service.d/service_registration_functions.sh b/source/scripts/init/service.d/service_registration_functions.sh index 729c2d4a..45427183 100755 --- a/source/scripts/init/service.d/service_registration_functions.sh +++ b/source/scripts/init/service.d/service_registration_functions.sh @@ -306,7 +306,6 @@ sm_register_one_event() { if [ "NULL" = "$SMR_EVENT" ] ; then return 0 fi - # if this service has already registered for this event, then cancel the previous registration # this is probably overkill since we likely already called sm_unregister, but better safe than sorry sm_rm_event "${SMR_SERVICE}" "${SMR_EVENT_NAME}" diff --git a/source/scripts/init/service.d/service_routed_bci.sh b/source/scripts/init/service.d/service_routed_bci.sh index c83dbb27..c510b546 100755 --- a/source/scripts/init/service.d/service_routed_bci.sh +++ b/source/scripts/init/service.d/service_routed_bci.sh @@ -80,11 +80,14 @@ case "$1" in staticroute-restart) service_routed radv-restart ;; + ipv6_prefix_delegation) + service_routed radv-restart + ;; # ipv6_nameserver|ipv6_dnssl) # service_routed radv-restart # ;; ipv6_prefix|ipv6_nameserver) -if [ "$MODEL_NUM" = "DPC3941B" ] || [ "$MODEL_NUM" = "DPC3939B" ] || [ "$MODEL_NUM" = "CGA4131COM" ] || [ "$MODEL_NUM" = "CGA4332COM" ]; then +if [ "$MODEL_NUM" = "DPC3941B" ] || [ "$MODEL_NUM" = "DPC3939B" ] || [ "$MODEL_NUM" = "CGA4131COM" ] || [ "$MODEL_NUM" = "CGA4332COM" ] || [ "$MODEL_NUM" = "SG417DBCT" ]; then service_routed radv-restart fi ;; diff --git a/source/service_ipv6/Makefile.am b/source/service_ipv6/Makefile.am index 8e96cfff..7d51d8b8 100644 --- a/source/service_ipv6/Makefile.am +++ b/source/service_ipv6/Makefile.am @@ -25,6 +25,9 @@ AM_CPPFLAGS = -I$(top_srcdir)/source/include \ AM_LDFLAGS = -lccsp_common -lsecure_wrapper $(DBUS_LIBS) +if ONESTACK_PRODUCT_REQ +AM_LDFLAGS += -lrdkb_feature_mode_gate +endif service_ipv6_SOURCES = service_ipv6.c service_ipv6_main.c service_ipv6_LDADD = $(top_builddir)/source/util/utils/libutopiautil.la \ diff --git a/source/service_ipv6/service_ipv6.c b/source/service_ipv6/service_ipv6.c index a8d99354..b0142fd4 100644 --- a/source/service_ipv6/service_ipv6.c +++ b/source/service_ipv6/service_ipv6.c @@ -53,6 +53,9 @@ #include "ccsp_memory.h" #endif +#ifdef _ONESTACK_PRODUCT_REQ_ +#include +#endif #ifdef _HUB4_PRODUCT_REQ_ #include "ccsp_dm_api.h" #include "ccsp_custom.h" @@ -257,8 +260,8 @@ struct dhcpv6_tag tag_list[] = else if ( val[0] ) out = atoi(val); \ } \ -#ifdef _CBR_PRODUCT_REQ_ -STATIC uint64_t helper_ntoh64(const uint64_t *inputval) +#if defined( _CBR_PRODUCT_REQ_) || defined (_ONESTACK_PRODUCT_REQ_) +STATIC uint64_t helper_ntoh64(const long long unsigned int *inputval) { uint64_t returnval; uint8_t *data = (uint8_t *)&returnval; @@ -275,7 +278,7 @@ STATIC uint64_t helper_ntoh64(const uint64_t *inputval) return returnval; } -STATIC uint64_t helper_hton64(const uint64_t *inputval) +STATIC uint64_t helper_hton64(const long long unsigned int *inputval) { return (helper_ntoh64(inputval)); } @@ -391,10 +394,21 @@ STATIC int get_dhcpv6s_pool_cfg(struct serv_ipv6 *si6, dhcpv6s_pool_cfg_t *cfg) DHCPV6S_SYSCFG_GETI(DHCPV6S_NAME, "pool", cfg->index, "", 0, "X_RDKCENTRAL_COM_DNSServersEnabled", cfg->X_RDKCENTRAL_COM_DNSServersEnabled); #ifdef MULTILAN_FEATURE -#ifdef CISCO_CONFIG_DHCPV6_PREFIX_DELEGATION - DHCPV6S_SYSCFG_GETS(DHCPV6S_NAME, "pool", cfg->index, "", 0, "IAInterface", iface_name); -#else - DHCPV6S_SYSCFG_GETS(DHCPV6S_NAME, "pool", cfg->index, "", 0, "Interface", iface_name); +#if defined(CISCO_CONFIG_DHCPV6_PREFIX_DELEGATION) || defined(_ONESTACK_PRODUCT_REQ_) + #if defined(_ONESTACK_PRODUCT_REQ_) + if (isFeatureSupportedInCurrentMode(FEATURE_IPV6_DELEGATION) == true) + #endif + { + DHCPV6S_SYSCFG_GETS(DHCPV6S_NAME, "pool", cfg->index, "", 0, "IAInterface", iface_name); + } +#endif +#if !defined(CISCO_CONFIG_DHCPV6_PREFIX_DELEGATION) || defined(_ONESTACK_PRODUCT_REQ_) + #if defined(_ONESTACK_PRODUCT_REQ_) + if (isFeatureSupportedInCurrentMode(FEATURE_IPV6_DELEGATION) == false) + #endif + { + DHCPV6S_SYSCFG_GETS(DHCPV6S_NAME, "pool", cfg->index, "", 0, "Interface", iface_name); + } #endif #else DHCPV6S_SYSCFG_GETS(DHCPV6S_NAME, "pool", cfg->index, "", 0, "IAInterface", cfg->interface); @@ -449,7 +463,7 @@ STATIC int get_ia_info(struct serv_ipv6 *si6, char *config_file, ia_na_t *iana, if(iana == NULL || iapd == NULL) return -1; -#if defined (_CBR_PRODUCT_REQ_) || defined (_BWG_PRODUCT_REQ_) +#if defined (_CBR_PRODUCT_REQ_) || defined (_BWG_PRODUCT_REQ_) || defined (_ONESTACK_PRODUCT_REQ_) sysevent_get(si6->sefd, si6->setok, COSA_DML_DHCPV6C_PREF_T1_SYSEVENT_NAME, action, sizeof(action)); errno_t rc = -1; if(action[0]!='\0') @@ -606,7 +620,7 @@ STATIC int get_prefix_info(const char *prefix, char *value, unsigned int val_le STATIC int get_active_lanif(struct serv_ipv6 *si6, unsigned int insts[], unsigned int *num) { int i = 0; -#if !defined(MULTILAN_FEATURE) || defined CISCO_CONFIG_DHCPV6_PREFIX_DELEGATION +#if !defined(MULTILAN_FEATURE) || defined CISCO_CONFIG_DHCPV6_PREFIX_DELEGATION || defined(_ONESTACK_PRODUCT_REQ_) char active_insts[32] = {0}; char lan_pd_if[128] = {0}; char *p = NULL; @@ -628,7 +642,11 @@ STATIC int get_active_lanif(struct serv_ipv6 *si6, unsigned int insts[], unsigne unsigned int max_active_if_count = 0; int primary_l3_instance = 0; -#ifdef CISCO_CONFIG_DHCPV6_PREFIX_DELEGATION +#if defined(CISCO_CONFIG_DHCPV6_PREFIX_DELEGATION) || defined(_ONESTACK_PRODUCT_REQ_) + #if defined(_ONESTACK_PRODUCT_REQ_) + if (isFeatureSupportedInCurrentMode(FEATURE_IPV6_DELEGATION)) + #endif + { syscfg_get(NULL, "lan_pd_interfaces", lan_pd_if, sizeof(lan_pd_if)); if (lan_pd_if[0] == '\0') { *num = 0; @@ -648,7 +666,14 @@ STATIC int get_active_lanif(struct serv_ipv6 *si6, unsigned int insts[], unsigne p = strtok(NULL, " "); } -#else + } +#endif +#if !defined(CISCO_CONFIG_DHCPV6_PREFIX_DELEGATION) || defined(_ONESTACK_PRODUCT_REQ_) + #if defined(_ONESTACK_PRODUCT_REQ_) + if (!isFeatureSupportedInCurrentMode(FEATURE_IPV6_DELEGATION)) + #endif + { + /* Get active bridge count from PSM */ if (!bus_handle) { fprintf(stderr, "DBUS not connected, returning \n"); @@ -718,6 +743,7 @@ STATIC int get_active_lanif(struct serv_ipv6 *si6, unsigned int insts[], unsigne } /* Set active IPv6 instances */ sysevent_set(si6->sefd, si6->setok, "ipv6_active_inst", active_if_list, 0); + } #endif @@ -879,7 +905,7 @@ STATIC int divide_ipv6_prefix(struct serv_ipv6 *si6) p_prefix = sub_prefixes; memcpy((void *)&tmp_prefix, (void *)prefix, 8); // the first 64 bits of mso prefix value -#ifdef _CBR_PRODUCT_REQ_ +#if defined (_CBR_PRODUCT_REQ_) || defined(_ONESTACK_PRODUCT_REQ_) tmp_prefix = helper_ntoh64(&tmp_prefix); // The memcpy is copying in reverse order due to LEndianess #endif #ifdef MULTILAN_FEATURE @@ -892,7 +918,7 @@ STATIC int divide_ipv6_prefix(struct serv_ipv6 *si6) sub_prefix = tmp_prefix | (i << (delta_bits - bit_boundary)); #endif memset(buf, 0, sizeof(buf)); -#ifdef _CBR_PRODUCT_REQ_ +#if defined (_CBR_PRODUCT_REQ_) || defined(_ONESTACK_PRODUCT_REQ_) sub_prefix = helper_hton64(&sub_prefix);// The memcpy is copying in reverse order due to LEndianess #endif memcpy((void *)buf, (void *)&sub_prefix, 8); @@ -920,13 +946,13 @@ STATIC int divide_ipv6_prefix(struct serv_ipv6 *si6) fprintf(stderr, "inet_pton failed\n"); } memcpy((void *)&tmp_prefix, (void *)prefix, 8); //the first 64 bits of the first sub-prefix -#ifdef _CBR_PRODUCT_REQ_ +#if defined (_CBR_PRODUCT_REQ_) || defined(_ONESTACK_PRODUCT_REQ_) tmp_prefix = helper_ntoh64(&tmp_prefix); // The memcpy is copying in reverse order due to LEndianess #endif for (i = 0; i < enabled_iface_num; i++) { //p_prefix->b_used = 1; memset(buf, 0, sizeof(buf)); -#ifdef _CBR_PRODUCT_REQ_ +#if defined (_CBR_PRODUCT_REQ_) || defined(_ONESTACK_PRODUCT_REQ_) tmp_prefix = helper_hton64(&tmp_prefix);// The memcpy is copying in reverse order due to LEndianess #endif memcpy((void *)buf, (void *)&tmp_prefix, 8); @@ -1682,7 +1708,7 @@ STATIC int gen_dibbler_conf(struct serv_ipv6 *si6) fprintf(fp, "inactive-mode\n"); /*Run scipt to config route */ -#if defined (_CBR_PRODUCT_REQ_) || defined (_BWG_PRODUCT_REQ_) +#if defined (_CBR_PRODUCT_REQ_) || defined (_BWG_PRODUCT_REQ_) || defined (_ONESTACK_PRODUCT_REQ_) fprintf(fp, "script \"/lib/rdk/server-notify.sh\" \n"); #endif @@ -1778,7 +1804,7 @@ STATIC int gen_dibbler_conf(struct serv_ipv6 *si6) /*pd pool*/ if(get_pd_pool(si6, &pd_pool) == 0) { fprintf(fp, " pd-class {\n"); -#if defined (_CBR_PRODUCT_REQ_) || defined (_BWG_PRODUCT_REQ_) +#if defined (_CBR_PRODUCT_REQ_) || defined (_BWG_PRODUCT_REQ_) || defined(_ONESTACK_PRODUCT_REQ_) fprintf(fp, " pd-pool %s /%d\n", pd_pool.start, pd_pool.prefix_length); #else fprintf(fp, " pd-pool %s - %s /%d\n", pd_pool.start, pd_pool.end, pd_pool.prefix_length); @@ -2079,6 +2105,7 @@ STATIC int dhcpv6s_restart(struct serv_ipv6 *si6) STATIC int serv_ipv6_start(struct serv_ipv6 *si6) { + fprintf(stderr, "Entered serv_ipv6_start \n"); char rtmod[16]; /* state check */ @@ -2098,10 +2125,17 @@ STATIC int serv_ipv6_start(struct serv_ipv6 *si6) sysevent_set(si6->sefd, si6->setok, "service_ipv6-status", "starting", 0); /* Fix for IPv6 prefix not getting updated in dibbler server conf file on WAN mode change */ -#if defined(_CBR2_PRODUCT_REQ_) +#if defined(_CBR2_PRODUCT_REQ_) sysevent_get(si6->sefd, si6->setok, "ipv6_prefix", si6->mso_prefix, sizeof(si6->mso_prefix)); sysevent_set(si6->sefd, si6->setok, "ipv6_prefix-divided", "", 0); #endif +#if defined(_ONESTACK_PRODUCT_REQ_) + if (isFeatureSupportedInCurrentMode(FEATURE_IPV6_DELEGATION)) + { + sysevent_get(si6->sefd, si6->setok, "ipv6_prefix_delegation", si6->mso_prefix, sizeof(si6->mso_prefix)); + sysevent_set(si6->sefd, si6->setok, "ipv6_prefix-divided", "", 0); + } +#endif /* * Update MTU of all the enabled IPv6 instances @@ -2118,13 +2152,22 @@ STATIC int serv_ipv6_start(struct serv_ipv6 *si6) * 5) Send RA, start DHCPv6 server */ /* For CBR product the lan(brlan0) v6 address set is done as part of PandM process*/ -#if !defined(_CBR_PRODUCT_REQ_) && !defined(_BWG_PRODUCT_REQ_) +#if !defined(_CBR_PRODUCT_REQ_) && !defined(_BWG_PRODUCT_REQ_) && !defined(_ONESTACK_PRODUCT_REQ_) if (lan_addr6_set(si6) !=0) { fprintf(stderr, "assign IPv6 address for lan interfaces error!\n"); sysevent_set(si6->sefd, si6->setok, "service_ipv6-status", "error", 0); return -1; } #endif +#if defined (_ONESTACK_PRODUCT_REQ_) + if (!isFeatureSupportedInCurrentMode(FEATURE_IPV6_DELEGATION)){ + if (lan_addr6_set(si6) !=0) { + fprintf(stderr, "assign IPv6 address for lan interfaces error!\n"); + sysevent_set(si6->sefd, si6->setok, "service_ipv6-status", "error", 0); + return -1; + } + } +#endif //Intel Proposed RDKB Generic Bug Fix from XB6 SDK /*start zebra*/ @@ -2152,6 +2195,7 @@ STATIC int serv_ipv6_start(struct serv_ipv6 *si6) STATIC int serv_ipv6_stop(struct serv_ipv6 *si6) { + fprintf(stderr, "Entered serv_ipv6_stop \n"); if (!serv_can_stop(si6->sefd, si6->setok, "service_ipv6")) return -1; @@ -2162,7 +2206,7 @@ STATIC int serv_ipv6_stop(struct serv_ipv6 *si6) sysevent_set(si6->sefd, si6->setok, "service_ipv6-status", "error", 0); return -1; } -#if !defined(_CBR_PRODUCT_REQ_) && !defined(_BWG_PRODUCT_REQ_) +#if !defined(_CBR_PRODUCT_REQ_) && !defined(_BWG_PRODUCT_REQ_) && !defined(_ONESTACK_PRODUCT_REQ_) del_addr6_flg = false; if (lan_addr6_unset(si6) !=0) { fprintf(stderr, "unset IPv6 address for lan interfaces error!\n"); @@ -2171,6 +2215,18 @@ STATIC int serv_ipv6_stop(struct serv_ipv6 *si6) return -1; } del_addr6_flg = true; +#endif +#if defined (_ONESTACK_PRODUCT_REQ_) + if (!isFeatureSupportedInCurrentMode(FEATURE_IPV6_DELEGATION)){ + del_addr6_flg = false; + if (lan_addr6_unset(si6) !=0) { + fprintf(stderr, "unset IPv6 address for lan interfaces error!\n"); + sysevent_set(si6->sefd, si6->setok, "service_ipv6-status", "error", 0); + del_addr6_flg = true; + return -1; + } + del_addr6_flg = true; + } #endif sysevent_set(si6->sefd, si6->setok, "service_ipv6-status", "stopped", 0); return 0; @@ -2219,12 +2275,28 @@ STATIC int serv_ipv6_init(struct serv_ipv6 *si6) return -1; #endif } - +#if defined (_ONESTACK_PRODUCT_REQ_) + if (isFeatureSupportedInCurrentMode(FEATURE_IPV6_DELEGATION)) + { + sysevent_get(si6->sefd, si6->setok, "ipv6_prefix_delegation", si6->mso_prefix, sizeof(si6->mso_prefix)); + } + else + { + sysevent_get(si6->sefd, si6->setok, "ipv6_prefix", si6->mso_prefix, sizeof(si6->mso_prefix)); + } +#else sysevent_get(si6->sefd, si6->setok, "ipv6_prefix", si6->mso_prefix, sizeof(si6->mso_prefix)); +#endif + fprintf(stderr, "IPv6 Prefix :%s\n", si6->mso_prefix); if (strlen(si6->mso_prefix)) + { si6->wan_ready = true; + } else + { + fprintf(stderr, "[%s] -- Init ipv6_prefix retrieval failed\n", PROG_NAME); return -1; + } sysevent_get(si6->sefd, si6->setok, "erouter_topology-mode", buf, sizeof(buf)); switch(atoi(buf)) { @@ -2307,8 +2379,10 @@ int service_ipv6_main(int argc, char *argv[]) } if (serv_ipv6_init(&si6) != 0) + { + fprintf(stderr, "[%s] -- Service IPV6 Initialization failed\n", PROG_NAME); exit(1); - + } for (i = 0; i < NELEMS(cmd_ops); i++) { if (strcmp(argv[1], cmd_ops[i].cmd) != 0 || !cmd_ops[i].exec) continue; @@ -2323,6 +2397,7 @@ int service_ipv6_main(int argc, char *argv[]) if (i == NELEMS(cmd_ops)) fprintf(stderr, "[%s] unknown command: %s\n", PROG_NAME, argv[1]); + fprintf(stderr, "[%s] -- DHCPv6 start in progress\n", PROG_NAME); if (serv_ipv6_term(&si6) != 0) exit(1); diff --git a/source/service_routed/Makefile.am b/source/service_routed/Makefile.am index e869e8de..2b537a86 100644 --- a/source/service_routed/Makefile.am +++ b/source/service_routed/Makefile.am @@ -19,7 +19,11 @@ bin_PROGRAMS = service_routed -AM_LDFLAGS = -lsecure_wrapper +AM_CPPFLAGS = -I$(top_srcdir)/source/include \ + -I$(top_srcdir)/source/util/utils \ + $(DBUS_CFLAGS) + +AM_LDFLAGS = -lsecure_wrapper -lccsp_common $(DBUS_LIBS) service_routed_SOURCES = service_routed.c service_routed_main.c @@ -29,8 +33,8 @@ service_routed_CFLAGS = -I$(top_srcdir)/source \ -I$(top_srcdir)/source/utapi/lib \ -I$(top_srcdir)/source/util/utils \ -I${PKG_CONFIG_SYSROOT_DIR}$(includedir)/dbus-1.0 \ - -I${PKG_CONFIG_SYSROOT_DIR}$(libdir)/dbus-1.0/include - + -I${PKG_CONFIG_SYSROOT_DIR}$(libdir)/dbus-1.0/include \ + -I${PKG_CONFIG_SYSROOT_DIR}$(includedir) service_routed_LDADD = $(top_builddir)/source/util/utils/libutopiautil.la \ $(top_builddir)/source/services/lib/libsrvmgr.la \ @@ -40,6 +44,10 @@ service_routed_LDADD = $(top_builddir)/source/util/utils/libutopiautil.la \ $(top_builddir)/source/utctx/lib/libutctx.la \ $(top_builddir)/source/ulog/libulog.la \ -ltelemetry_msgsender +service_routed_LDFLAGS = -L${PKG_CONFIG_SYSROOT_DIR}${libdir} +if ONESTACK_PRODUCT_REQ +service_routed_LDFLAGS += -lrdkb_feature_mode_gate +endif if CORE_NET_LIB_FEATURE_SUPPORT -service_routed_LDFLAGS = -lnet +service_routed_LDFLAGS += -lnet endif diff --git a/source/service_routed/service_routed.c b/source/service_routed/service_routed.c index 240ac2d5..c01695c9 100644 --- a/source/service_routed/service_routed.c +++ b/source/service_routed/service_routed.c @@ -59,6 +59,9 @@ #include #endif +#ifdef _ONESTACK_PRODUCT_REQ_ +#include +#endif #include "util.h" #include #include "sysevent/sysevent.h" @@ -425,8 +428,11 @@ STATIC int get_active_lanif(int sefd, token_t setok, unsigned int *insts, unsign char *p = NULL; int i = 0; -#ifdef CISCO_CONFIG_DHCPV6_PREFIX_DELEGATION - +#if defined(CISCO_CONFIG_DHCPV6_PREFIX_DELEGATION) || defined(_ONESTACK_PRODUCT_REQ_) + #if defined(_ONESTACK_PRODUCT_REQ_) + if (isFeatureSupportedInCurrentMode(FEATURE_IPV6_DELEGATION)) + #endif + { char lan_pd_if[128] = {0}; char if_name[16] = {0}; char buf[64] = {0}; @@ -449,8 +455,13 @@ STATIC int get_active_lanif(int sefd, token_t setok, unsigned int *insts, unsign p = strtok(NULL, " "); } - -#else + } +#endif +#if !defined(CISCO_CONFIG_DHCPV6_PREFIX_DELEGATION) || defined(_ONESTACK_PRODUCT_REQ_) + #if defined(_ONESTACK_PRODUCT_REQ_) + if (!isFeatureSupportedInCurrentMode(FEATURE_IPV6_DELEGATION)) + #endif + { /* service_ipv6 sets active IPv6 interfaces instances. */ sysevent_get(sefd, setok, "ipv6_active_inst", active_insts, sizeof(active_insts)); @@ -459,14 +470,14 @@ STATIC int get_active_lanif(int sefd, token_t setok, unsigned int *insts, unsign insts[i++] = atoi(p); p = strtok(NULL, " "); } - + } #endif *num = i; return *num; } #else -#ifdef CISCO_CONFIG_DHCPV6_PREFIX_DELEGATION +#if defined(CISCO_CONFIG_DHCPV6_PREFIX_DELEGATION) || defined(_ONESTACK_PRODUCT_REQ_) STATIC int get_active_lanif(int sefd, token_t setok, unsigned int *insts, unsigned int *num) { char active_insts[32] = {0}; @@ -505,7 +516,11 @@ STATIC int get_active_lanif(int sefd, token_t setok, unsigned int *insts, unsign STATIC int route_set(struct serv_routed *sr) { -#if defined(CISCO_CONFIG_DHCPV6_PREFIX_DELEGATION) || defined(MULTILAN_FEATURE) +#if defined(CISCO_CONFIG_DHCPV6_PREFIX_DELEGATION) || defined(MULTILAN_FEATURE) || defined(_ONESTACK_PRODUCT_REQ_) + #if defined(_ONESTACK_PRODUCT_REQ_) + if (isFeatureSupportedInCurrentMode(FEATURE_IPV6_DELEGATION)) + #endif + { unsigned int l2_insts[4] = {0}; unsigned int enabled_iface_num = 0; char evt_name[64] = {0}; @@ -560,6 +575,7 @@ STATIC int route_set(struct serv_routed *sr) lan_if, lan_if, lan_if, lan_if); #endif } + } #endif #if defined (_HUB4_PRODUCT_REQ_) && (!defined (_WNXL11BWL_PRODUCT_REQ_)) || defined(_SCER11BEL_PRODUCT_REQ_) @@ -657,7 +673,11 @@ STATIC int route_unset(struct serv_routed *sr) #ifdef CORE_NET_LIB libnet_status status; #endif -#if defined(CISCO_CONFIG_DHCPV6_PREFIX_DELEGATION) || defined(MULTILAN_FEATURE) +#if defined(CISCO_CONFIG_DHCPV6_PREFIX_DELEGATION) || defined(MULTILAN_FEATURE) || defined(_ONESTACK_PRODUCT_REQ_) +#ifdef _ONESTACK_PRODUCT_REQ_ + if (isFeatureSupportedInCurrentMode(FEATURE_IPV6_DELEGATION)) +#endif + { unsigned int l2_insts[4] = {0}; unsigned int enabled_iface_num = 0; char evt_name[64] = {0}; @@ -689,7 +709,8 @@ STATIC int route_unset(struct serv_routed *sr) #endif } -#elif !defined(WAN_MANAGER_UNIFICATION_ENABLED) //Default route is configured WanManager. + } +#elif !defined(WAN_MANAGER_UNIFICATION_ENABLED) #if defined (_HUB4_PRODUCT_REQ_) && (!defined (_WNXL11BWL_PRODUCT_REQ_)) || defined(_RDKB_GLOBAL_PRODUCT_REQ_) #ifdef CORE_NET_LIB status = rule_delete("-6 iif brlan0 table erouter"); @@ -901,7 +922,7 @@ STATIC int gen_zebra_conf(int sefd, token_t setok) "!log stdout\n" "log file /var/tmp/zebra.log errors\n" "table 255\n"; -#if defined(MULTILAN_FEATURE) || defined(CISCO_CONFIG_DHCPV6_PREFIX_DELEGATION) +#if defined(MULTILAN_FEATURE) || defined(CISCO_CONFIG_DHCPV6_PREFIX_DELEGATION) || defined(_ONESTACK_PRODUCT_REQ_) int i = 0; unsigned int l2_insts[4] = {0}; unsigned int enabled_iface_num = 0; @@ -1000,15 +1021,27 @@ STATIC int gen_zebra_conf(int sefd, token_t setok) #endif syscfg_get(NULL, "ra_interval", ra_interval, sizeof(ra_interval)); -#ifdef CISCO_CONFIG_DHCPV6_PREFIX_DELEGATION + +#ifdef WAN_FAILOVER_SUPPORTED + char last_broadcasted_prefix[64] = {0}; +#endif +#if defined(CISCO_CONFIG_DHCPV6_PREFIX_DELEGATION) || defined(_ONESTACK_PRODUCT_REQ_) + #if defined(_ONESTACK_PRODUCT_REQ_) + if (isFeatureSupportedInCurrentMode(FEATURE_IPV6_DELEGATION)) + #endif + { sysevent_get(sefd, setok, "previous_ipv6_prefix", orig_prefix, sizeof(orig_prefix)); sysevent_get(sefd, setok, "ipv6_prefix_prdtime", preferred_lft, sizeof(preferred_lft)); sysevent_get(sefd, setok, "ipv6_prefix_vldtime", valid_lft, sizeof(valid_lft)); -#else - + } +#endif +#if !defined(CISCO_CONFIG_DHCPV6_PREFIX_DELEGATION) || defined(_ONESTACK_PRODUCT_REQ_) + #if defined(_ONESTACK_PRODUCT_REQ_) + if (!isFeatureSupportedInCurrentMode(FEATURE_IPV6_DELEGATION)) + #endif + { #ifdef WAN_FAILOVER_SUPPORTED - char last_broadcasted_prefix[64] ; memset(last_broadcasted_prefix,0,sizeof(last_broadcasted_prefix)); if (gIpv6AddrAssignment == ULA_IPV6) { @@ -1119,6 +1152,7 @@ STATIC int gen_zebra_conf(int sefd, token_t setok) sysevent_get(sefd, setok, "ipv6_prefix_vldtime", valid_lft, sizeof(valid_lft)); #endif syscfg_get(NULL, "lan_ifname", lan_if, sizeof(lan_if)); + } #endif if (atoi(preferred_lft) <= 0) snprintf(preferred_lft, sizeof(preferred_lft), "300"); @@ -1131,7 +1165,24 @@ STATIC int gen_zebra_conf(int sefd, token_t setok) sysevent_get(sefd, setok, "wan-status", wan_st, sizeof(wan_st)); syscfg_get(NULL, "last_erouter_mode", rtmod, sizeof(rtmod)); -#if defined(MULTILAN_FEATURE) || defined(CISCO_CONFIG_DHCPV6_PREFIX_DELEGATION) + +#if defined(MULTILAN_FEATURE) || defined(CISCO_CONFIG_DHCPV6_PREFIX_DELEGATION) || defined (_ONESTACK_PRODUCT_REQ_) + int multilan_enabled = 0; + int pd_enabled = 0; + +#if defined(MULTILAN_FEATURE) + multilan_enabled = 1; +#endif +#if defined(CISCO_CONFIG_DHCPV6_PREFIX_DELEGATION) + pd_enabled = 1; +#endif + + #ifdef _ONESTACK_PRODUCT_REQ_ + pd_enabled = isFeatureSupportedInCurrentMode(FEATURE_IPV6_DELEGATION); + #endif + + if (pd_enabled || multilan_enabled) + { get_active_lanif(sefd, setok, l2_insts, &enabled_iface_num); for (i = 0; i < enabled_iface_num; i++) { @@ -1437,17 +1488,17 @@ STATIC int gen_zebra_conf(int sefd, token_t setok) if ((strncmp(buf,"true",4) == 0) && iresCode == 204) { -#if defined (_COSA_BCM_MIPS_) -#ifdef CISCO_CONFIG_DHCPV6_PREFIX_DELEGATION - // For CBR platform, the captive portal redirection feature was removed - // inWifiCp = 1; +#if defined (_COSA_BCM_MIPS_) +#if defined(CISCO_CONFIG_DHCPV6_PREFIX_DELEGATION) + // For CBR platform, the captive portal redirection feature was removed + // inWifiCp = 1; #else - inWifiCp = 1; + inWifiCp = 1; #endif #else - inWifiCp = 1; + inWifiCp = 1; #endif - } + } #if defined (_XB6_PROD_REQ_) syscfg_get(NULL, "enableRFCaptivePortal", rfCpEnable, sizeof(rfCpEnable)); if(rfCpEnable != NULL) @@ -1557,16 +1608,32 @@ STATIC int gen_zebra_conf(int sefd, token_t setok) } #endif /* static IPv6 DNS */ -#ifdef CISCO_CONFIG_DHCPV6_PREFIX_DELEGATION +#if defined(CISCO_CONFIG_DHCPV6_PREFIX_DELEGATION) || defined(_ONESTACK_PRODUCT_REQ_) + #if defined(_ONESTACK_PRODUCT_REQ_) + if (isFeatureSupportedInCurrentMode(FEATURE_IPV6_DELEGATION)) + #endif + { snprintf(rec, sizeof(rec), "dhcpv6spool%d0::optionnumber", i); syscfg_get(NULL, rec, val, sizeof(val)); -#else + } +#endif +#if !defined(CISCO_CONFIG_DHCPV6_PREFIX_DELEGATION) || defined(_ONESTACK_PRODUCT_REQ_) + #if defined(_ONESTACK_PRODUCT_REQ_) + if (!isFeatureSupportedInCurrentMode(FEATURE_IPV6_DELEGATION)) + #endif + { syscfg_get(NULL, "dhcpv6spool00::optionnumber", val, sizeof(val)); + } #endif nopt = atoi(val); for (j = 0; j < nopt; j++) { -#ifdef CISCO_CONFIG_DHCPV6_PREFIX_DELEGATION +#if defined(CISCO_CONFIG_DHCPV6_PREFIX_DELEGATION) || defined(_ONESTACK_PRODUCT_REQ_) + #if defined(_ONESTACK_PRODUCT_REQ_) + if (isFeatureSupportedInCurrentMode(FEATURE_IPV6_DELEGATION)) + #endif + { memset(name_servs, 0, sizeof(name_servs)); + } #endif snprintf(rec, sizeof(rec), "dhcpv6spool0option%d::bEnabled", j); /*RDKB-12965 & CID:-34147*/ syscfg_get(NULL, rec, val, sizeof(val)); @@ -1709,11 +1776,16 @@ STATIC int gen_zebra_conf(int sefd, token_t setok) fprintf(fp, "interface %s\n", lan_if); fprintf(fp, " ip irdp multicast\n"); -#if defined(MULTILAN_FEATURE) || defined(CISCO_CONFIG_DHCPV6_PREFIX_DELEGATION) +#if defined(MULTILAN_FEATURE) || defined(CISCO_CONFIG_DHCPV6_PREFIX_DELEGATION) || defined(_ONESTACK_PRODUCT_REQ_) } //for (i = 0; i < enabled_iface_num; i++) + } #endif -#ifndef CISCO_CONFIG_DHCPV6_PREFIX_DELEGATION +#if !defined(CISCO_CONFIG_DHCPV6_PREFIX_DELEGATION) || defined(_ONESTACK_PRODUCT_REQ_) +#ifdef _ONESTACK_PRODUCT_REQ_ +if (!isFeatureSupportedInCurrentMode(FEATURE_IPV6_DELEGATION)) +#endif +{ char cmd[100]; char out[100]; char interface_name[32] = {0}; @@ -1925,6 +1997,7 @@ if(!strncmp(out,"true",strlen(out))) memset(out,0,sizeof(out)); } } +} #endif fclose(fp); return 0;