@@ -566,6 +566,10 @@ int net_context_get(sa_family_t family, enum net_sock_type type, uint16_t proto,
566566#if defined(CONFIG_NET_IPV4_MAPPING_TO_IPV6 )
567567 /* By default IPv4 and IPv6 are in different port spaces */
568568 contexts [i ].options .ipv6_v6only = true;
569+ #endif
570+ #if defined(CONFIG_NET_IPV4 )
571+ contexts [i ].options .ipv4_mcast_loop =
572+ IS_ENABLED (CONFIG_NET_INITIAL_IPV4_MCAST_LOOP );
569573#endif
570574 if (IS_ENABLED (CONFIG_NET_IP )) {
571575 (void )memset (& contexts [i ].remote , 0 , sizeof (struct sockaddr ));
@@ -1783,6 +1787,19 @@ static int get_context_mcast_ttl(struct net_context *context,
17831787#endif
17841788}
17851789
1790+ static int get_context_ipv4_mcast_loop (struct net_context * context ,
1791+ void * value , size_t * len )
1792+ {
1793+ #if defined(CONFIG_NET_IPV4 )
1794+ return get_bool_option (context -> options .ipv4_mcast_loop , value , len );
1795+ #else
1796+ ARG_UNUSED (context );
1797+ ARG_UNUSED (value );
1798+ ARG_UNUSED (len );
1799+ return - ENOTSUP ;
1800+ #endif
1801+ }
1802+
17861803static int get_context_mcast_hop_limit (struct net_context * context ,
17871804 void * value , size_t * len )
17881805{
@@ -3293,6 +3310,20 @@ static int set_context_mcast_ttl(struct net_context *context,
32933310#endif
32943311}
32953312
3313+ static int set_context_ipv4_mcast_loop (struct net_context * context ,
3314+ const void * value , size_t len )
3315+ {
3316+ #if defined(CONFIG_NET_IPV4 )
3317+ return set_bool_option (& context -> options .ipv4_mcast_loop , value , len );
3318+ #else
3319+ ARG_UNUSED (context );
3320+ ARG_UNUSED (value );
3321+ ARG_UNUSED (len );
3322+
3323+ return - ENOTSUP ;
3324+ #endif
3325+ }
3326+
32963327static int set_context_mcast_hop_limit (struct net_context * context ,
32973328 const void * value , size_t len )
32983329{
@@ -3688,6 +3719,9 @@ int net_context_set_option(struct net_context *context,
36883719 case NET_OPT_IPV6_MCAST_LOOP :
36893720 ret = set_context_ipv6_mcast_loop (context , value , len );
36903721 break ;
3722+ case NET_OPT_IPV4_MCAST_LOOP :
3723+ ret = set_context_ipv4_mcast_loop (context , value , len );
3724+ break ;
36913725 }
36923726
36933727 k_mutex_unlock (& context -> lock );
@@ -3776,6 +3810,9 @@ int net_context_get_option(struct net_context *context,
37763810 case NET_OPT_IPV6_MCAST_LOOP :
37773811 ret = get_context_ipv6_mcast_loop (context , value , len );
37783812 break ;
3813+ case NET_OPT_IPV4_MCAST_LOOP :
3814+ ret = get_context_ipv4_mcast_loop (context , value , len );
3815+ break ;
37793816 }
37803817
37813818 k_mutex_unlock (& context -> lock );
0 commit comments