Network statistics: incoming/outgoing broadcast packets count

Solution for Network statistics: incoming/outgoing broadcast packets count
is Given Below:

I would like to write the c program to monitor network statistics for incoming and outgoing packets, collisions etc. There is a function call getifaddrs with a great code example: https://man7.org/linux/man-pages/man3/getifaddrs.3.html

Using the example from the link above almost all packet statistics could be retrieved. I did not find however the way to monitor the number of incoming and outgoing broadcast packets. Could anybody help with some suggestions on how to get the number of (incoming and outgoing) broadcast packets count per network interface.