Hi Ole,

My requirement is to sniff the NTP packets using a raw sockets, and process
them in my application.
I new bee to VPP world.

>>The message IDs are dynamic and depend on which plugins are loaded.
i do not understand exactly.

Thanks,
Nousi

On Wed, 9 Mar 2022 at 17:35, <otr...@employees.org> wrote:

> Hi,
>
> > I am not getting a reply from vpp.
> > Any pointers will be helpful.
> > Thanks in advance.
> >
> >  logs below.   after " writing punt socket register...:"  log it does
> not come out.
> >
> >  NTPSYNC-TEST:: app start
> >  NTPSYNC-TEST:: VPP Server Socket bind Successful
> (/var/run/vpp-punt.sock)
> >  NTPSYNC-TEST:: Connected to vpp...: 0
> >  NTPSYNC-TEST:: message id VL_API_PUNT_SOCKET_REGISTER 694
> >  NTPSYNC-TEST:: message id VL_API_PUNT_SOCKET_REGISTER 695
>
> The message IDs are dynamic and depend on which plugins are loaded.
> Are you sure these are correct?
>
> VAPI provides a much higher level C interface. src/vpp-api/vapi/
> Which would allow you to write much less boilerplate.
>
> Ole
>
> >  NTPSYNC-TEST:: type=1 , ntohl=16777216, htonl=16777216
> >  NTPSYNC-TEST:: protocol = 17
> >  NTPSYNC-TEST:: writing punt socket register...:
> >
> >
> >  code:
> >  ----------------
> >  const char* Unix_socket_path = "/var/run/vpp-punt.sock";
> >
> >  int main()
> >  {
> >     openlog("NTPSYNC-TEST:",0, LOG_USER);
> >     syslog(LOG_INFO, "app start");
> >
> >     unix_socket_rd = -1;
> >     unix_socket_wr = -1;
> >     strncpy(strAppName, appName, strlen(appName));
> >     maxOutStandingReq = maxOutSize;
> >     responseQueSize = respSize;
> >
> >     int len, rc;
> >     struct sockaddr_un remote;
> >
> >     memset(&remote, 0, sizeof(struct sockaddr_un));
> >
> >     unix_socket_rd = socket(AF_UNIX, SOCK_DGRAM, 0);
> >     if (unix_socket_rd == -1)
> >     {
> >         syslog(LOG_ERR, "VPP Server socket error (%s)", strerror(errno));
> >         return;
> >     }
> >
> >     remote.sun_family = AF_UNIX;
> >     strcpy(remote.sun_path, Unix_socket_path);
> >     len = sizeof(remote);
> >     unlink(Unix_socket_path);
> >     rc = bind(unix_socket_rd, (struct sockaddr *) &remote, len);
> >     if (rc == -1)
> >     {
> >         syslog(LOG_ERR, "VPP Server Socket bind failed (%s)",
> strerror(errno));
> >         close(unix_socket_rd);
> >         return;
> >     }
> >     else
> >     {
> >         syslog(LOG_INFO, "VPP Server Socket bind Successful (%s)",
> Unix_socket_path);
> >     }
> >
> > clib_mem_init(0, 3ULL << 30);
> > test_punt_socket_register_message();
> > }
> >
> > void test_punt_socket_register_message()
> > {
> >     api_main_t * am = vlibapi_get_main();
> >     vl_api_punt_socket_register_t *mp;
> >     char *read_path = "/var/run/vpp.sock";
> >     int async = 1;
> >
> >     int rv = vac_connect("vac_client", NULL, wrap_vac_callback, 32 );
> >         if (rv != 0)
> >         {
> >                         syslog(LOG_INFO, "Connect failed: %d \n", rv);
> >                         exit(rv);
> >         }
> >
> >         syslog(LOG_INFO,"Connected to vpp...: %d\n", rv);
> >         double timestamp_start = unix_time_now_nsec() * 1e-6;
> >
> >         if (async)
> >         {
> >                 mp = vl_msg_api_alloc(sizeof(*mp));
> >                 memset(mp, 0, sizeof(*mp));
> >                 mp->_vl_msg_id = ntohs(VL_API_PUNT_SOCKET_REGISTER);
> >                 syslog(LOG_INFO," message id VL_API_PUNT_SOCKET_REGISTER
> %d", VL_API_PUNT_SOCKET_REGISTER);
> >                 syslog(LOG_INFO," message id VL_API_PUNT_SOCKET_REGISTER
> %d", VL_API_PUNT_SOCKET_REGISTER_REPLY);
> >                 mp->header_version = ntohl(1);
> >                 mp->punt.type = PUNT_API_TYPE_L4;
> >                 mp->punt.punt.l4.af = ADDRESS_IP4;
> >                 mp->punt.punt.l4.protocol = IP_PROTOCOL_UDP;
> >                 mp->punt.punt.l4.port = ntohs(123);
> >                 mp->client_index = am->my_client_index;
> >                 strncpy((char*) mp->pathname, read_path, 107);
> > syslog(LOG_INFO, " type=%u , ntohl=%u, htonl=%u", PUNT_API_TYPE_L4,
> clib_host_to_net_u32(PUNT_API_TYPE_L4),
> clib_net_to_host_u32(PUNT_API_TYPE_L4));
> > syslog(LOG_INFO, " protocol = %u", IP_PROTOCOL_UDP);
> >
> >                 syslog(LOG_INFO, " writing punt socket register...: \n");
> >                 vac_write((char *)mp, sizeof(*mp));
> >
> >                 while (result_msg_id !=
> VL_API_PUNT_SOCKET_REGISTER_REPLY);
> >         }
> >
> > syslog(LOG_INFO," message id VL_API_PUNT_SOCKET_REGISTER %d",
> VL_API_CONTROL_PING_REPLY);
> >         if (async)
> >         {
> >                 vl_api_control_ping_t control;
> >                 vl_api_control_ping_t *mp;
> >                 mp = &control;
> >                 M_NOALLOC(CONTROL_PING, control_ping);
> >                 syslog(LOG_INFO," writing control ping message...: \n");
> >                 vac_write((char *)mp, sizeof(*mp));
> >
> >                 while (result_msg_id != VL_API_CONTROL_PING_REPLY);
> >         }
> >
> >         double timestamp_end = unix_time_now_nsec() * 1e-6;
> >         syslog(LOG_INFO,"\nTook %.2f msec, %.0f msgs/msec \n",
> (timestamp_end - timestamp_start),
> >                                         1/(timestamp_end -
> timestamp_start));
> >         syslog(LOG_INFO,"Exiting...\n");
> >         vac_disconnect();
> > }
> >
> > --
> > Thanks & Regards,
> > B.Nousilal,
> >
> >
> > 
> >
>
>

-- 


*Thanks & Regards,B.Nousilal,*
-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#20992): https://lists.fd.io/g/vpp-dev/message/20992
Mute This Topic: https://lists.fd.io/mt/89660111/21656
Group Owner: vpp-dev+ow...@lists.fd.io
Unsubscribe: https://lists.fd.io/g/vpp-dev/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-

Reply via email to