diff --git a/drivers/net/ppp.c b/drivers/net/ppp.c index 4db963beeb7..1e1ce474095 100644 --- a/drivers/net/ppp.c +++ b/drivers/net/ppp.c @@ -1046,7 +1046,7 @@ static int ppp_start(const struct device *dev) } #endif /* !CONFIG_NET_TEST */ - ARG_UNUSED(context); + net_if_carrier_on(context->iface); return 0; } @@ -1054,6 +1054,7 @@ static int ppp_stop(const struct device *dev) { struct ppp_driver_context *context = dev->data; + net_if_carrier_off(context->iface); context->modem_init_done = false; return 0; } diff --git a/include/zephyr/net/ppp.h b/include/zephyr/net/ppp.h index 686f34aecf2..4067d37f4cc 100644 --- a/include/zephyr/net/ppp.h +++ b/include/zephyr/net/ppp.h @@ -489,6 +489,9 @@ struct ppp_context { /** Is PPP ready to receive packets */ uint16_t is_ready_to_serve : 1; + /** Is PPP L2 enabled or not */ + uint16_t is_enabled : 1; + /** PPP enable pending */ uint16_t is_enable_done : 1; diff --git a/subsys/net/l2/ppp/ppp_internal.h b/subsys/net/l2/ppp/ppp_internal.h index 0603f1e27b8..c5b5a9547f6 100644 --- a/subsys/net/l2/ppp/ppp_internal.h +++ b/subsys/net/l2/ppp/ppp_internal.h @@ -213,5 +213,3 @@ static inline bool ppp_my_option_is_acked(struct ppp_fsm *fsm, { return ppp_my_option_flags(fsm, code) & PPP_MY_OPTION_ACKED; } - -void ppp_if_carrier_down(struct net_if *iface); diff --git a/subsys/net/l2/ppp/ppp_l2.c b/subsys/net/l2/ppp/ppp_l2.c index 63b4b5d57fe..b949c491406 100644 --- a/subsys/net/l2/ppp/ppp_l2.c +++ b/subsys/net/l2/ppp/ppp_l2.c @@ -17,7 +17,6 @@ LOG_MODULE_REGISTER(net_l2_ppp, CONFIG_NET_L2_PPP_LOG_LEVEL); #include #include "net_private.h" -#include "ipv4_autoconf_internal.h" #include "ppp_stats.h" #include "ppp_internal.h" @@ -218,7 +217,31 @@ static enum net_l2_flags ppp_flags(struct net_if *iface) return ctx->ppp_l2_flags; } -NET_L2_INIT(PPP_L2, ppp_recv, ppp_send, NULL, ppp_flags); +static int ppp_enable(struct net_if *iface, bool state) +{ + const struct ppp_api *ppp = + net_if_get_device(iface)->api; + struct ppp_context *ctx = net_if_l2_data(iface); + + if (ctx->is_enabled == state) { + return 0; + } + + ctx->is_enabled = state; + + if (!state) { + if (ppp->stop) { + ppp->stop(net_if_get_device(iface)); + } + } else { + if (ppp->start) { + ppp->start(net_if_get_device(iface)); + } + } + return 0; +} + +NET_L2_INIT(PPP_L2, ppp_recv, ppp_send, ppp_enable, ppp_flags); #if defined(CONFIG_NET_SHELL) static int get_ppp_context(int idx, struct ppp_context **ctx,