summaryrefslogtreecommitdiffstats
path: root/firmware/microblaze/lib
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/microblaze/lib')
-rw-r--r--firmware/microblaze/lib/net_common.c11
-rw-r--r--firmware/microblaze/lib/net_common.h1
2 files changed, 12 insertions, 0 deletions
diff --git a/firmware/microblaze/lib/net_common.c b/firmware/microblaze/lib/net_common.c
index 693502d18..ab7aadca9 100644
--- a/firmware/microblaze/lib/net_common.c
+++ b/firmware/microblaze/lib/net_common.c
@@ -378,6 +378,17 @@ handle_arp_packet(struct arp_eth_ipv4 *p, size_t size)
}
}
+bool is_udp_packet_with_vrt(uint32_t *p, size_t nlines, int port){
+ struct ip_hdr *ip = (struct ip_hdr *)(p + 4);
+ struct udp_hdr *udp = (struct udp_hdr *)(((char *)ip) + IP_HLEN);
+ uint32_t *payload = (uint32_t *)(((char *)udp) + UDP_HLEN);
+ return \
+ (p[3] & 0xffff) == ETHERTYPE_IPV4 &&
+ IPH_PROTO(ip) == IP_PROTO_UDP &&
+ udp->dest == port &&
+ payload[0] != 0; //must be non zero vrt header
+}
+
void
handle_eth_packet(uint32_t *p, size_t nlines)
{
diff --git a/firmware/microblaze/lib/net_common.h b/firmware/microblaze/lib/net_common.h
index cfba43412..1a7052f71 100644
--- a/firmware/microblaze/lib/net_common.h
+++ b/firmware/microblaze/lib/net_common.h
@@ -56,5 +56,6 @@ void send_udp_pkt(int src_port, struct socket_address dst,
void handle_eth_packet(uint32_t *p, size_t nlines);
+bool is_udp_packet_with_vrt(uint32_t *p, size_t nlines, int port);
#endif /* INCLUDED_NET_COMMON_H */