Hi Ivan, I moved your callback up a little. Also, I see that your have both IPv6 and IPv4 enabled. I will recommend disabling IPv4 in your lwipopts.h file temporarily (by #define LWIP_IPV4 0) and see if you can get IPv6 to run by itself first. Once you get that working, then you can consider running the dual stack.
~Edman From: lwip-users <lwip-users-bounces+edmangzayzay=eaton....@nongnu.org> On Behalf Of Jiang Peng Sent: Sunday, November 14, 2021 8:02 PM To: Mailing list for lwIP users <lwip-users@nongnu.org> Subject: Re: [lwip-users] [EXTERNAL] lwip IPV6 PPP only get link local address and cannot connect to server Hi Edman, thanks for the info. I use the STM32 cellular PPP client. It looks like the example code you have, but does a little bit more. I also add some logs to trace the Router Advertisemen and nd6_send_rs. But only IPV6 LL address received. Really appreciate your help. thanks a lot. Ivan /////////////////////////////log////////////////////////////////////////////////// 33.484 ppposif UTILS: our_ipaddr = 10.115.108.187 33.484 ppposif UTILS: his_ipaddr = 10.64.64.64 33.507 ppposif UTILS: netmask = 255.255.255.255 33.507 ppposif UTILS: dns1 = 101.168.244.100 33.507 ppposif UTILS: dns2 = 10.5.136.242 33.507 ppposif UTILS: our6_ipaddr = :: **************************************************nd6_send_rs start **************************************************nd6_send_rs called -4 local IP address 10.115.108.187 remote IP address 10.64.64.64 primary DNS address 101.168.244.100 secondary DNS address 10.5.136.242 ppp phase changed[0]: phase=10 ipv6cp: received interface identifier (fe80::2912:3031:16a9:5f44) (ACK) ipv6cp: upnetif_ip6_addr_set: netif address being changed netif: IPv6 address 0 of interface pp set to FE80::89D7:60FE:FAB3:4E1D/0x0hx netif_ip6_addr_set_state: netif address state being changed CELL_PPP: PPP NETIF interface UP other IPv6 Address: FE80::89D7:60FE:FAB3:4E1D other IPv6 Address: :: other IPv6 Address: :: netif: IPv6 address 0 of interface pp set to FE80::89D7:60FE:FAB3:4E1D/0x0hx sif6up[0]: err_code=0 39.285 ppposif UTILS: 39.285 ppposif UTILS: our_ipaddr = 10.115.108.187 39.285 ppposif UTILS: his_ipaddr = 10.64.64.64 39.308 ppposif UTILS: netmask = 255.255.255.255 39.308 ppposif UTILS: dns1 = 101.168.244.100 39.308 ppposif UTILS: dns2 = 10.5.136.242 39.308 ppposif UTILS: our6_ipaddr = FE80::89D7:60FE:FAB3:4E1D **************************************************nd6_send_rs start **************************************************nd6_send_rs called 0 local LL address fe80::89d7:60fe:fab3:4e1d remote LL address fe80::2912:3031:16a9:5f44 **********************************Router Advertisement 104 **********************************Router Advertisement new 3 **************************************************nd6_send_rs start **************************************************nd6_send_rs called 0 **********************************Router Advertisement 104 **********************************Router Advertisement new 0 On Sat, 13 Nov 2021 at 08:28, Zayzay, Edman G <edmangzay...@eaton.com<mailto:edmangzay...@eaton.com>> wrote: Seems strange though. Because I am using LWIP 2.1.2 and everything is working. Did you register a callback function as follows during your initialization?: ppp_set_netif_statuscallback() ppp_set_netif_linkcallback() your netif_statuscallback should be triggered once the Router Advertisement comes in After the solicitation. That’s where you will see your full IPv6 address. After your pppObject = pppos_create() is successful, you need to do something like this… ppp_set_netif_statuscallback(pppObject, pppNetifStatusCB); Your callback should look something like this static void pppNetifStatusCB (struct netif *netif) { #if LWIP_IPV6 uint8_t i; #endif printf("\r\nCELL_PPP: PPP NETIF interface %s\r\n", netif_is_up(netif) ? "UP" : "DOWN"); #if LWIP_IPV6 // We've been notified that a change is about to take place on the interface. // Check if we now have a routable address instead of Link-local address only. for (i = 0; i < LWIP_IPV6_NUM_ADDRESSES; i++) { if (!ip_addr_isany(netif_ip_addr6(netif, i)) && !ip_addr_islinklocal(netif_ip_addr6(netif, i)) ) { Printf( " Unicast IPv6 Address: %s\r\n", ip6addr_ntoa(netif_ip6_addr(netif, i))); } } #endif } Your can send me snippet of what you are doing if you still have problem. I have tested this on both BG95 and BG96. ~Edman From: lwip-users <lwip-users-bounces+edmangzayzay=eaton....@nongnu.org<mailto:eaton....@nongnu.org>> On Behalf Of Jiang Peng Sent: Friday, November 12, 2021 4:07 PM To: Mailing list for lwIP users <lwip-users@nongnu.org<mailto:lwip-users@nongnu.org>> Subject: Re: [lwip-users] [EXTERNAL] lwip IPV6 PPP only get link local address and cannot connect to server Thanks Edman That is the same place I added, but I don't see ipv6 address get through yet. I also tried 2.1.3 and still same. May I know anything missing? Thanks a lot for your help Ivan On Sat., 13 Nov. 2021, 1:08 am Zayzay, Edman G, <edmangzay...@eaton.com<mailto:edmangzay...@eaton.com>> wrote: Hi Ivan, When you get your callback indicating that the connection is up, that is when you need to send the router solicitation. See the example code below in the following link : https://github.com/particle-iot/lwip-contrib/blob/master/examples/ppp/pppos_example.c Look at line 96 – 98 #if PPP_IPV6_SUPPORT fprintf(stderr, " our6_ipaddr = %s\n\r", ip6addr_ntoa(netif_ip6_addr(pppif, 0))); This is where you send Router Solicitation #endif /* PPP_IPV6_SUPPORT */ From: lwip-users <lwip-users-bounces+edmangzayzay=eaton....@nongnu.org<mailto:eaton....@nongnu.org>> On Behalf Of Jiang Peng Sent: Thursday, November 11, 2021 6:41 PM To: Mailing list for lwIP users <lwip-users@nongnu.org<mailto:lwip-users@nongnu.org>> Subject: Re: [lwip-users] [EXTERNAL] lwip IPV6 PPP only get link local address and cannot connect to server Hi Edman, Thanks a lot for the information. It appears that is the same issue I faced. I tried your suggestion, to add nd6_send_rs, but nothing happened, or I just add it in wrong place(I call it in ppposif.c). Could you please shed some light on how to send this rs? Upgrading to 2.1.3 may not be an option for me for now. thanks a lot Ivan On Fri, 12 Nov 2021 at 01:08, Zayzay, Edman G <edmangzay...@eaton.com<mailto:edmangzay...@eaton.com>> wrote: Hi Ivan, You need to explicitly send a router solicitation to the network in other to get the full IPv6 Address. The function to call is nd6_send_rs() in n6.c . However, this is a static function and you may have to create a wrapper to call it. As of yesterday, LWIP 2.1.3 was released and they now send RS automatically for IPv6. Hope this helps as I had the same issue 9 months ago. Edman From: lwip-users <lwip-users-bounces+edmangzayzay=eaton....@nongnu.org<mailto:eaton....@nongnu.org>> On Behalf Of Jiang Peng Sent: Wednesday, November 10, 2021 6:40 PM To: lwip-users@nongnu.org<mailto:lwip-users@nongnu.org> Subject: [EXTERNAL] [lwip-users] lwip IPV6 PPP only get link local address and cannot connect to server Hi everyone, I have a project that is running LwIP V2.1.2. The stack is LwIP on top of BG96 cellular modem. It works fine for IPV4, but when I enable IPV6, I only get IPV6 link local address, and cannot get real IPV6 address, therefore, I cannot connect to my server. The LwIP comes from ST cellular expansion package. I enable the log, and it got local and remote LL address, but after that never got any real address, and cannot connect to my server. thanks a lot for any hints or suggestions. thanks Ivan ////////////////////////////////////////////////////////////////////////////logs ////////////////////////////////////////////////////////////////////// 05.535 atcmd BG96:Activate PDN (user cid = 1, modem cid = 1) 05.542 atcmd BG96:MODEM SWITCHES TO DATA MODE 05.542 atcmd ATCore:<<< DATA MODE SELECTED >>> ppposif_client_confignetif: netmask of interface set to 255.255.255.255 netif: added interface pp IP addr 0.0.0.0 netmask 255.255.255.255 gw 0.0.0.0 ppp phase changed[0]: phase=0 netif: setting default interface pp netif: setting default interface pp client ppp_notify_phase_cb: PPP_PHASE_DEADppposif_client_dead: DC_SERVICE_OFF 06.035 iot_cell =====>CST_notif_callback (Data Cache event=0) ppp_connect[0]: holdoff=0 ppp phase changed[0]: phase=3 client ppp_notify_phase_cb: PPP_PHASE_INITIALIZEpppos_connect: unit 0: connecting ppp_start[0] ppp phase changed[0]: phase=6 pppos_send_config[0]: out_accm=FF FF FF FF ppp_send_config[0] pppos_recv_config[0]: in_accm=FF FF FF FF ppp_recv_config[0] ppp: auth protocols: PAP=0 pppos_write[0]: len=24 ppp_start[0]: finished pppos_input[0]: got 61 bytes pbuf_remove_header: old 0x24016058 new 0x2401605a (2) No auth is possible lcp_reqci: returning CONFREJ.pppos_write[0]: len=13 tcpip_inpkt: PACKET 0x24016258/0x2400eae8 pppos_input[0]: got 7 bytes pbuf_remove_header: old 0x24016058 new 0x2401605a (2) tcpip_inpkt: PACKET 0x24016258/0x2400eae8 pppos_input[0]: got 1 bytes tcpip_inpkt: PACKET 0x24016258/0x2400eae8 pppos_input[0]: got 44 bytes pbuf_remove_header: old 0x24016058 new 0x2401605a (2) lcp_reqci: returning CONFACK.pppos_write[0]: len=24 netif_set_mtu[0]: mtu=1500 pppos_send_config[0]: out_accm=0 0 0 0 ppp_send_config[0] pppos_recv_config[0]: in_accm=0 0 0 0 ppp_recv_config[0] ppp phase changed[0]: phase=7 07.031 iot_cell =====>CST_notif_callback (Data Cache event=2) 07.128 iot_cell =====>CST_notif_callback (Data Cache event=0) 07.128 iot_cell =====>CST_notif_callback (Data Cache event=1) 07.128 iot_cell -----> New State: CST_PPP_CONFIG_ON_GOING_STATE <----- 07.128 iot_cell ============ CST_cellular_service_task : autom_event = no event mtd_init.c +301 StartIoTTask Modem state is 18, ST Safe found ppp phase changed[0]: phase=9 pppos_input[0]: got 21 bytes ipv6cp: received interface identifier (fe80::1525:f2b1:ebca:3352) (ACK) ipv6cp: returning Configure-ACKpppos_write[0]: len=18 tcpip_inpkt: PACKET 0x24016258/0x2400eae8 pppos_input[0]: got 20 bytes pbuf_remove_header: old 0x24016058 new 0x2401605a (2) local LL address fe80::d823:7001:beb5:b051pppos_write[0]: len=18 tcpip_inpkt: PACKET 0x24016258/0x2400eae8 pppos_input[0]: got 1 bytes tcpip_inpkt: PACKET 0x24016258/0x2400eae8 pppos_input[0]: got 19 bytes pbuf_remove_header: old 0x24016058 new 0x2401605a (2) ipv6cp: upnetif_ip6_addr_set: netif address being changed netif: IPv6 address 0 of interface pp set to FE80::D823:7001:BEB5:B051/0x0hx netif_ip6_addr_set_state: netif address state being changed netif: IPv6 address 0 of interface pp set to FE80::D823:7001:BEB5:B051/0x0hx sif6up[0]: err_code=0 our_ipaddr = 0.0.0.0 his_ipaddr = 0.0.0.0 netmask = 255.255.255.255 dns1 = 8.8.8.8 dns2 = 8.8.4.4 our6_ipaddr = FE80::D823:7001:BEB5:B051 local LL address fe80::d823:7001:beb5:b051 remote LL address fe80::1525:f2b1:ebca:3352 ppp phase changed[0]: phase=10 -- Jiang Peng _______________________________________________ lwip-users mailing list lwip-users@nongnu.org<mailto:lwip-users@nongnu.org> https://lists.nongnu.org/mailman/listinfo/lwip-users -- Jiang Peng _______________________________________________ lwip-users mailing list lwip-users@nongnu.org<mailto:lwip-users@nongnu.org> https://lists.nongnu.org/mailman/listinfo/lwip-users _______________________________________________ lwip-users mailing list lwip-users@nongnu.org<mailto:lwip-users@nongnu.org> https://lists.nongnu.org/mailman/listinfo/lwip-users -- Jiang Peng
/** ****************************************************************************** * @file ppposif_client.c * @author MCD Application Team * @brief This file contains pppos client adatation layer ****************************************************************************** * @attention * * <h2><center>© Copyright (c) 2018 STMicroelectronics. * All rights reserved.</center></h2> * * This software component is licensed by ST under Ultimate Liberty license * SLA0044, the "License"; You may not use this file except in compliance with * the License. You may obtain a copy of the License at: * www.st.com/SLA0044 * ****************************************************************************** */ /* Includes ------------------------------------------------------------------*/ #include <stdbool.h> #include "ppposif_client.h" #include "plf_config.h" #if (USE_SOCKETS_TYPE == USE_SOCKETS_LWIP) /* LwIP is a Third Party so MISRAC messages linked to it are ignored */ /*cstat -MISRAC2012-* */ #include "ppp.h" /*cstat +MISRAC2012-* */ #include "ppposif.h" #include "ipc_uart.h" #include "ppposif_ipc.h" #include "rtosal.h" #include "main.h" #include "error_handler.h" #include "trace_interface.h" #include "dc_common.h" #include "cellular_service_datacache.h" #include "ppp.h" /* Private defines -----------------------------------------------------------*/ #define IPC_DEVICE IPC_DEVICE_0 #define PPPOSIF_CONFIG_TIMEOUT_VALUE 15000U #define PPPOSIF_CONFIG_FAIL_MAX 3 /* Private typedef -----------------------------------------------------------*/ /* Private macros ------------------------------------------------------------*/ /* Private variables ---------------------------------------------------------*/ static struct netif gnetif_ppp_client; static ppp_pcb *ppp_pcb_client; static osTimerId ppposif_config_timeout_timer_handle; static osSemaphoreId sem_ppp_init_client = NULL; /* Global variables ----------------------------------------------------------*/ /* Private function prototypes -----------------------------------------------*/ static void ppp_notify_phase_client_cb(ppp_pcb *pcb, u8_t phase, void *ctx); static void ppposif_client_running(ppp_pcb *pcb); static void ppposif_client_dead(void); static void ppposif_reconf(void); static void ppposif_client_thread(void *argument); static void ppposif_config_timeout_timer_callback(void const *argument); /* Functions Definition ------------------------------------------------------*/ /* Private Functions Definition ------------------------------------------------------*/ /* Notify phase callback (PPP_NOTIFY_PHASE) ========================================== Notify phase callback, enabled using the PPP_NOTIFY_PHASE config option, let you configure a callback that is called on each PPP internal state change. This is different from the status callback which only warns you about up(running) and down(dead) events. Notify phase callback can be used, for example, to set a LED pattern depending on the current phase of the PPP session. Here is a callback example which tries to mimic what we usually see on xDSL modems while they are negotiating the link, which should be self-explanatory: */ static void ppp_notify_phase_client_cb(ppp_pcb *pcb, u8_t phase, void *ctx) { UNUSED(ctx); (void)rtosalDelay(500U); /* hack, add a delay to avoid race condition with Modem which sends an LCP Request earlier. To be improved by syncing the input reading and PPP state machine */ switch (phase) { /* Session is down (either permanently or briefly) */ case PPP_PHASE_DEAD: PRINT_PPPOSIF("client ppp_notify_phase_cb: PPP_PHASE_DEAD") ppposif_client_dead(); break; /* We are between two sessions */ case PPP_PHASE_HOLDOFF: PRINT_PPPOSIF("client ppp_notify_phase_cb: PPP_PHASE_HOLDOFF") ppposif_reconf(); break; /* Session just started */ case PPP_PHASE_INITIALIZE: PRINT_PPPOSIF("client ppp_notify_phase_cb: PPP_PHASE_INITIALIZE") break; /* Session is running */ case PPP_PHASE_RUNNING: PRINT_PPPOSIF("client ppp_notify_phase_cb: PPP_PHASE_RUNNING") ppposif_client_running(pcb); break; default: break; } } /* ppposif thread */ static void ppposif_client_thread(void *argument) { UNUSED(argument); (void)rtosalSemaphoreAcquire(sem_ppp_init_client, RTOSAL_WAIT_FOREVER); while (true) { ppposif_input(&gnetif_ppp_client, ppp_pcb_client, IPC_DEVICE); } } static void ppposif_client_running(ppp_pcb *pcb) { dc_cellular_info_t cellular_info; struct netif *pppif; pppif = ppp_netif((pcb)); (void)rtosalTimerStop(ppposif_config_timeout_timer_handle); (void)dc_com_read(&dc_com_db, DC_CELLULAR_INFO, (void *)&cellular_info, sizeof(cellular_info)); cellular_info.rt_state_ppp = DC_SERVICE_ON; cellular_info.ip_addr = pppif->ip_addr; (void)dc_com_write(&dc_com_db, DC_CELLULAR_INFO, (void *)&cellular_info, sizeof(cellular_info)); } static void ppposif_client_dead(void) { dc_cellular_info_t cellular_info; (void)dc_com_read(&dc_com_db, DC_CELLULAR_INFO, (void *)&cellular_info, sizeof(cellular_info)); PRINT_PPPOSIF("ppposif_client_dead: DC_SERVICE_OFF\r\n") cellular_info.rt_state_ppp = DC_SERVICE_OFF; (void)dc_com_write(&dc_com_db, DC_CELLULAR_INFO, (void *)&cellular_info, sizeof(cellular_info)); } static void ppposif_reconf(void) { dc_cellular_info_t cellular_info; (void)ppp_close(ppp_pcb_client, 0U); PRINT_PPPOSIF("ppposif_config_timeout_timer_callback") (void)dc_com_read(&dc_com_db, DC_CELLULAR_INFO, (void *)&cellular_info, sizeof(cellular_info)); cellular_info.rt_state_ppp = DC_SERVICE_FAIL; (void)dc_com_write(&dc_com_db, DC_CELLULAR_INFO, (void *)&cellular_info, sizeof(cellular_info)); } static void ppposif_config_timeout_timer_callback(void const *argument) { UNUSED(argument); ppposif_reconf(); } /* Exported functions Definition ------------------------------------------------------*/ /** * @brief component init * @param none * @retval ppposif_status_t return status */ ppposif_status_t ppposif_client_init(void) { ppposif_ipc_init(IPC_DEVICE); return PPPOSIF_OK; } /** * @brief component start * @param none * @retval ppposif_status_t return status */ ppposif_status_t ppposif_client_start(void) { static osThreadId pppClientThreadId = NULL; ppposif_status_t ret = PPPOSIF_OK; PRINT_PPPOSIF("ppposif_client_config") sem_ppp_init_client = rtosalSemaphoreNew((const rtosal_char_t *)"SEM_PPP_CLIENT_INIT", (uint16_t) 1U); (void)rtosalSemaphoreAcquire(sem_ppp_init_client, RTOSAL_WAIT_FOREVER); ppposif_config_timeout_timer_handle = rtosalTimerNew((const rtosal_char_t *)"PPPOSIF_CONFIG_TIMEOUT_timer", (os_ptimer)ppposif_config_timeout_timer_callback, osTimerOnce, NULL); pppClientThreadId = rtosalThreadNew((const rtosal_char_t *)"PPPosifClt", (os_pthread) ppposif_client_thread, PPPOSIF_CLIENT_THREAD_PRIO, (uint32_t)PPPOSIF_CLIENT_THREAD_STACK_SIZE, NULL); if (pppClientThreadId == NULL) { ERROR_Handler(DBG_CHAN_PPPOSIF, 1, ERROR_FATAL); } return ret; } extern err_t nd6_send_rs(struct netif *netif); static void pppNetifStatusCB (struct netif *netif) { #if LWIP_IPV6 uint8_t i; #endif printf("\r\nCELL_PPP: PPP NETIF interface %s\r\n", netif_is_up(netif) ? "UP" : "DOWN"); #if LWIP_IPV6 // We've been notified that a change is about to take place on the interface. // Check if we now have a routable address instead of Link-local address only. for (i = 0; i < LWIP_IPV6_NUM_ADDRESSES; i++) { if (!ip_addr_isany(netif_ip_addr6(netif, i)) && !ip_addr_islinklocal(netif_ip_addr6(netif, i)) ) { printf( " Unicast IPv6 Address: %s\r\n", ip6addr_ntoa(netif_ip6_addr(netif, i))); } else { printf( " other IPv6 Address: %s\r\n", ip6addr_ntoa(netif_ip6_addr(netif, i))); } } #endif //nd6_send_rs(netif); } /** * @brief Create a new PPPoS client interface * @param none * @retval ppposif_status_t return status */ ppposif_status_t ppposif_client_config(void) { static uint32_t ppposif_create_done = 0U; err_t ppp_err; ppposif_status_t ret = PPPOSIF_OK; PRINT_PPPOSIF("ppposif_client_config") ppposif_ipc_select(IPC_DEVICE); if (ppposif_create_done == 0U) { ppp_pcb_client = pppos_create(&gnetif_ppp_client, ppposif_output_cb, ppposif_status_cb, (void *)IPC_DEVICE); if (ppp_pcb_client == NULL) { ret = PPPOSIF_ERROR; ERROR_Handler(DBG_CHAN_PPPOSIF, 3, ERROR_FATAL); } else { netif_set_default(&gnetif_ppp_client); ppposif_create_done = 1U; } } if (ret == PPPOSIF_OK) { ppp_set_default((ppp_pcb_client)); ppp_set_notify_phase_callback(ppp_pcb_client, ppp_notify_phase_client_cb); ppp_set_usepeerdns((ppp_pcb_client), (1)); ppp_set_netif_statuscallback(ppp_pcb_client, pppNetifStatusCB);//add by me /* ppp_set_auth(ppp_pcb_client, PPPAUTHTYPE_PAP, "USER", "PASS"); */ (void)rtosalTimerStart(ppposif_config_timeout_timer_handle, PPPOSIF_CONFIG_TIMEOUT_VALUE); ppp_err = ppp_connect(ppp_pcb_client, 0U); (void)rtosalSemaphoreRelease(sem_ppp_init_client); if (ppp_err != (err_t)ERR_OK) { printf("ppp connection error %d\r\n", ppp_err); ret = PPPOSIF_ERROR; } } return ret; } /** * @brief close a PPPoS client interface * @param none * @retval ppposif_status_t return status */ ppposif_status_t ppposif_client_close(uint8_t cause) { dc_cellular_info_t cellular_info; PRINT_PPPOSIF("ppposif_client_close") (void)rtosalTimerStop(ppposif_config_timeout_timer_handle); if (cause == PPPOSIF_CAUSE_POWER_OFF) { PRINT_PPPOSIF("ppposif_client_close : Closing PPP for POWER OFF") (void) ppposif_close(ppp_pcb_client); } else { (void)dc_com_read(&dc_com_db, DC_CELLULAR_INFO, (void *)&cellular_info, sizeof(cellular_info)); cellular_info.rt_state_ppp = DC_SERVICE_FAIL; (void)dc_com_write(&dc_com_db, DC_CELLULAR_INFO, (void *)&cellular_info, sizeof(cellular_info)); } return PPPOSIF_OK; } #endif /* USE_SOCKETS_TYPE == USE_SOCKETS_LWIP */ /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
_______________________________________________ lwip-users mailing list lwip-users@nongnu.org https://lists.nongnu.org/mailman/listinfo/lwip-users