1195972f6Sopenharmony_ci/* 2195972f6Sopenharmony_ci * Copyright (c) 2023-2023 Huawei Device Co., Ltd. All rights reserved. 3195972f6Sopenharmony_ci * 4195972f6Sopenharmony_ci * Redistribution and use in source and binary forms, with or without modification, 5195972f6Sopenharmony_ci * are permitted provided that the following conditions are met: 6195972f6Sopenharmony_ci * 7195972f6Sopenharmony_ci * 1. Redistributions of source code must retain the above copyright notice, this list of 8195972f6Sopenharmony_ci * conditions and the following disclaimer. 9195972f6Sopenharmony_ci * 10195972f6Sopenharmony_ci * 2. Redistributions in binary form must reproduce the above copyright notice, this list 11195972f6Sopenharmony_ci * of conditions and the following disclaimer in the documentation and/or other materials 12195972f6Sopenharmony_ci * provided with the distribution. 13195972f6Sopenharmony_ci * 14195972f6Sopenharmony_ci * 3. Neither the name of the copyright holder nor the names of its contributors may be used 15195972f6Sopenharmony_ci * to endorse or promote products derived from this software without specific prior written 16195972f6Sopenharmony_ci * permission. 17195972f6Sopenharmony_ci * 18195972f6Sopenharmony_ci * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19195972f6Sopenharmony_ci * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 20195972f6Sopenharmony_ci * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 21195972f6Sopenharmony_ci * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 22195972f6Sopenharmony_ci * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 23195972f6Sopenharmony_ci * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 24195972f6Sopenharmony_ci * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 25195972f6Sopenharmony_ci * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 26195972f6Sopenharmony_ci * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 27195972f6Sopenharmony_ci * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 28195972f6Sopenharmony_ci * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29195972f6Sopenharmony_ci */ 30195972f6Sopenharmony_ci#ifdef LOSCFG_NET_CONTAINER 31195972f6Sopenharmony_ci#include "lwip/net_group.h" 32195972f6Sopenharmony_ci#include "lwip/netif.h" 33195972f6Sopenharmony_ci 34195972f6Sopenharmony_cistatic struct netif root_loop_netif = {0}; 35195972f6Sopenharmony_cistatic struct net_group root_net_group = { 36195972f6Sopenharmony_ci .loop_netif = &root_loop_netif, 37195972f6Sopenharmony_ci}; 38195972f6Sopenharmony_ci 39195972f6Sopenharmony_cistruct net_group *get_root_net_group(void) 40195972f6Sopenharmony_ci{ 41195972f6Sopenharmony_ci return &root_net_group; 42195972f6Sopenharmony_ci} 43195972f6Sopenharmony_ci 44195972f6Sopenharmony_cistruct net_group *get_curr_process_net_group(void) 45195972f6Sopenharmony_ci{ 46195972f6Sopenharmony_ci return get_default_net_group_ops()->get_curr_process_net_group(); 47195972f6Sopenharmony_ci} 48195972f6Sopenharmony_ci 49195972f6Sopenharmony_cistatic void do_set_netif_net_group(struct netif *netif, struct net_group *group) 50195972f6Sopenharmony_ci{ 51195972f6Sopenharmony_ci (void)netif; 52195972f6Sopenharmony_ci (void)group; 53195972f6Sopenharmony_ci} 54195972f6Sopenharmony_ci 55195972f6Sopenharmony_cistatic struct net_group *do_get_net_group_from_netif(struct netif *netif) 56195972f6Sopenharmony_ci{ 57195972f6Sopenharmony_ci (void)netif; 58195972f6Sopenharmony_ci return get_root_net_group(); 59195972f6Sopenharmony_ci} 60195972f6Sopenharmony_ci 61195972f6Sopenharmony_cistatic void do_set_ippcb_net_group(struct ip_pcb *pcb, struct net_group *group) 62195972f6Sopenharmony_ci{ 63195972f6Sopenharmony_ci (void)pcb; 64195972f6Sopenharmony_ci (void)group; 65195972f6Sopenharmony_ci} 66195972f6Sopenharmony_ci 67195972f6Sopenharmony_cistatic struct net_group *do_get_net_group_from_ippcb(struct ip_pcb *pcb) 68195972f6Sopenharmony_ci{ 69195972f6Sopenharmony_ci (void)pcb; 70195972f6Sopenharmony_ci return get_root_net_group(); 71195972f6Sopenharmony_ci} 72195972f6Sopenharmony_ci 73195972f6Sopenharmony_cistatic struct net_group_ops root_net_group_ops = { 74195972f6Sopenharmony_ci .get_curr_process_net_group = get_root_net_group, 75195972f6Sopenharmony_ci .set_netif_net_group = do_set_netif_net_group, 76195972f6Sopenharmony_ci .get_net_group_from_netif = do_get_net_group_from_netif, 77195972f6Sopenharmony_ci .set_ippcb_net_group = do_set_ippcb_net_group, 78195972f6Sopenharmony_ci .get_net_group_from_ippcb = do_get_net_group_from_ippcb, 79195972f6Sopenharmony_ci}; 80195972f6Sopenharmony_ci 81195972f6Sopenharmony_cistruct net_group_ops *default_net_group_ops = &root_net_group_ops; 82195972f6Sopenharmony_ci 83195972f6Sopenharmony_civoid set_default_net_group_ops(struct net_group_ops *ops) { 84195972f6Sopenharmony_ci default_net_group_ops = ops; 85195972f6Sopenharmony_ci} 86195972f6Sopenharmony_ci 87195972f6Sopenharmony_cistruct net_group_ops *get_default_net_group_ops(void) { 88195972f6Sopenharmony_ci return default_net_group_ops; 89195972f6Sopenharmony_ci} 90195972f6Sopenharmony_ci#endif 91