Skip to content

Commit a9e23c1

Browse files
make vendor firlds exportable
1 parent 30f817a commit a9e23c1

File tree

2 files changed

+17
-17
lines changed

2 files changed

+17
-17
lines changed

layers/arp.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ type ARPPacket struct {
4747
// In an ARP reply this field is used to indicate the address of the host that originated the ARP request.
4848
TargetMAC net.HardwareAddr
4949
TargetIP netip.Addr // Internetwork address of the intended receiver.
50-
dstVendor string
51-
srcVendor string
50+
DstVendor string
51+
SrcVendor string
5252
}
5353

5454
func NewARPPacket(
@@ -75,8 +75,8 @@ func NewARPPacket(
7575
SenderIP: senderIP,
7676
TargetMAC: targetMAC,
7777
TargetIP: targetIP,
78-
dstVendor: oui.VendorWithMAC(targetMAC),
79-
srcVendor: oui.VendorWithMAC(senderMAC),
78+
DstVendor: oui.VendorWithMAC(targetMAC),
79+
SrcVendor: oui.VendorWithMAC(senderMAC),
8080
}, nil
8181
}
8282

@@ -100,10 +100,10 @@ func (ap *ARPPacket) String() string {
100100
ap.Plen,
101101
ap.Op,
102102
ap.SenderMAC,
103-
ap.srcVendor,
103+
ap.SrcVendor,
104104
ap.SenderIP,
105105
ap.TargetMAC,
106-
ap.dstVendor,
106+
ap.DstVendor,
107107
ap.TargetIP,
108108
)
109109
}
@@ -175,8 +175,8 @@ func (ap *ARPPacket) UnmarshalBinary(data []byte) error {
175175
if !ok {
176176
return fmt.Errorf("failed parsing target IP address")
177177
}
178-
ap.dstVendor = oui.VendorWithMAC(ap.TargetMAC)
179-
ap.srcVendor = oui.VendorWithMAC(ap.SenderMAC)
178+
ap.DstVendor = oui.VendorWithMAC(ap.TargetMAC)
179+
ap.SrcVendor = oui.VendorWithMAC(ap.SenderMAC)
180180
return nil
181181
}
182182

layers/ethernet.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ type EthernetFrame struct {
3535
SrcMAC net.HardwareAddr // MAC address of the source device.
3636
EtherType *EthernetType // The protocol of the upper layer.
3737
Payload []byte
38-
dstVendor string
39-
srcVendor string
38+
DstVendor string
39+
SrcVendor string
4040
}
4141

4242
func NewEthernetFrame(dstMAC, srcMAC net.HardwareAddr, et EtherType, payload []byte) (*EthernetFrame, error) {
@@ -48,8 +48,8 @@ func NewEthernetFrame(dstMAC, srcMAC net.HardwareAddr, et EtherType, payload []b
4848
SrcMAC: srcMAC,
4949
EtherType: &EthernetType{Val: et, Desc: ethertypedesc(et)},
5050
Payload: payload,
51-
dstVendor: oui.VendorWithMAC(dstMAC),
52-
srcVendor: oui.VendorWithMAC(srcMAC),
51+
DstVendor: oui.VendorWithMAC(dstMAC),
52+
SrcVendor: oui.VendorWithMAC(srcMAC),
5353
}, nil
5454
}
5555

@@ -62,16 +62,16 @@ func (ef *EthernetFrame) String() string {
6262
%s`,
6363
ef.Summary(),
6464
ef.DstMAC,
65-
ef.dstVendor,
65+
ef.DstVendor,
6666
ef.SrcMAC,
67-
ef.srcVendor,
67+
ef.SrcVendor,
6868
ef.EtherType,
6969
len(ef.Payload),
7070
hex.Dump(ef.ToBytes()))
7171
}
7272

7373
func (ef *EthernetFrame) Summary() string {
74-
return fmt.Sprintf("Ethernet Frame: Src MAC: %s → Dst MAC: %s", ef.srcVendor, ef.dstVendor)
74+
return fmt.Sprintf("Ethernet Frame: Src MAC: %s → Dst MAC: %s", ef.SrcVendor, ef.DstVendor)
7575
}
7676

7777
func (ef *EthernetFrame) MarshalBinary() ([]byte, error) {
@@ -98,8 +98,8 @@ func (ef *EthernetFrame) UnmarshalBinary(data []byte) error {
9898
etdesc := ethertypedesc(et)
9999
ef.EtherType = &EthernetType{Val: et, Desc: etdesc}
100100
ef.Payload = data[headerSizeEthernet:]
101-
ef.dstVendor = oui.VendorWithMAC(ef.DstMAC)
102-
ef.srcVendor = oui.VendorWithMAC(ef.SrcMAC)
101+
ef.DstVendor = oui.VendorWithMAC(ef.DstMAC)
102+
ef.SrcVendor = oui.VendorWithMAC(ef.SrcMAC)
103103
return nil
104104
}
105105

0 commit comments

Comments
 (0)