summaryrefslogtreecommitdiff
path: root/datastructs.go
blob: a4ac45cbd3469af623215739216cfb985a23fcb8 (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
package main

import (
	"errors"
	"time"
)

type RawData struct {
	ipSrc      string
	ipDst      string
	time       time.Time
	port       int
	packetSize int
}

func (rd *RawData) getVolSize(conf Config) (string, error) {
	for _, volume := range conf.Volumes {
		if volume.Lower <= rd.packetSize &&
			(rd.packetSize < volume.Upper || volume.Upper == 0) {
			return volume.Size, nil
		}
	}
	return "N/A", errors.New("Could not find a fitting size volume")
}

type CleanData struct {
	ipbSrc     string
	ipbDst     string
	time       time.Time
	port       int
	volume     string
	occurances int
}

func (cd *CleanData) equals(other *CleanData) bool {
	return cd.ipbSrc == other.ipbSrc &&
		cd.ipbDst == other.ipbDst &&
		cd.time == other.time &&
		cd.port == other.port &&
		cd.volume == other.volume
}