新TAP测试(TODO 解析arp)

This commit is contained in:
黄思敏 2022-09-01 10:58:34 +08:00
parent 87a90722bd
commit 160e8d122f
2 changed files with 13 additions and 3 deletions

View File

@ -16,6 +16,7 @@ import (
"github.com/474420502/perfectshutdown" "github.com/474420502/perfectshutdown"
"github.com/songgao/packets/ethernet" "github.com/songgao/packets/ethernet"
"github.com/songgao/water" "github.com/songgao/water"
"github.com/songgao/water/waterutil"
"google.golang.org/grpc" "google.golang.org/grpc"
) )
@ -109,7 +110,9 @@ func NewNetTunnel() *NetTunnel {
// }) // })
case ethernet.IPv4: case ethernet.IPv4:
log.Printf("bytes len: %d type(ipv4): % x", len(rbuf), frame.Ethertype()) log.Printf("bytes len: %d type(ipv4): % x", len(rbuf), frame.Ethertype())
log.Printf("src: %s(%d) dst: %s(%d)", waterutil.IPv4Source(frame), waterutil.IPv4SourcePort(frame), waterutil.IPv4Destination(frame), waterutil.IPv4DestinationPort(frame))
log.Println(len(frame)) log.Println(len(frame))
} }
// TODO: 判断地址 转入对应的客户端发送数据 // TODO: 判断地址 转入对应的客户端发送数据

View File

@ -7,12 +7,12 @@ option go_package = "proto/gen";
package frame; package frame;
service FrameService { service FrameService {
rpc SendFrames (stream Request) returns (Response); rpc SendFrames (stream RequestFrames) returns (Response);
rpc SendMacIP(RequestMacIP) returns (Response);
} }
// //
message Request { message RequestFrames {
int32 Type = 1;
bytes Frames = 2; bytes Frames = 2;
} }
@ -22,3 +22,10 @@ message Response {
string Message = 2; string Message = 2;
bytes Data = 3; bytes Data = 3;
} }
//
message RequestMacIP {
bytes IP = 1;
bytes MAC = 2;
}