summaryrefslogtreecommitdiffstats
path: root/src/fastd.h
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2014-09-26 15:35:31 +0200
committerMatthias Schiffer <mschiffer@universe-factory.net>2014-09-26 15:35:31 +0200
commitd90524202c9484f2851dbe192847f71dadc22ce5 (patch)
tree2a5413ef5b58ebb6121b67114ffa6863c6b6fbe6 /src/fastd.h
parentc341adf527930b211bb10480826456b3f03dc066 (diff)
downloadfastd-d90524202c9484f2851dbe192847f71dadc22ce5.tar
fastd-d90524202c9484f2851dbe192847f71dadc22ce5.zip
Move get_source_address and get_dest_address to fastd.h
Diffstat (limited to 'src/fastd.h')
-rw-r--r--src/fastd.h16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/fastd.h b/src/fastd.h
index 93788bd..8af0556 100644
--- a/src/fastd.h
+++ b/src/fastd.h
@@ -395,6 +395,22 @@ static inline size_t fastd_max_payload(void) {
}
}
+
+/** Returns the source address of an ethernet packet */
+static inline fastd_eth_addr_t fastd_buffer_source_address(const fastd_buffer_t buffer) {
+ fastd_eth_addr_t ret;
+ memcpy(&ret, buffer.data+offsetof(struct ethhdr, h_source), ETH_ALEN);
+ return ret;
+}
+
+/** Returns the destination address of an ethernet packet */
+static inline fastd_eth_addr_t fastd_buffer_dest_address(const fastd_buffer_t buffer) {
+ fastd_eth_addr_t ret;
+ memcpy(&ret, buffer.data+offsetof(struct ethhdr, h_dest), ETH_ALEN);
+ return ret;
+}
+
+
/** Checks if a fastd_peer_address_t is an IPv6 link-local address */
static inline bool fastd_peer_address_is_v6_ll(const fastd_peer_address_t *addr) {
return (addr->sa.sa_family == AF_INET6 && IN6_IS_ADDR_LINKLOCAL(&addr->in6.sin6_addr));