Ejemplo n.º 1
0
func (p *Packet) Pack(buf *packet.Buffer) error {
	buf.Write(p.DstAddr)
	buf.Write(p.SrcAddr)

	if p.Type != LLC {
		buf.WriteN(p.Type)
	} else {
		buf.WriteN(p.Length)
	}

	return nil
}
Ejemplo n.º 2
0
func (p *Packet) Pack(buf *packet.Buffer) error {
	buf.WriteN(uint8(p.Version<<4 | (p.Class >> 4)))
	buf.WriteN(p.Class<<4 | uint8(p.Label>>16))
	buf.WriteN(uint16(p.Label))

	buf.WriteN(p.Length)
	buf.WriteN(p.NextHdr)
	buf.WriteN(p.HopLimit)

	buf.Write(p.SrcAddr.To16())
	buf.Write(p.DstAddr.To16())

	return nil
}
Ejemplo n.º 3
0
func (p *Packet) Pack(buf *packet.Buffer) error {
	buf.WriteN((p.Version << 4) | p.IHL)
	buf.WriteN(p.TOS)
	buf.WriteN(p.Length)
	buf.WriteN(p.Id)
	buf.WriteN((uint16(p.Flags) << 13) | p.FragOff)
	buf.WriteN(p.TTL)
	buf.WriteN(p.Protocol)
	buf.WriteN(uint16(0x00))
	buf.Write(p.SrcAddr.To4())
	buf.Write(p.DstAddr.To4())

	p.checksum(buf.LayerBytes()[:20])
	buf.PutUint16N(10, p.Checksum)

	return nil
}
Ejemplo n.º 4
0
func (p *Packet) Pack(buf *packet.Buffer) error {
	buf.WriteN(p.HWType)
	buf.WriteN(p.ProtoType)

	buf.WriteN(p.HWAddrLen)
	buf.WriteN(p.ProtoAddrLen)

	buf.WriteN(p.Operation)

	buf.Write(p.HWSrcAddr[len(p.HWSrcAddr)-int(p.HWAddrLen):])
	buf.Write(p.ProtoSrcAddr[len(p.ProtoSrcAddr)-int(p.ProtoAddrLen):])

	buf.Write(p.HWDstAddr[len(p.HWDstAddr)-int(p.HWAddrLen):])
	buf.Write(p.ProtoDstAddr[len(p.ProtoDstAddr)-int(p.ProtoAddrLen):])

	return nil
}
Ejemplo n.º 5
0
func (p *Packet) Pack(buf *packet.Buffer) error {
	buf.Write(p.Data)

	return nil
}