只是一个简单的计网课设
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
eruhs/describer/ethernet.go

33 lines
727 B

package describer
import (
"eruhs/core/parser"
"strings"
)
type EthernetDescriber struct {
Eth *parser.Ethernet
}
func (e *EthernetDescriber) GetHeader() []byte {
return e.Eth.Header
}
func (e *EthernetDescriber) GetDetailDescribe() Describe {
protoName := "ETH"
switch e.Eth.Type {
case parser.EthernetTypeIPv4:
protoName = "IPv4"
case parser.EthernetTypeIPv6:
protoName = "IPv6"
case parser.LayerTypeARP:
protoName = "ARP"
default:
}
return Describe{
1: {"源地址", strings.ToUpper(e.Eth.Source.String())},
2: {"目的地址", strings.ToUpper(e.Eth.Destination.String())},
3: {"网络层协议类型", protoName},
}
}