-
Notifications
You must be signed in to change notification settings - Fork 1
/
cipv6.go
31 lines (26 loc) · 830 Bytes
/
cipv6.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
package main
/*
#cgo CFLAGS: -I/home/acklio/Desktop/Trial/udp6sh
#cgo LDFLAGS: -L/home/acklio/Desktop/Trial/udp6sh -ludp6
#include "udp6.h"
#include <stdint.h>
*/
import "C" //no blank line between the bulk comment and this line
func main() {
// Sample structure
ci := C.int(8)
cs := C.CString("Go string")
foo := C.struct_Foo{a: ci, b: cs}
// IPv6 Header
src_ip := C.CString("2001:face::6cf2:65e:dead:beef")
dst_ip := C.CString("2001:face::1acf:5eff:fe37:d8a9")
dst_mac := C.CString("18:cf:5e:37:d8:a9")
ip := C.struct_Ipv6{src: src_ip, dst: dst_ip, hopLimit: 10, nextHeader: 17}
// UDP Header
src_port := C.ushort(4950)
dst_port := C.ushort(5940)
udp := C.struct_Udp{esport: src_port, lcport: dst_port, checksum: C.ushort(24566)}
// Send the packet using C library
C.Stest(foo)
C.V6Send(ip, dst_mac, udp)
}