github.com/cilium/cilium@v1.16.2/pkg/policy/trafficdirection/trafficdirection.go (about)

     1  // SPDX-License-Identifier: Apache-2.0
     2  // Copyright Authors of Cilium
     3  
     4  package trafficdirection
     5  
     6  // TrafficDirection specifies the directionality of policy (ingress or egress).
     7  type TrafficDirection uint8
     8  
     9  const (
    10  	// Invalid represents an invalid traffic direction.
    11  	Invalid TrafficDirection = 2
    12  
    13  	// Egress represents egress traffic.
    14  	Egress TrafficDirection = 1
    15  
    16  	// Ingress represents ingress traffic.
    17  	Ingress TrafficDirection = 0
    18  )
    19  
    20  // Uint8 normalizes the TrafficDirection for insertion into BPF maps.
    21  func (td TrafficDirection) Uint8() uint8 {
    22  	return uint8(td)
    23  }
    24  
    25  func (td TrafficDirection) String() string {
    26  	if td == Egress {
    27  		return "Egress"
    28  	} else if td == Ingress {
    29  		return "Ingress"
    30  	}
    31  
    32  	return "Unknown"
    33  }