blob: 3233c8c029c9add2920b7c389a3be17047993cb1 [file] [log] [blame]
Matteo Scandolo4b3fc7e2019-09-17 16:49:54 -07001/*
2 * Copyright 2018-present Open Networking Foundation
3
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7
8 * http://www.apache.org/licenses/LICENSE-2.0
9
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package packetHandlers
18
19import (
20 "github.com/google/gopacket"
21 "github.com/google/gopacket/layers"
22 "net"
23)
24
25func IsDhcpPacket(pkt gopacket.Packet) bool {
26 if layerDHCP := pkt.Layer(layers.LayerTypeDHCPv4); layerDHCP != nil {
27 return true
28 }
29 return false
30}
31
32func IsIncomingPacket(packet gopacket.Packet) bool {
33 if ipLayer := packet.Layer(layers.LayerTypeIPv4); ipLayer != nil {
34
35 ip, _ := ipLayer.(*layers.IPv4)
36
37 // FIXME find a better way to filter outgoing packets
38 if ip.SrcIP.Equal(net.ParseIP("182.21.0.128")) {
39 return true
40 }
41 }
42 return false
43}