summaryrefslogtreecommitdiffstats
path: root/src
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
parentc341adf527930b211bb10480826456b3f03dc066 (diff)
downloadfastd-d90524202c9484f2851dbe192847f71dadc22ce5.tar
fastd-d90524202c9484f2851dbe192847f71dadc22ce5.zip
Move get_source_address and get_dest_address to fastd.h
Diffstat (limited to 'src')
-rw-r--r--src/fastd.h16
-rw-r--r--src/receive.c9
-rw-r--r--src/send.c9
3 files changed, 18 insertions, 16 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));
diff --git a/src/receive.c b/src/receive.c
index e2a996b..0b6f5af 100644
--- a/src/receive.c
+++ b/src/receive.c
@@ -245,13 +245,6 @@ void fastd_receive(fastd_socket_t *sock) {
handle_socket_receive(sock, &local_addr, &recvaddr, buffer);
}
-/** Returns the source address of an ethernet packet */
-static inline fastd_eth_addr_t get_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;
-}
-
/** Handles a received and decrypted payload packet */
void fastd_handle_receive(fastd_peer_t *peer, fastd_buffer_t buffer, bool reordered) {
if (conf.mode == MODE_TAP) {
@@ -261,7 +254,7 @@ void fastd_handle_receive(fastd_peer_t *peer, fastd_buffer_t buffer, bool reorde
return;
}
- fastd_eth_addr_t src_addr = get_source_address(buffer);
+ fastd_eth_addr_t src_addr = fastd_buffer_source_address(buffer);
if (fastd_eth_addr_is_unicast(src_addr))
fastd_peer_eth_addr_add(peer, src_addr);
diff --git a/src/send.c b/src/send.c
index fbc1a16..19f0649 100644
--- a/src/send.c
+++ b/src/send.c
@@ -195,13 +195,6 @@ static inline void send_all(fastd_buffer_t buffer, fastd_peer_t *source) {
fastd_buffer_free(buffer);
}
-/** Returns the destination address of an ethernet packet */
-static inline fastd_eth_addr_t get_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;
-}
-
/** Handles sending of a payload packet to a single peer in TAP mode */
static inline bool send_data_tap_single(fastd_buffer_t buffer, fastd_peer_t *source) {
if (conf.mode != MODE_TAP)
@@ -213,7 +206,7 @@ static inline bool send_data_tap_single(fastd_buffer_t buffer, fastd_peer_t *sou
return true;
}
- fastd_eth_addr_t dest_addr = get_dest_address(buffer);
+ fastd_eth_addr_t dest_addr = fastd_buffer_dest_address(buffer);
if (!fastd_eth_addr_is_unicast(dest_addr))
return false;