summaryrefslogtreecommitdiff
path: root/tunnat/src/tunnel.cc
diff options
context:
space:
mode:
Diffstat (limited to 'tunnat/src/tunnel.cc')
-rw-r--r--tunnat/src/tunnel.cc12
1 files changed, 12 insertions, 0 deletions
diff --git a/tunnat/src/tunnel.cc b/tunnat/src/tunnel.cc
index 58ff892..295286f 100644
--- a/tunnat/src/tunnel.cc
+++ b/tunnat/src/tunnel.cc
@@ -1092,6 +1092,12 @@ int TunNSH::PacketConstruct(const char * pkt, unsigned int pkt_len)
struct ether_hdr * eth_hdr = (struct ether_hdr *) pkt;
*eth_hdr = eth_hdr_;
+ /* 交换MAC源、目的地址 */
+ struct ether_addr __swap_ether_addr;
+ ether_addr_copy(&eth_hdr->s_addr, &__swap_ether_addr);
+ ether_addr_copy(&eth_hdr->d_addr, &eth_hdr->s_addr);
+ ether_addr_copy(&__swap_ether_addr, &eth_hdr->d_addr);
+
unsigned int offset = 0;
pkt += sizeof(struct ether_hdr);
offset += sizeof(struct ether_hdr);
@@ -1116,6 +1122,12 @@ int TunNSH::PacketForwardModify(const char * pkt, unsigned int pkt_len)
return RT_ERR;
}
+ /* 交换MAC源、目的地址 */
+ struct ether_addr __swap_ether_addr;
+ ether_addr_copy(&eth_hdr->s_addr, &__swap_ether_addr);
+ ether_addr_copy(&eth_hdr->d_addr, &eth_hdr->s_addr);
+ ether_addr_copy(&__swap_ether_addr, &eth_hdr->d_addr);
+
unsigned int offset = 0;
pkt += sizeof(struct ether_hdr);
offset += sizeof(struct ether_hdr);