further updates
This commit is contained in:
39
server/utils/file_transfer.go
Normal file
39
server/utils/file_transfer.go
Normal file
@@ -0,0 +1,39 @@
|
||||
package utils
|
||||
|
||||
import (
|
||||
"log"
|
||||
"github.com/google/gopacket"
|
||||
|
||||
"saprusserver/structs"
|
||||
)
|
||||
|
||||
func (c* SocketCall) FileTransferPacket(message string) gopacket.SerializeBuffer {
|
||||
eth, ip, udp := basePacket(c)
|
||||
|
||||
sapFile := structs.SaprusFileTransfer {
|
||||
Flag: [1]byte{0x11},
|
||||
Sequence: [2]byte{0x22, 0x33},
|
||||
Checksum: [2]byte{0x44, 0x44},
|
||||
Payload: []byte(message),
|
||||
}
|
||||
|
||||
sapHeader := structs.SaprusHeaderFrame {
|
||||
PacketType: [2]byte{0x88, 0x88},
|
||||
Length: c.saprusPayloadLength(sapFile.Bytes()),
|
||||
Payload: sapFile.Bytes(),
|
||||
}
|
||||
|
||||
buf := gopacket.NewSerializeBuffer()
|
||||
opts := gopacket.SerializeOptions {
|
||||
ComputeChecksums: true,
|
||||
FixLengths: true,
|
||||
}
|
||||
|
||||
udp.SetNetworkLayerForChecksum(&ip)
|
||||
err := gopacket.SerializeLayers(buf, opts, ð, &ip, &udp, gopacket.Payload(sapHeader.Bytes()))
|
||||
if err != nil {
|
||||
log.Panic(err)
|
||||
}
|
||||
return buf
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user