// Code generated by protoc-gen-go. DO NOT EDIT.
// source: nodeb_info.proto

package entities

import (
	fmt "fmt"
	proto "github.com/golang/protobuf/proto"
	math "math"
)

// Reference imports to suppress errors if they are not otherwise used.
var _ = proto.Marshal
var _ = fmt.Errorf
var _ = math.Inf

// This is a compile-time assertion to ensure that this generated file
// is compatible with the proto package it is being compiled against.
// A compilation error at this line likely means your copy of the
// proto package needs to be updated.
const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package

type ConnectionStatus int32

const (
	ConnectionStatus_UNKNOWN_CONNECTION_STATUS ConnectionStatus = 0
	ConnectionStatus_CONNECTED                 ConnectionStatus = 1
	ConnectionStatus_NOT_CONNECTED             ConnectionStatus = 2
	ConnectionStatus_CONNECTED_SETUP_FAILED    ConnectionStatus = 3
	ConnectionStatus_CONNECTING                ConnectionStatus = 4
)

var ConnectionStatus_name = map[int32]string{
	0: "UNKNOWN_CONNECTION_STATUS",
	1: "CONNECTED",
	2: "NOT_CONNECTED",
	3: "CONNECTED_SETUP_FAILED",
	4: "CONNECTING",
}

var ConnectionStatus_value = map[string]int32{
	"UNKNOWN_CONNECTION_STATUS": 0,
	"CONNECTED":                 1,
	"NOT_CONNECTED":             2,
	"CONNECTED_SETUP_FAILED":    3,
	"CONNECTING":                4,
}

func (x ConnectionStatus) String() string {
	return proto.EnumName(ConnectionStatus_name, int32(x))
}

func (ConnectionStatus) EnumDescriptor() ([]byte, []int) {
	return fileDescriptor_04b920976079e56c, []int{0}
}

type Node_Type int32

const (
	Node_UNKNOWN Node_Type = 0
	Node_ENB     Node_Type = 1
	Node_GNB     Node_Type = 2
)

var Node_Type_name = map[int32]string{
	0: "UNKNOWN",
	1: "ENB",
	2: "GNB",
}

var Node_Type_value = map[string]int32{
	"UNKNOWN": 0,
	"ENB":     1,
	"GNB":     2,
}

func (x Node_Type) String() string {
	return proto.EnumName(Node_Type_name, int32(x))
}

func (Node_Type) EnumDescriptor() ([]byte, []int) {
	return fileDescriptor_04b920976079e56c, []int{1, 0}
}

type Failure_Type int32

const (
	Failure_UNKNOWN_TYPE          Failure_Type = 0
	Failure_X2_SETUP_FAILURE      Failure_Type = 1
	Failure_ENDC_X2_SETUP_FAILURE Failure_Type = 2
)

var Failure_Type_name = map[int32]string{
	0: "UNKNOWN_TYPE",
	1: "X2_SETUP_FAILURE",
	2: "ENDC_X2_SETUP_FAILURE",
}

var Failure_Type_value = map[string]int32{
	"UNKNOWN_TYPE":          0,
	"X2_SETUP_FAILURE":      1,
	"ENDC_X2_SETUP_FAILURE": 2,
}

func (x Failure_Type) String() string {
	return proto.EnumName(Failure_Type_name, int32(x))
}

func (Failure_Type) EnumDescriptor() ([]byte, []int) {
	return fileDescriptor_04b920976079e56c, []int{2, 0}
}

type NodebInfo struct {
	RanName          string           `protobuf:"bytes,1,opt,name=ran_name,json=ranName,proto3" json:"ran_name,omitempty"`
	Ip               string           `protobuf:"bytes,2,opt,name=ip,proto3" json:"ip,omitempty"`
	Port             uint32           `protobuf:"varint,3,opt,name=port,proto3" json:"port,omitempty"`
	ConnectionStatus ConnectionStatus `protobuf:"varint,4,opt,name=connection_status,json=connectionStatus,proto3,enum=entities.ConnectionStatus" json:"connection_status,omitempty"`
	GlobalNbId       *GlobalNbId      `protobuf:"bytes,5,opt,name=global_nb_id,json=globalNbId,proto3" json:"global_nb_id,omitempty"`
	NodeType         Node_Type        `protobuf:"varint,6,opt,name=node_type,json=nodeType,proto3,enum=entities.Node_Type" json:"node_type,omitempty"`
	// Types that are valid to be assigned to Configuration:
	//	*NodebInfo_Enb
	//	*NodebInfo_Gnb
	Configuration        isNodebInfo_Configuration `protobuf_oneof:"configuration"`
	FailureType          Failure_Type              `protobuf:"varint,9,opt,name=failure_type,json=failureType,proto3,enum=entities.Failure_Type" json:"failure_type,omitempty"`
	SetupFailure         *SetupFailure             `protobuf:"bytes,10,opt,name=setup_failure,json=setupFailure,proto3" json:"setup_failure,omitempty"`
	XXX_NoUnkeyedLiteral struct{}                  `json:"-"`
	XXX_unrecognized     []byte                    `json:"-"`
	XXX_sizecache        int32                     `json:"-"`
}

func (m *NodebInfo) Reset()         { *m = NodebInfo{} }
func (m *NodebInfo) String() string { return proto.CompactTextString(m) }
func (*NodebInfo) ProtoMessage()    {}
func (*NodebInfo) Descriptor() ([]byte, []int) {
	return fileDescriptor_04b920976079e56c, []int{0}
}

func (m *NodebInfo) XXX_Unmarshal(b []byte) error {
	return xxx_messageInfo_NodebInfo.Unmarshal(m, b)
}
func (m *NodebInfo) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
	return xxx_messageInfo_NodebInfo.Marshal(b, m, deterministic)
}
func (m *NodebInfo) XXX_Merge(src proto.Message) {
	xxx_messageInfo_NodebInfo.Merge(m, src)
}
func (m *NodebInfo) XXX_Size() int {
	return xxx_messageInfo_NodebInfo.Size(m)
}
func (m *NodebInfo) XXX_DiscardUnknown() {
	xxx_messageInfo_NodebInfo.DiscardUnknown(m)
}

var xxx_messageInfo_NodebInfo proto.InternalMessageInfo

func (m *NodebInfo) GetRanName() string {
	if m != nil {
		return m.RanName
	}
	return ""
}

func (m *NodebInfo) GetIp() string {
	if m != nil {
		return m.Ip
	}
	return ""
}

func (m *NodebInfo) GetPort() uint32 {
	if m != nil {
		return m.Port
	}
	return 0
}

func (m *NodebInfo) GetConnectionStatus() ConnectionStatus {
	if m != nil {
		return m.ConnectionStatus
	}
	return ConnectionStatus_UNKNOWN_CONNECTION_STATUS
}

func (m *NodebInfo) GetGlobalNbId() *GlobalNbId {
	if m != nil {
		return m.GlobalNbId
	}
	return nil
}

func (m *NodebInfo) GetNodeType() Node_Type {
	if m != nil {
		return m.NodeType
	}
	return Node_UNKNOWN
}

type isNodebInfo_Configuration interface {
	isNodebInfo_Configuration()
}

type NodebInfo_Enb struct {
	Enb *Enb `protobuf:"bytes,7,opt,name=enb,proto3,oneof"`
}

type NodebInfo_Gnb struct {
	Gnb *Gnb `protobuf:"bytes,8,opt,name=gnb,proto3,oneof"`
}

func (*NodebInfo_Enb) isNodebInfo_Configuration() {}

func (*NodebInfo_Gnb) isNodebInfo_Configuration() {}

func (m *NodebInfo) GetConfiguration() isNodebInfo_Configuration {
	if m != nil {
		return m.Configuration
	}
	return nil
}

func (m *NodebInfo) GetEnb() *Enb {
	if x, ok := m.GetConfiguration().(*NodebInfo_Enb); ok {
		return x.Enb
	}
	return nil
}

func (m *NodebInfo) GetGnb() *Gnb {
	if x, ok := m.GetConfiguration().(*NodebInfo_Gnb); ok {
		return x.Gnb
	}
	return nil
}

func (m *NodebInfo) GetFailureType() Failure_Type {
	if m != nil {
		return m.FailureType
	}
	return Failure_UNKNOWN_TYPE
}

func (m *NodebInfo) GetSetupFailure() *SetupFailure {
	if m != nil {
		return m.SetupFailure
	}
	return nil
}

// XXX_OneofWrappers is for the internal use of the proto package.
func (*NodebInfo) XXX_OneofWrappers() []interface{} {
	return []interface{}{
		(*NodebInfo_Enb)(nil),
		(*NodebInfo_Gnb)(nil),
	}
}

type Node struct {
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

func (m *Node) Reset()         { *m = Node{} }
func (m *Node) String() string { return proto.CompactTextString(m) }
func (*Node) ProtoMessage()    {}
func (*Node) Descriptor() ([]byte, []int) {
	return fileDescriptor_04b920976079e56c, []int{1}
}

func (m *Node) XXX_Unmarshal(b []byte) error {
	return xxx_messageInfo_Node.Unmarshal(m, b)
}
func (m *Node) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
	return xxx_messageInfo_Node.Marshal(b, m, deterministic)
}
func (m *Node) XXX_Merge(src proto.Message) {
	xxx_messageInfo_Node.Merge(m, src)
}
func (m *Node) XXX_Size() int {
	return xxx_messageInfo_Node.Size(m)
}
func (m *Node) XXX_DiscardUnknown() {
	xxx_messageInfo_Node.DiscardUnknown(m)
}

var xxx_messageInfo_Node proto.InternalMessageInfo

type Failure struct {
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

func (m *Failure) Reset()         { *m = Failure{} }
func (m *Failure) String() string { return proto.CompactTextString(m) }
func (*Failure) ProtoMessage()    {}
func (*Failure) Descriptor() ([]byte, []int) {
	return fileDescriptor_04b920976079e56c, []int{2}
}

func (m *Failure) XXX_Unmarshal(b []byte) error {
	return xxx_messageInfo_Failure.Unmarshal(m, b)
}
func (m *Failure) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
	return xxx_messageInfo_Failure.Marshal(b, m, deterministic)
}
func (m *Failure) XXX_Merge(src proto.Message) {
	xxx_messageInfo_Failure.Merge(m, src)
}
func (m *Failure) XXX_Size() int {
	return xxx_messageInfo_Failure.Size(m)
}
func (m *Failure) XXX_DiscardUnknown() {
	xxx_messageInfo_Failure.DiscardUnknown(m)
}

var xxx_messageInfo_Failure proto.InternalMessageInfo

func init() {
	proto.RegisterEnum("entities.ConnectionStatus", ConnectionStatus_name, ConnectionStatus_value)
	proto.RegisterEnum("entities.Node_Type", Node_Type_name, Node_Type_value)
	proto.RegisterEnum("entities.Failure_Type", Failure_Type_name, Failure_Type_value)
	proto.RegisterType((*NodebInfo)(nil), "entities.NodebInfo")
	proto.RegisterType((*Node)(nil), "entities.Node")
	proto.RegisterType((*Failure)(nil), "entities.Failure")
}

func init() { proto.RegisterFile("nodeb_info.proto", fileDescriptor_04b920976079e56c) }

var fileDescriptor_04b920976079e56c = []byte{
	// 506 bytes of a gzipped FileDescriptorProto
	0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x64, 0x52, 0x51, 0x8b, 0xda, 0x4c,
	0x14, 0x35, 0xd1, 0x6f, 0x35, 0x57, 0xe3, 0x37, 0x4e, 0xb7, 0x4b, 0x14, 0x4a, 0xad, 0x50, 0x90,
	0x42, 0xa5, 0x58, 0x28, 0x94, 0x3e, 0xad, 0x9a, 0xb5, 0xd2, 0x32, 0x2e, 0x31, 0xd2, 0xf6, 0x69,
	0xc8, 0xe8, 0x18, 0x02, 0xee, 0x4c, 0x48, 0x22, 0xd4, 0xa7, 0xfe, 0xc1, 0xfe, 0xa8, 0x32, 0x93,
	0x68, 0xac, 0x7d, 0xbb, 0x73, 0xce, 0xb9, 0xe7, 0xdc, 0xb9, 0x33, 0x80, 0x84, 0xdc, 0x72, 0x46,
	0x23, 0xb1, 0x93, 0xa3, 0x38, 0x91, 0x99, 0xc4, 0x0d, 0x2e, 0xb2, 0x28, 0x8b, 0x78, 0xda, 0xb3,
	0x42, 0xc1, 0x72, 0xb0, 0x67, 0xf1, 0x73, 0xf9, 0xf2, 0xe7, 0x98, 0xa6, 0x3c, 0x3b, 0xc4, 0x74,
	0x17, 0x44, 0xfb, 0x43, 0xc2, 0x69, 0xc2, 0xd3, 0x58, 0x8a, 0x94, 0x17, 0x82, 0x8e, 0x60, 0x34,
	0xda, 0x6a, 0x97, 0x63, 0x0e, 0x0d, 0x7e, 0x57, 0xc1, 0x22, 0x2a, 0x68, 0x21, 0x76, 0x12, 0x77,
	0xa1, 0x91, 0x04, 0x82, 0x8a, 0xe0, 0x89, 0x3b, 0x46, 0xdf, 0x18, 0x5a, 0x5e, 0x3d, 0x09, 0x04,
	0x09, 0x9e, 0x38, 0x6e, 0x83, 0x19, 0xc5, 0x8e, 0xa9, 0x41, 0x33, 0x8a, 0x31, 0x86, 0x5a, 0x2c,
	0x93, 0xcc, 0xa9, 0xf6, 0x8d, 0xa1, 0xed, 0xe9, 0x1a, 0xcf, 0xa1, 0xb3, 0x91, 0x42, 0xf0, 0x4d,
	0x16, 0x49, 0x41, 0xd3, 0x2c, 0xc8, 0x0e, 0xa9, 0x53, 0xeb, 0x1b, 0xc3, 0xf6, 0xb8, 0x37, 0x3a,
	0x0d, 0x3f, 0x9a, 0x9e, 0x25, 0x2b, 0xad, 0xf0, 0xd0, 0xe6, 0x0a, 0xc1, 0x1f, 0xa0, 0x15, 0xee,
	0x25, 0x0b, 0xf6, 0x54, 0x4f, 0xec, 0xfc, 0xd7, 0x37, 0x86, 0xcd, 0xf1, 0x6d, 0xe9, 0x31, 0xd7,
	0x2c, 0x61, 0x8b, 0xad, 0x07, 0xe1, 0xb9, 0xc6, 0xef, 0xc0, 0x52, 0x5b, 0xa3, 0xd9, 0x31, 0xe6,
	0xce, 0x8d, 0x0e, 0x7e, 0x56, 0x36, 0xa9, 0x7b, 0x8e, 0xfc, 0x63, 0xcc, 0xbd, 0x86, 0x52, 0xa9,
	0x0a, 0xbf, 0x82, 0x2a, 0x17, 0xcc, 0xa9, 0xeb, 0x00, 0xbb, 0xd4, 0xba, 0x82, 0x7d, 0xae, 0x78,
	0x8a, 0x53, 0x92, 0x50, 0x30, 0xa7, 0x71, 0x2d, 0x99, 0xe7, 0x92, 0x50, 0x30, 0xfc, 0x11, 0x5a,
	0xa7, 0x95, 0xeb, 0x68, 0x4b, 0x47, 0xdf, 0x95, 0xda, 0x87, 0x9c, 0xcd, 0xd3, 0x9b, 0x85, 0x56,
	0x0f, 0xf0, 0x09, 0xec, 0xbf, 0xde, 0xcc, 0x01, 0x9d, 0x73, 0xd1, 0xbb, 0x52, 0x74, 0x61, 0xe0,
	0xb5, 0xd2, 0x8b, 0xd3, 0xe4, 0x7f, 0xb0, 0x37, 0x52, 0xec, 0xa2, 0xf0, 0x90, 0x04, 0x6a, 0x7d,
	0x83, 0xb7, 0x50, 0x53, 0xb7, 0x1c, 0xbc, 0x86, 0x9a, 0x76, 0x6f, 0x42, 0x7d, 0x4d, 0xbe, 0x90,
	0xe5, 0x37, 0x82, 0x2a, 0xb8, 0x0e, 0x55, 0x97, 0x4c, 0x90, 0xa1, 0x8a, 0x39, 0x99, 0x20, 0x73,
	0xe0, 0x43, 0xbd, 0xb0, 0x1a, 0x2c, 0x8a, 0x0e, 0x04, 0xad, 0xa2, 0x83, 0xfa, 0x3f, 0x1e, 0x5d,
	0x54, 0xc1, 0xb7, 0x80, 0xbe, 0x8f, 0xe9, 0xca, 0xf5, 0xd7, 0x8f, 0xf4, 0xe1, 0x7e, 0xf1, 0x75,
	0xed, 0xb9, 0xc8, 0xc0, 0x5d, 0x78, 0xee, 0x92, 0xd9, 0x94, 0xfe, 0x43, 0x99, 0x6f, 0x7e, 0x01,
	0xba, 0x7e, 0x63, 0xfc, 0x02, 0xba, 0x27, 0xdb, 0xe9, 0x92, 0x10, 0x77, 0xea, 0x2f, 0x96, 0x84,
	0xae, 0xfc, 0x7b, 0x7f, 0xbd, 0x42, 0x15, 0x6c, 0x83, 0x55, 0xc0, 0xee, 0x0c, 0x19, 0xb8, 0x03,
	0x36, 0x59, 0xfa, 0xb4, 0x84, 0x4c, 0xdc, 0x83, 0xbb, 0xf3, 0xf1, 0x22, 0xd1, 0x9d, 0xa1, 0x2a,
	0x6e, 0x03, 0x9c, 0x4c, 0xc9, 0x1c, 0xd5, 0xd8, 0x8d, 0xfe, 0xdb, 0xef, 0xff, 0x04, 0x00, 0x00,
	0xff, 0xff, 0x44, 0xa7, 0x9d, 0x8f, 0x43, 0x03, 0x00, 0x00,
}
