Beispiel #1
0
void udp_poll(FAR struct net_driver_s *dev, FAR struct udp_conn_s *conn)
{
  /* Verify that the UDP connection is valid */

  if (conn->lport != 0)
    {
      /* Set-up for the application callback */

      dev->d_appdata = &dev->d_buf[NET_LL_HDRLEN(dev) + IPUDP_HDRLEN];
      dev->d_snddata = &dev->d_buf[NET_LL_HDRLEN(dev) + IPUDP_HDRLEN];

      dev->d_len     = 0;
      dev->d_sndlen  = 0;

      /* Perform the application callback */

      (void)udp_callback(dev, conn, UDP_POLL);

      /* If the application has data to send, setup the UDP/IP header */

      if (dev->d_sndlen > 0)
        {
          udp_send(dev, conn);
          return;
        }
    }

  /* Make sure that d_len is zero meaning that there is nothing to be sent */

  dev->d_len   = 0;
}
Beispiel #2
0
void ip_callback(u_char * arg, const struct pcap_pkthdr *pkthdr,
		 const u_char * packet)
{
	ipn++;
	struct ip_header *hdr;
	hdr = (struct ip_header *)(packet + 14);

	sprintf(spacket.protocol, "%s", "IP");
	sprintf(spacket.src_ip, "%s", inet_ntoa(hdr->src_addr));
	sprintf(spacket.dst_ip, "%s", inet_ntoa(hdr->dst_addr));

	switch (hdr->protocol) {
	case 6:
		tcp_callback(arg, pkthdr, packet);
		break;
	case 17:
		udp_callback(arg, pkthdr, packet);
		break;
	case 1:
		icmp_callback(arg, pkthdr, packet);
		break;
	default:
		break;
	}
}
Beispiel #3
0
void udp_poll(FAR struct net_driver_s *dev, FAR struct udp_conn_s *conn)
{
  /* Verify that the UDP connection is valid */

  if (conn->lport != 0)
    {
      /* Set up for the callback.  We can't know in advance if the application
       * is going to send a IPv4 or an IPv6 packet, so this setup may not
       * actually be used.
       */

#if defined(CONFIG_NET_IPv4)
      udp_ipv4_select(dev);
#else /* if defined(CONFIG_NET_IPv6) */
      udp_ipv6_select(dev);
#endif

      dev->d_len     = 0;
      dev->d_sndlen  = 0;

      /* Perform the application callback */

      (void)udp_callback(dev, conn, UDP_POLL);

      /* If the application has data to send, setup the UDP/IP header */

      if (dev->d_sndlen > 0)
        {
          udp_send(dev, conn);
          return;
        }
    }

  /* Make sure that d_len is zero meaning that there is nothing to be sent */

  dev->d_len   = 0;
}