1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19#ifndef ROCKER_H
20#define ROCKER_H
21
22#include "qemu/sockets.h"
23
24#if defined(DEBUG_ROCKER)
25# define DPRINTF(fmt, ...) \
26 do { \
27 struct timeval tv; \
28 char timestr[64]; \
29 time_t now; \
30 gettimeofday(&tv, NULL); \
31 now = tv.tv_sec; \
32 strftime(timestr, sizeof(timestr), "%T", localtime(&now)); \
33 fprintf(stderr, "%s.%06ld ", timestr, tv.tv_usec); \
34 fprintf(stderr, "ROCKER: " fmt, ## __VA_ARGS__); \
35 } while (0)
36#else
37static inline GCC_FMT_ATTR(1, 2) int DPRINTF(const char *fmt, ...)
38{
39 return 0;
40}
41#endif
42
43#define __le16 uint16_t
44#define __le32 uint32_t
45#define __le64 uint64_t
46
47#define __be16 uint16_t
48#define __be32 uint32_t
49#define __be64 uint64_t
50
51static inline bool ipv4_addr_is_multicast(__be32 addr)
52{
53 return (addr & htonl(0xf0000000)) == htonl(0xe0000000);
54}
55
56typedef struct ipv6_addr {
57 union {
58 uint8_t addr8[16];
59 __be16 addr16[8];
60 __be32 addr32[4];
61 };
62} Ipv6Addr;
63
64static inline bool ipv6_addr_is_multicast(const Ipv6Addr *addr)
65{
66 return (addr->addr32[0] & htonl(0xFF000000)) == htonl(0xFF000000);
67}
68
69typedef struct rocker Rocker;
70typedef struct world World;
71typedef struct desc_info DescInfo;
72typedef struct desc_ring DescRing;
73
74Rocker *rocker_find(const char *name);
75uint32_t rocker_fp_ports(Rocker *r);
76int rocker_event_link_changed(Rocker *r, uint32_t pport, bool link_up);
77int rocker_event_mac_vlan_seen(Rocker *r, uint32_t pport, uint8_t *addr,
78 uint16_t vlan_id);
79int rx_produce(World *world, uint32_t pport,
80 const struct iovec *iov, int iovcnt, uint8_t copy_to_cpu);
81int rocker_port_eg(Rocker *r, uint32_t pport,
82 const struct iovec *iov, int iovcnt);
83
84#endif
85