summaryrefslogtreecommitdiffstats
path: root/src/fastd.h
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2014-04-25 03:23:13 +0200
committerMatthias Schiffer <mschiffer@universe-factory.net>2014-04-25 03:23:13 +0200
commit8c193693d7d0b5b118cf2831eeef15e28ee9851e (patch)
tree1493736f1c293453da09bfe7b322d8daa4fc0d03 /src/fastd.h
parent1723e18b1d92c3fe6d60ea8cef514901cac8e5ba (diff)
downloadfastd-8c193693d7d0b5b118cf2831eeef15e28ee9851e.tar
fastd-8c193693d7d0b5b118cf2831eeef15e28ee9851e.zip
Move around some code
Diffstat (limited to 'src/fastd.h')
-rw-r--r--src/fastd.h23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/fastd.h b/src/fastd.h
index 328666c..f12d036 100644
--- a/src/fastd.h
+++ b/src/fastd.h
@@ -349,6 +349,29 @@ static inline size_t fastd_max_inner_packet(void) {
}
}
+static inline fastd_eth_addr_t fastd_get_source_address(const fastd_buffer_t buffer) {
+ fastd_eth_addr_t ret;
+
+ switch (conf.mode) {
+ case MODE_TAP:
+ memcpy(&ret, buffer.data+offsetof(struct ethhdr, h_source), ETH_ALEN);
+ return ret;
+ default:
+ exit_bug("invalid mode");
+ }
+}
+
+static inline fastd_eth_addr_t fastd_get_dest_address(const fastd_buffer_t buffer) {
+ fastd_eth_addr_t ret;
+ switch (conf.mode) {
+ case MODE_TAP:
+ memcpy(&ret, buffer.data+offsetof(struct ethhdr, h_dest), ETH_ALEN);
+ return ret;
+ default:
+ exit_bug("invalid mode");
+ }
+}
+
static inline size_t fastd_max_outer_packet(void) {
return PACKET_TYPE_LEN + fastd_max_inner_packet() + conf.max_overhead;
}