Re: [vpp-dev] VAPI ACL addition. Not getting ACL index in response. #acl #acl_plugin #vapi

2021-08-30 Thread RaviKiran Veldanda
[Edited Message Follows]

Sorry for spamming, anyway, I found the problem.
I was sending wrong response structure causing the problem.
We supposed to use,
*vapi_msg_acl_add_replace_reply* *resp; but I was using 
*vapi_payload_acl_add_replace_reply* *resp;
Its working fine.
Just incase some one wants to use above example, providing working one below.
printf ("--- Basic acl addition- reply test ---\n");
vapi_msg_acl_add_replace *acl= vapi_alloc_acl_add_replace(ctx, 1);
if(acl==NULL)
{
printf("ACL retuns NULL %d\n",__LINE__);
exit(1);
}
acl->payload.acl_index=-1;
strncpy((char *)acl->payload.tag,"CheckIsWorking",12);
acl->payload.count=1;
vapi_type_prefix src_addr,dst_addr;
acl->payload.r[0].is_permit=1;
src_addr.address.af=0;
src_addr.len=24;//prefix len
inet_aton("172.1.1.0",(struct in_addr *)&(src_addr.address.un.ip4));
dst_addr.address.af=0;
dst_addr.len=24;//prefix len
inet_aton("111.1.1.0",(struct in_addr *)&(dst_addr.address.un.ip4));
acl->payload.r[0].src_prefix=src_addr;
acl->payload.r[0].dst_prefix=dst_addr;
vapi_msg_acl_add_replace_hton(acl);
rv = vapi_send (ctx, acl);
if(rv!=VAPI_OK)
{
printf("vapi_Send %d\n",__LINE__);
exit(1);

}
vapi_msg_acl_add_replace_reply *resp;
size_t size;
rv = vapi_recv (ctx, (void *) &resp, &size, 0, 0);
if(rv!=VAPI_OK)
{
printf("vapi_Send %d\n",__LINE__);
exit(1);
}
vapi_msg_acl_add_replace_reply_ntoh(resp);
printf("So the reply receivied ACL Index %d Retval 
%d\n",resp->payload.acl_index,resp->payload.retval);

vapi_msg_free (ctx, resp);

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#20049): https://lists.fd.io/g/vpp-dev/message/20049
Mute This Topic: https://lists.fd.io/mt/85263360/21656
Mute #vapi:https://lists.fd.io/g/vpp-dev/mutehashtag/vapi
Mute #acl_plugin:https://lists.fd.io/g/vpp-dev/mutehashtag/acl_plugin
Mute #acl:https://lists.fd.io/g/vpp-dev/mutehashtag/acl
Group Owner: vpp-dev+ow...@lists.fd.io
Unsubscribe: https://lists.fd.io/g/vpp-dev/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



Re: [vpp-dev] VAPI ACL addition. Not getting ACL index in response. #acl #acl_plugin #vapi

2021-08-30 Thread RaviKiran Veldanda
Sorry for spamming, anyway, I found the problem.
I was sending wrong response structure causing the problem.
We supposed to use,
*vapi_msg_acl_add_replace_reply* *resp;
*vapi_payload_acl_add_replace_reply* *resp;
Its working fine.
Just incase some one wants to use above example, providing working one below.
printf ("--- Basic acl addition- reply test ---\n");
vapi_msg_acl_add_replace *acl= vapi_alloc_acl_add_replace(ctx, 1);
if(acl==NULL)
{
printf("ACL retuns NULL %d\n",__LINE__);
exit(1);
}
acl->payload.acl_index=-1;
strncpy((char *)acl->payload.tag,"CheckIsWorking",12);
acl->payload.count=1;
vapi_type_prefix src_addr,dst_addr;
acl->payload.r[0].is_permit=1;
src_addr.address.af=0;
src_addr.len=24;//prefix len
inet_aton("172.1.1.0",(struct in_addr *)&(src_addr.address.un.ip4));
dst_addr.address.af=0;
dst_addr.len=24;//prefix len
inet_aton("111.1.1.0",(struct in_addr *)&(dst_addr.address.un.ip4));
acl->payload.r[0].src_prefix=src_addr;
acl->payload.r[0].dst_prefix=dst_addr;
vapi_msg_acl_add_replace_hton(acl);
rv = vapi_send (ctx, acl);
if(rv!=VAPI_OK)
{
printf("vapi_Send %d\n",__LINE__);
exit(1);

}
vapi_msg_acl_add_replace_reply *resp;
size_t size;
rv = vapi_recv (ctx, (void *) &resp, &size, 0, 0);
if(rv!=VAPI_OK)
{
printf("vapi_Send %d\n",__LINE__);
exit(1);
}
vapi_msg_acl_add_replace_reply_ntoh(resp);
printf("So the reply receivied ACL Index %d Retval 
%d\n",resp->payload.acl_index,resp->payload.retval);

vapi_msg_free (ctx, resp);

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#20049): https://lists.fd.io/g/vpp-dev/message/20049
Mute This Topic: https://lists.fd.io/mt/85263360/21656
Mute #vapi:https://lists.fd.io/g/vpp-dev/mutehashtag/vapi
Mute #acl_plugin:https://lists.fd.io/g/vpp-dev/mutehashtag/acl_plugin
Mute #acl:https://lists.fd.io/g/vpp-dev/mutehashtag/acl
Group Owner: vpp-dev+ow...@lists.fd.io
Unsubscribe: https://lists.fd.io/g/vpp-dev/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



[vpp-dev] VAPI ACL addition. Not getting ACL index in response. #acl #acl_plugin #vapi

2021-08-30 Thread RaviKiran Veldanda
[Edited Message Follows]

Hi Experts,
We are trying to use VPP-API(VAPI) to create ACL rules.
We are using the VAPI in blocking mode to get response immediately.
We are getting the response back but the *ACL-INDEX is some other value*. Can 
you please see the below code, if I am doing something wrong.
Any pointers are big help.

printf ("--- Basic acl addition- reply test ---\n");
vapi_msg_acl_add_replace *acl= vapi_alloc_acl_add_replace(ctx, 1);
if(acl==NULL)
{
printf("ACL retuns NULL %d\n",__LINE__);
exit(1);
}
acl->payload.acl_index=-1;
strncpy((char *)acl->payload.tag,"CheckIsWorking",12);
acl->payload.count=1;
vapi_type_prefix src_addr,dst_addr;
acl->payload.r[0].is_permit=1;
src_addr.address.af=0;
src_addr.len=24;//prefix len
inet_aton("172.1.1.0",(struct in_addr *)&(src_addr.address.un.ip4));
dst_addr.address.af=0;
dst_addr.len=24;//prefix len
inet_aton("111.1.1.0",(struct in_addr *)&(dst_addr.address.un.ip4));
acl->payload.r[0].src_prefix=src_addr;
acl->payload.r[0].dst_prefix=dst_addr;
vapi_msg_acl_add_replace_hton(acl);
rv = vapi_send (ctx, acl);
if(rv!=VAPI_OK)
{
printf("vapi_Send %d\n",__LINE__);
exit(1);

}
vapi_payload_acl_add_replace_reply *resp;
size_t size;
rv = vapi_recv (ctx, (void *) &resp, &size, 0, 0);
if(rv!=VAPI_OK)
{
printf("vapi_Send %d\n",__LINE__);
exit(1);
}
printf("So the reply receivied ACL Index %d Retval 
%d\n",resp->acl_index,resp->retval);
vapi_msg_free (ctx, resp);
*This is our testing Output:*
# ./vapi_cli
--- Basic show version message - reply test ---
show_version_reply: program: `vpe', version: `21.06.0-2~g99c146915-dirty', 
build directory: `/opt/vpp', build date: `2021-07-29T16:36:55'
--- Basic acl addition- reply test ---
So the reply receivied *ACL Index 42754 Retval 0*

*VPP created the ACL:
*
# vppctl show acl-plugin acl
acl-index 0 count 1 tag {CheckIsWorki}
0: ipv4 permit src 172.0.1.0/24 dst 111.0.1.0/24 proto 0 sport 0 dport 0
acl-index 1 count 1 tag {CheckIsWorki}
0: ipv4 permit src 172.1.1.0/24 dst 111.1.1.0/24 proto 0 sport 0 dport 0
acl-index 2 count 1 tag {CheckIsWorki}
0: ipv4 permit src 172.1.1.0/24 dst 111.1.1.0/24 proto 0 sport 0 dport 0
acl-index 3 count 1 tag {CheckIsWorki}
0: ipv4 permit src 172.1.1.0/24 dst 111.1.1.0/24 proto 0 sport 0 dport 0
acl-index 4 count 1 tag {CheckIsWorki}
0: ipv4 permit src 172.1.1.0/24 dst 111.1.1.0/24 proto 0 sport 0 dport 0
acl-index 5 count 1 tag {CheckIsWorki}
0: ipv4 permit src 172.1.1.0/24 dst 111.1.1.0/24 proto 0 sport 0 dport 0

I am expecting the *vapi_payload_acl_add_replace_reply *resp; should contain 
the acl_index but not. Any help is truly appreciated.*

//Ravi.

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#20048): https://lists.fd.io/g/vpp-dev/message/20048
Mute This Topic: https://lists.fd.io/mt/85263360/21656
Mute #vapi:https://lists.fd.io/g/vpp-dev/mutehashtag/vapi
Mute #acl_plugin:https://lists.fd.io/g/vpp-dev/mutehashtag/acl_plugin
Mute #acl:https://lists.fd.io/g/vpp-dev/mutehashtag/acl
Group Owner: vpp-dev+ow...@lists.fd.io
Unsubscribe: https://lists.fd.io/g/vpp-dev/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



[vpp-dev] VAPI ACL addition. Not getting ACL index in response. #acl #acl_plugin #vapi

2021-08-30 Thread RaviKiran Veldanda
[Edited Message Follows]

Hi Experts,
We are trying to use VPP-API(VAPI) to create ACL rules.
We are using the VAPI in blocking mode to get response immediately.
We are getting the response back but the *ACL-INDEX is some other value*. Can 
you please see the below code, if I am doing something wrong.
Any pointers are big help.

printf ("--- Basic acl addition- reply test ---\n");
vapi_msg_acl_add_replace *acl= vapi_alloc_acl_add_replace(ctx, 1);
if(acl==NULL)
{
printf("ACL retuns NULL %d\n",__LINE__);
exit(1);
}
acl->payload.acl_index=-1;
strncpy((char *)acl->payload.tag,"CheckIsWorking",12);
acl->payload.count=1;
vapi_type_prefix src_addr,dst_addr;
acl->payload.r[0].is_permit=1;
src_addr.address.af=0;
src_addr.len=24;//prefix len
inet_aton("172.1.1.0",(struct in_addr *)&(src_addr.address.un.ip4));
dst_addr.address.af=0;
dst_addr.len=24;//prefix len
inet_aton("111.1.1.0",(struct in_addr *)&(dst_addr.address.un.ip4));
acl->payload.r[0].src_prefix=src_addr;
acl->payload.r[0].dst_prefix=dst_addr;
vapi_msg_acl_add_replace_hton(acl);
rv = vapi_send (ctx, acl);
if(rv!=VAPI_OK)
{
printf("vapi_Send %d\n",__LINE__);
exit(1);

}
vapi_payload_acl_add_replace_reply *resp;
size_t size;
rv = vapi_recv (ctx, (void *) &resp, &size, 0, 0);
if(rv!=VAPI_OK)
{
printf("vapi_Send %d\n",__LINE__);
exit(1);
}
printf("So the reply receivied ACL Index %d Retval 
%d\n",resp->acl_index,resp->retval);
vapi_msg_free (ctx, resp);
*This is our testing Output:*
# ./vapi_cli
--- Basic show version message - reply test ---
show_version_reply: program: `vpe', version: `21.06.0-2~g99c146915-dirty', 
build directory: `/opt/vpp', build date: `2021-07-29T16:36:55'
--- Basic acl addition- reply test ---
So the reply receivied ACL Index 42754 Retval 0

*VPP created the ACL:
*
# vppctl show acl-plugin acl
acl-index 0 count 1 tag {CheckIsWorki}
0: ipv4 permit src 172.0.1.0/24 dst 111.0.1.0/24 proto 0 sport 0 dport 0
acl-index 1 count 1 tag {CheckIsWorki}
0: ipv4 permit src 172.1.1.0/24 dst 111.1.1.0/24 proto 0 sport 0 dport 0
acl-index 2 count 1 tag {CheckIsWorki}
0: ipv4 permit src 172.1.1.0/24 dst 111.1.1.0/24 proto 0 sport 0 dport 0
acl-index 3 count 1 tag {CheckIsWorki}
0: ipv4 permit src 172.1.1.0/24 dst 111.1.1.0/24 proto 0 sport 0 dport 0
acl-index 4 count 1 tag {CheckIsWorki}
0: ipv4 permit src 172.1.1.0/24 dst 111.1.1.0/24 proto 0 sport 0 dport 0
acl-index 5 count 1 tag {CheckIsWorki}
0: ipv4 permit src 172.1.1.0/24 dst 111.1.1.0/24 proto 0 sport 0 dport 0

I am expecting the vapi_payload_acl_add_replace_reply *resp; should contain the 
acl_index but not. Can someone help.

//Ravi.

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#20048): https://lists.fd.io/g/vpp-dev/message/20048
Mute This Topic: https://lists.fd.io/mt/85263360/21656
Mute #vapi:https://lists.fd.io/g/vpp-dev/mutehashtag/vapi
Mute #acl_plugin:https://lists.fd.io/g/vpp-dev/mutehashtag/acl_plugin
Mute #acl:https://lists.fd.io/g/vpp-dev/mutehashtag/acl
Group Owner: vpp-dev+ow...@lists.fd.io
Unsubscribe: https://lists.fd.io/g/vpp-dev/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



[vpp-dev] VAPI ACL addition. Not getting ACL index in response. #acl #acl_plugin #vapi

2021-08-30 Thread RaviKiran Veldanda
Hi Experts,
We are trying to use VPP-API(VAPI) to create ACL rules.
We are using the VAPI in blocking mode to get response immediately.
We are getting the response back but the *ACL-INDEX is some other value*. Can 
you please see the below code, if I am doing something wrong.
Any pointers are big help.

printf ("--- Basic acl addition- reply test ---\n");
vapi_msg_acl_add_replace *acl= vapi_alloc_acl_add_replace(ctx, 1);
if(acl==NULL)
{
printf("ACL retuns NULL %d\n",__LINE__);
exit(1);
}
acl->payload.acl_index=-1;
strncpy((char *)acl->payload.tag,"CheckIsWorking",12);
acl->payload.count=1;
vapi_type_prefix src_addr,dst_addr;
acl->payload.r[0].is_permit=1;
src_addr.address.af=0;
src_addr.len=24;//prefix len
inet_aton("172.1.1.0",(struct in_addr *)&(src_addr.address.un.ip4));
dst_addr.address.af=0;
dst_addr.len=24;//prefix len
inet_aton("111.1.1.0",(struct in_addr *)&(dst_addr.address.un.ip4));
acl->payload.r[0].src_prefix=src_addr;
acl->payload.r[0].dst_prefix=dst_addr;
vapi_msg_acl_add_replace_hton(acl);
rv = vapi_send (ctx, acl);
if(rv!=VAPI_OK)
{
printf("vapi_Send %d\n",__LINE__);
exit(1);

}
vapi_payload_acl_add_replace_reply *resp;
size_t size;
rv = vapi_recv (ctx, (void *) &resp, &size, 0, 0);
if(rv!=VAPI_OK)
{
printf("vapi_Send %d\n",__LINE__);
exit(1);
}
printf("So the reply receivied ACL Index %d Retval 
%d\n",resp->acl_index,resp->retval);
vapi_msg_free (ctx, resp);

//Ravi.

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#20048): https://lists.fd.io/g/vpp-dev/message/20048
Mute This Topic: https://lists.fd.io/mt/85263360/21656
Mute #acl_plugin:https://lists.fd.io/g/vpp-dev/mutehashtag/acl_plugin
Mute #vapi:https://lists.fd.io/g/vpp-dev/mutehashtag/vapi
Mute #acl:https://lists.fd.io/g/vpp-dev/mutehashtag/acl
Group Owner: vpp-dev+ow...@lists.fd.io
Unsubscribe: https://lists.fd.io/g/vpp-dev/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-