plong

Unnamed repository; edit this file 'description' to name the repository.
git clone https://git.inz.fi/plong
Log | Files | Refs

net.h (762B)


      1 #ifndef PLONG_NET_H
      2 #define PLONG_NET_H
      3 
      4 #include <stdint.h>
      5 #include <net/if.h>
      6 #include <time.h>
      7 #include "json.h"
      8 
      9 #define IF_MAX 32
     10 
     11 #define NET_FIELDS_RX(x) \
     12 	x(rx, bytes) \
     13 	x(rx, packets) \
     14 	x(rx, errs) \
     15 	x(rx, drop) \
     16 	x(rx, fifo) \
     17 	x(rx, frame) \
     18 	x(rx, compressed) \
     19 	x(rx, multicast)
     20 #define NET_FIELDS_TX(x) \
     21 	x(tx, bytes) \
     22 	x(tx, packets) \
     23 	x(tx, errs) \
     24 	x(tx, drop) \
     25 	x(tx, fifo) \
     26 	x(tx, colls) \
     27 	x(tx, carrier) \
     28 	x(tx, compressed)
     29 #define NET_FIELDS(x) \
     30 	NET_FIELDS_RX(x) \
     31 	NET_FIELDS_TX(x)
     32 
     33 struct net {
     34 	struct timespec stamp;
     35 	struct {
     36 		unsigned int ifidx;
     37 #define X(d, n) uintmax_t d ## n;
     38 NET_FIELDS(X)
     39 #undef X
     40 	} ifaces[IF_MAX];
     41 	size_t n;
     42 };
     43 
     44 int net_init(struct net *n);
     45 int net_poll(struct net *n, struct json *j);
     46 
     47 #endif