aboutsummaryrefslogtreecommitdiff
path: root/cmd/pkg/protocol.go
blob: 84444c3cbd00c5688a68c926d880ac5d1a7693c7 (plain)
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
package pkg

import (
	"net"
	// "netip"
)

const (
	MAX_IP_PACKET_SIZE = 1400
)

func Initialize(config IpConfig) (error) {
	// ip config from go parser

	// initialize ip table

	// error check

	// different for router and host??
	// host 
	// create node interfaces?
}

func ipRecv(data []byte) (error) {
	// parse ip header

	// check ip checksum

	// check ip version

	// check ip length

	// check ip ttl

	// check ip protocol

	// check ip destination

	// check ip source

	// check forwarding table
}

func ipForwarding(dst netip.Addr, protocolNum uint16, data []byte) (error) {
	// send test packest to dst

	// lookup forwarding table

	// locally

	// not locally
}

type HandlerFunc = func(*Packet, []interface{}) (error) {

	// do smth with packet
}

func RegisterRecvHandler(protocolNum uint8, callbackFunc HandlerFunc) (error) {
}

func routeRip() (error) {
	// communicate with other routers

	// update forwarding table
}