diff options
| author | Qiuwen Lu <[email protected]> | 2020-05-28 14:48:56 +0800 |
|---|---|---|
| committer | Qiuwen Lu <[email protected]> | 2020-05-28 14:48:56 +0800 |
| commit | ecd34ae9a277d96c30a4ee88f6e13437470cd9db (patch) | |
| tree | 504ccce866944afb5dae8dd1cdcef5af4702f19f | |
| parent | a32503092597f9731ce48ba5cb3846cf62d5c9b6 (diff) | |
修正构建NSH外层以太网头部时,未交换源、目的MAC地址的问题。feature-nsh-support
| -rw-r--r-- | tunnat/src/tunnel.cc | 12 |
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(ð_hdr->s_addr, &__swap_ether_addr); + ether_addr_copy(ð_hdr->d_addr, ð_hdr->s_addr); + ether_addr_copy(&__swap_ether_addr, ð_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(ð_hdr->s_addr, &__swap_ether_addr); + ether_addr_copy(ð_hdr->d_addr, ð_hdr->s_addr); + ether_addr_copy(&__swap_ether_addr, ð_hdr->d_addr); + unsigned int offset = 0; pkt += sizeof(struct ether_hdr); offset += sizeof(struct ether_hdr); |
