hi
I am using K60 MQX+RTCS and using PPP over a GPRS modem.
The problem I am facing with PPP is that I am able to get connected and view the assigned IPs but the default route is not getting added. As a result, basic 'ping' itself doesn't work.
There is once place though where I have commented the code:
- first we open the serial port and assign to PPP_CON_DEV_HANDLE: this succeeds:
/* Open serial device. */
default_ppp.PPP_CON_DEV_HANDLE = fopen(default_ppp.PPP_CONNECTION_DEVICE, NULL);
- However, the following fails - why it fails I can't understand:
/* Open PPP like client. */
default_ppp.PPP_DEV_HANDLE = fopen("dcn:", (char_ptr)default_ppp.PPP_CON_DEV_HANDLE);
/* Checking, does it open ? */
if(default_ppp.PPP_DEV_HANDLE == NULL)
{
if(default_ppp.PPP_CON_DEV_HANDLE)
{
/* Close PPP_DEVICE. */
fclose(default_ppp.PPP_CON_DEV_HANDLE);
}
printf("\n ERROR: Can not open \"dcn\" PPP driver.\n");
return RTCS_ERROR;
}
}
- So, I commented the PPP_DEV_HANDLE and using PPP_CON_DEV_HANDLE in '_io_pcbppp_hdlc_init()'.
I have set 'DEFAULT_ROUTE' to TRUE in the 'ipcp_data' structure.
I traced the code in the IP Stack and found that 'IPCP_up()' which is supposed to set the default route is not getting called.
Can anybody provide pointers on the possible cause of the problem?
I tried adding a default route using 'RTCS_gate_add()' with the peer IP address as the gateway but even that doesn't work. If I print the routes using 'RTCS_walk_route()" shows this newly added route as a 'INDIRECT ROUTE'. The ethernet interface route appears as a 'DIRECT ROUTE'. What's the difference between 'INDIRECT' and 'DIRECT' routes.
My 'ppp_start()' code is given below:
void ppp_start(PPP_LINK_DETAILS_STRUCT *ppp_current)
{
uint_32 error;
_ip_address local_address;
_ip_address peer_address=0;
IPCP_DATA_STRUCT ipcp_data;
// PAP configuration
char* localname = ppp_current->LOCAL_NAME;
char* localsecret = ppp_current->LOCAL_PASSWORD;
PPP_SECRET lsecret;
// Setup PAP for client mode
lsecret.PPP_ID_LENGTH = strlen(localname);
lsecret.PPP_PW_LENGTH = strlen(localsecret);
lsecret.PPP_ID_PTR = localname;
lsecret.PPP_PW_PTR = localsecret;
_PPP_PAP_LSECRET = &lsecret; /* lsecrets */
_PPP_PAP_RSECRETS = NULL; /* rsecrets */
_PPP_CHAP_LNAME = NULL; /* localname */
_PPP_CHAP_LSECRETS = NULL; /* lsecrets */
_PPP_CHAP_RSECRETS = NULL; /* rsecrets */
ppp_current->PPP_IO_DRIVER_HANDLE = _iopcb_ppphdlc_init(ppp_current->PPP_CON_DEV_HANDLE);
_PPP_ACCM = 0;
error = PPP_initialize(ppp_current->PPP_IO_DRIVER_HANDLE, &ppp_current->PPP_HANDLE);
if (error)
{
printf("\n PPP initialize: %lx", error);
_task_block();
}
_iopcb_open(ppp_current->PPP_IO_DRIVER_HANDLE, PPP_lowerup, PPP_lowerdown,ppp_current->PPP_HANDLE);
error = RTCS_if_add(ppp_current->PPP_HANDLE, RTCS_IF_PPP, &ppp_current->PPP_IF_HANDLE);
if (error)
{
printf("\n IF add failed, error = %lx", error);
_task_block();
}
_lwsem_create(&ppp_current->PPP_SEM, 0);
_mem_zero(&ipcp_data, sizeof(ipcp_data));
ipcp_data.IP_UP = PPP_linkup;
ipcp_data.IP_DOWN = PPP_linkdown;
ipcp_data.IP_PARAM = &ppp_current->PPP_SEM;
ipcp_data.ACCEPT_LOCAL_ADDR = TRUE;
ipcp_data.ACCEPT_REMOTE_ADDR = TRUE;
ipcp_data.LOCAL_ADDR = 0; //ppp_current->PPP_LOCAL_ADDRESS;
ipcp_data.REMOTE_ADDR = 0; //ppp_current->PPP_REMOTE_ADDRESS;
ipcp_data.DEFAULT_NETMASK = TRUE;
ipcp_data.DEFAULT_ROUTE = TRUE;
error = RTCS_if_bind_IPCP(ppp_current->PPP_IF_HANDLE, &ipcp_data);
if (error)
{
printf("\n IF bind failed, error = %lx", error);
_task_block();
}
/*In case "client" we need wait for connection to server*/
printf("\n Please wait initiate PPP connection. Waiting...\n");
// Handshake with RAS server
// 10 attempts to connect
error = 0;
while (error < 10)
{
if (PPP_link == FALSE)
{
_time_delay(1000);
}
else
{
printf("\n PPP_link = %d, time = %d\n",PPP_link,error);
break;
}
error ++;
}
if (PPP_link == TRUE)
{
local_address = IPCP_get_local_addr(ppp_current->PPP_IF_HANDLE);
peer_address = IPCP_get_peer_addr(ppp_current->PPP_IF_HANDLE);
printf("\n PPP device on %s is bound on.\n", ppp_current->PPP_CONNECTION_DEVICE );
printf(" PPP local address is : %d.%d.%d.%d\n", IPBYTES(local_address));
printf(" PPP remote address is : %d.%d.%d.%d\n", IPBYTES(peer_address));
printf(" Now PPP connection is established on %d.%d.%d.%d\n", IPBYTES(peer_address));
/* Install a route for a default gateway */
RTCS_gate_add(peer_address, 0, 0);
}
else
{
if(ppp_current->PPP_HANDLE)
{
/* clean up all PPP structure */
error = PPP_shutdown(ppp_current->PPP_HANDLE);
}
ppp_current->PPP_HANDLE = NULL;
// We should remove route to clear part block.
RTCS_gate_remove(ppp_current->PPP_GATE_ADDR, INADDR_ANY, INADDR_ANY);
}
}
Hi Nagaraj,
Could you test using the latest version of MQX?
According to the release notes there are several bug fixes to RTCS PPP in MQX 4.0.
Regards
Sol
Hi,
Thank you, this problem has been solved. The root cause was that I was not initialising the _PPP_PAP_LSECRET pointer.
I went thro' the manual and found that the default values (NULL values for username, password, etc) were suitable for me and didn't think it necessary to initialise it. However, after initialising the '_PPP_PAP_LSECRET' pointer, things started working.
however, I am now hit with another issue - I am able to 'ping' an outside IP address from the K60 over the PPP interface, but I am not able to ping the PPP interface's IP address of the K60 from my PC. Any reasons for this?
I have enabled 'RTCSCFG_ICMP_ENABLE' in 'user_config.h'. The strange thing is that on Ethernet side, I am getting ping responses but not on the PPP side.