Skip to content

Commit

Permalink
refactor ppp codec.c
Browse files Browse the repository at this point in the history
  • Loading branch information
w180112 committed Nov 11, 2023
1 parent e5b725c commit 90645f3
Show file tree
Hide file tree
Showing 7 changed files with 396 additions and 348 deletions.
18 changes: 15 additions & 3 deletions src/cmds.c
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,11 @@ static void cmd_quit_parsed(__attribute__((unused)) void *parsed_result,
__attribute__((unused)) struct cmdline *cl,
__attribute__((unused)) void *data)
{
tVRG_MBX *mail = (tVRG_MBX *)rte_malloc(NULL,sizeof(tVRG_MBX),0);
tVRG_MBX *mail = (tVRG_MBX *)rte_malloc(NULL, sizeof(tVRG_MBX), 0);
if (mail == NULL) {
cmdline_printf(cl, "cmd_quit_parsed failed: rte_malloc failed: %s\n", rte_strerror(rte_errno));
return;
}
cli_to_main_msg_t *msg = (cli_to_main_msg_t *)mail->refp;

msg->type = CLI_QUIT;
Expand Down Expand Up @@ -244,7 +248,11 @@ static void cmd_connect_parsed( void *parsed_result,
__attribute__((unused)) void *data)
{
struct cmd_connect_result *res = parsed_result;
tVRG_MBX *mail = (tVRG_MBX *)rte_malloc(NULL,sizeof(tVRG_MBX),0);
tVRG_MBX *mail = (tVRG_MBX *)rte_malloc(NULL, sizeof(tVRG_MBX), 0);
if (mail == NULL) {
cmdline_printf(cl, "cmd_connect_parsed failed: rte_malloc failed: %s\n", rte_strerror(rte_errno));
return;
}
cli_to_main_msg_t *msg = (cli_to_main_msg_t *)mail->refp;

if (strcmp(res->connect, "connect") == 0)
Expand Down Expand Up @@ -304,7 +312,11 @@ static void cmd_dhcp_parsed( void *parsed_result,
__attribute__((unused)) void *data)
{
struct cmd_dhcp_result *res = parsed_result;
tVRG_MBX *mail = (tVRG_MBX *)rte_malloc(NULL,sizeof(tVRG_MBX),0);
tVRG_MBX *mail = (tVRG_MBX *)rte_malloc(NULL, sizeof(tVRG_MBX), 0);
if (mail == NULL) {
cmdline_printf(cl, "cmd_dhcp_parsed failed: rte_malloc failed: %s\n", rte_strerror(rte_errno));
return;
}
cli_to_main_msg_t *msg = (cli_to_main_msg_t *)mail->refp;

if (strcmp(res->cmd, "start") == 0)
Expand Down
14 changes: 12 additions & 2 deletions src/dp.c
Original file line number Diff line number Diff line change
Expand Up @@ -127,12 +127,17 @@ int wan_recvd(void *arg)
struct rte_mbuf *pkt[BURST_SIZE];
U16 ori_port_id, nb_rx;
ppp_payload_t *ppp_payload;
tVRG_MBX *mail = rte_malloc(NULL,sizeof(tVRG_MBX)*32,65536);
tVRG_MBX *mail = rte_malloc(NULL, sizeof(tVRG_MBX)*32, 65536);
int i;
U32 icmp_new_cksum;
char *cur;
U16 user_index;
VRG_t *vrg_ccb = (VRG_t *)arg;

if (mail == NULL) {
VRG_LOG(ERR, vrg_ccb->fp, NULL, NULL, "wan_recvd failed: rte_malloc failed: %s\n", rte_strerror(rte_errno));
return -1;
}

usleep(500000);
for(;;) {
Expand Down Expand Up @@ -765,7 +770,12 @@ void drv_xmit(VRG_t *vrg_ccb, U8 *mu, U16 mulen)
static int lsi_event_callback(U16 port_id, enum rte_eth_event_type type, void *param)
{
struct rte_eth_link link;
tVRG_MBX *mail = (tVRG_MBX *)rte_malloc(NULL,sizeof(tVRG_MBX),2048);
tVRG_MBX *mail = (tVRG_MBX *)rte_malloc(NULL, sizeof(tVRG_MBX), 2048);

if (mail == NULL) {
VRG_LOG(ERR, NULL, NULL, NULL, "lsi_event_callback failed: rte_malloc failed: %s\n", rte_strerror(rte_errno));
return -1;
}

RTE_SET_USED(param);

Expand Down
Loading

0 comments on commit 90645f3

Please sign in to comment.