diff --git a/src/switch/api/v1/ned.proto b/src/switch/api/v1/ned.proto index 2a3e6a96b1a8d57918fb310d63981883cf929257..173df3f1b1a7a238c4f0933b3495d61bc6ac67d9 100644 --- a/src/switch/api/v1/ned.proto +++ b/src/switch/api/v1/ned.proto @@ -4,12 +4,15 @@ package nedpb; option go_package = "l2sm.local/ovs-switch/pkg/nedpb"; -service VxlanService { +service NedService { // Creates a VxLAN with the specified IP address. rpc CreateVxlan(CreateVxlanRequest) returns (CreateVxlanResponse); // Attaches the specified interface to the bridge. rpc AttachInterface(AttachInterfaceRequest) returns (AttachInterfaceResponse); + + // Returns this neds node name + rpc GetNodeName(GetNodeNameRequest) returns (GetNodeNameResponse); } message CreateVxlanRequest { @@ -32,6 +35,11 @@ message AttachInterfaceRequest { message AttachInterfaceResponse { // The OpenFlow ID of the attached interface. int64 interface_num = 1; - // The node name from the environment variable. - string node_name = 2; } + +message GetNodeNameRequest { + +} +message GetNodeNameResponse { + string node_name = 1; +} \ No newline at end of file diff --git a/src/switch/cmd/grpc-server/main.go b/src/switch/cmd/grpc-server/main.go deleted file mode 100644 index 85bcee32db04af50b9c5a7722df49ee8b2279d1d..0000000000000000000000000000000000000000 --- a/src/switch/cmd/grpc-server/main.go +++ /dev/null @@ -1,76 +0,0 @@ -package main - -import ( - "context" - "fmt" - "log" - "net" - "os" - - "google.golang.org/grpc" - - // Adjust the import path based on your module path - - "l2sm.local/ovs-switch/pkg/nedpb" - "l2sm.local/ovs-switch/pkg/ovs" -) - -// server is used to implement nedpb.VxlanServiceServer -type server struct { - nedpb.UnimplementedVxlanServiceServer -} - -// CreateVxlan implements nedpb.VxlanServiceServer -func (s *server) CreateVxlan(ctx context.Context, req *nedpb.CreateVxlanRequest) (*nedpb.CreateVxlanResponse, error) { - ipAddress := req.GetIpAddress() - - // Implement your logic to create a VxLAN with the given IP address - // For example, call a function from pkg/ovs/vsctl.go - // success, message := ovs.CreateVxlan(ipAddress) - - // Placeholder implementation - bridge := ovs.FromName("brtun") - bridge.CreateVxlan(ovs.Vxlan{"", "", ipAddress, ""}) - message := fmt.Sprintf("VxLAN with IP %s created successfully", ipAddress) - - return &nedpb.CreateVxlanResponse{ - Success: success, - Message: message, - }, nil -} - -// AttachInterface implements nedpb.VxlanServiceServer -func (s *server) AttachInterface(ctx context.Context, req *nedpb.AttachInterfaceRequest) (*nedpb.AttachInterfaceResponse, error) { - interfaceName := req.GetInterfaceName() - - // Implement your logic to attach the interface to the bridge - // For example, call a function from pkg/ovs/vsctl.go - // openflowID, err := ovs.AttachInterface(interfaceName) - - // Placeholder implementation - nodeName := os.Getenv("NODE_NAME") - - return &nedpb.AttachInterfaceResponse{ - OpenflowId: openflowID, - NodeName: nodeName, - }, nil -} - -func main() { - // Listen on a TCP port - lis, err := net.Listen("tcp", ":50051") // Choose your port - if err != nil { - log.Fatalf("failed to listen: %v", err) - } - - // Create a gRPC server - grpcServer := grpc.NewServer() - - // Register the server - nedpb.RegisterVxlanServiceServer(grpcServer, &server{}) - - log.Printf("gRPC server listening on :50051") - if err := grpcServer.Serve(lis); err != nil { - log.Fatalf("failed to serve: %v", err) - } -} diff --git a/src/switch/cmd/ned-server/main.go b/src/switch/cmd/ned-server/main.go new file mode 100644 index 0000000000000000000000000000000000000000..490ac0fbc88d4fd2a6e9e905d1d85daf30572901 --- /dev/null +++ b/src/switch/cmd/ned-server/main.go @@ -0,0 +1,174 @@ +package main + +import ( + "context" + "errors" + "flag" + "fmt" + "log" + "net" + "os/exec" + "time" + + "google.golang.org/grpc" + + // Adjust the import path based on your module path + nedv1 "l2sm.local/ovs-switch/api/v1" + + "l2sm.local/ovs-switch/internal/inits" + "l2sm.local/ovs-switch/pkg/nedpb" + "l2sm.local/ovs-switch/pkg/ovs" +) + +// server is used to implement nedpb.VxlanServiceServer +type server struct { + nedpb.UnimplementedNedServiceServer + Bridge ovs.Bridge + Settings nedv1.NedSettings +} + +func main() { + configDir, neighborsDir, err := takeArguments() + + if err != nil { + fmt.Println("Error with the arguments provided. Error:", err) + return + } + + var settings nedv1.NedSettings + err = inits.ReadFile(configDir, &settings) + + if err != nil { + fmt.Println("Error with the provided file. Error:", err) + return + } + + fmt.Println("Initializing switch, connected to controller: ", settings.ControllerIP) + + bridge, err := inits.InitializeSwitch(settings.NedName, settings.ControllerIP) + if err != nil { + log.Fatalf("error initializing ned: %v", err) + } + + var node nedv1.Node + err = inits.ReadFile(neighborsDir, &node) + + if err != nil { + fmt.Println("Error with the provided file. Error:", err) + return + } + + err = inits.ConnectToNeighbors(bridge, node) + if err != nil { + fmt.Println("Could not connect neighbors: ", err) + return + } + + // Listen on a TCP port + lis, err := net.Listen("tcp", ":50051") // Choose your port + if err != nil { + log.Fatalf("failed to listen: %v", err) + } + + // Create a gRPC server + grpcServer := grpc.NewServer() + + // Register the server + nedpb.RegisterNedServiceServer(grpcServer, &server{Bridge: bridge, Settings: settings}) + + log.Printf("gRPC server listening on :50051") + if err := grpcServer.Serve(lis); err != nil { + log.Fatalf("failed to serve: %v", err) + } +} + +// CreateVxlan implements nedpb.VxlanServiceServer +func (s *server) CreateVxlan(ctx context.Context, req *nedpb.CreateVxlanRequest) (*nedpb.CreateVxlanResponse, error) { + ipAddress := req.GetIpAddress() + + // Implement your logic to create a VxLAN with the given IP address + // For example, call a function from pkg/ovs/vsctl.go + // success, message := ovs.CreateVxlan(ipAddress) + + // Placeholder implementation + bridge := ovs.FromName("brtun") + bridge.CreateVxlan(ovs.Vxlan{VxlanId: "", LocalIp: "", RemoteIp: ipAddress, UdpPort: ""}) + message := fmt.Sprintf("VxLAN with IP %s created successfully", ipAddress) + + return &nedpb.CreateVxlanResponse{ + Success: true, + Message: message, + }, nil +} + +// AttachInterface implements nedpb.VxlanServiceServer +func (s *server) AttachInterface(ctx context.Context, req *nedpb.AttachInterfaceRequest) (*nedpb.AttachInterfaceResponse, error) { + interfaceName := req.GetInterfaceName() + + // Create a new interface and attach it to the bridge + newPort, err := AddInterfaceToBridge(interfaceName) + if err != nil { + return nil, fmt.Errorf("failed to add interface to bridge: %v", err) + } + + interfaceNum, err := s.Bridge.GetPortNumber(newPort) + if err != nil { + return nil, fmt.Errorf("failed to get port number: %v", err) + } + + nodeName := s.Settings.NodeName + if nodeName == "" { + nodeName = "default-node" // Fallback if NODE_NAME is not set + } + + return &nedpb.AttachInterfaceResponse{ + InterfaceNum: interfaceNum, + NodeName: nodeName, + }, nil +} + +// AddInterfaceToBridge creates a new veth pair, attaches one end to the specified bridge, +// and returns the name of the other end. +func AddInterfaceToBridge(bridgeName string) (string, error) { + // Generate unique interface names + timestamp := time.Now().UnixNano() + vethName := fmt.Sprintf("veth%d", timestamp) + peerName := fmt.Sprintf("vpeer%d", timestamp) + + // Create the veth pair + if err := exec.Command("ip", "link", "add", vethName, "type", "veth", "peer", "name", peerName).Run(); err != nil { + return "", fmt.Errorf("failed to create veth pair: %v", err) + } + + // Set both interfaces up + if err := exec.Command("ip", "link", "set", vethName, "up").Run(); err != nil { + return "", fmt.Errorf("failed to set %s up: %v", vethName, err) + } + if err := exec.Command("ip", "link", "set", peerName, "up").Run(); err != nil { + return "", fmt.Errorf("failed to set %s up: %v", peerName, err) + } + + // Add one end to the Linux bridge + if err := exec.Command("ip", "link", "set", vethName, "master", bridgeName).Run(); err != nil { + return "", fmt.Errorf("failed to add %s to bridge %s: %v", vethName, bridgeName, err) + } + + return peerName, nil +} + +func takeArguments() (string, string, error) { + + configDir := flag.String("config_dir", "", "directory where the ned settings are specified. Required") + neighborsDir := flag.String("neighbors_dir", "", "directory where the ned's neighbors are specified. Required") + + flag.Parse() + + switch { + case *configDir == "": + return "", "", errors.New("config directory is not defined") + case *neighborsDir == "": + return "", "", errors.New("provider name is not defined") + } + + return *configDir, *neighborsDir, nil +} diff --git a/src/switch/pkg/nedpb/ned.pb.go b/src/switch/pkg/nedpb/ned.pb.go index 7a03427b916b1d3a3c42bf1e85733726371ea72a..3f99b92ba329bb6723ee6838d7561eccbe7e0fbb 100644 --- a/src/switch/pkg/nedpb/ned.pb.go +++ b/src/switch/pkg/nedpb/ned.pb.go @@ -179,7 +179,7 @@ type AttachInterfaceResponse struct { unknownFields protoimpl.UnknownFields // The OpenFlow ID of the attached interface. - OpenflowId int64 `protobuf:"varint,1,opt,name=openflow_id,json=openflowId,proto3" json:"openflow_id,omitempty"` + InterfaceNum int64 `protobuf:"varint,1,opt,name=interface_num,json=interfaceNum,proto3" json:"interface_num,omitempty"` // The node name from the environment variable. NodeName string `protobuf:"bytes,2,opt,name=node_name,json=nodeName,proto3" json:"node_name,omitempty"` } @@ -216,9 +216,9 @@ func (*AttachInterfaceResponse) Descriptor() ([]byte, []int) { return file_ned_proto_rawDescGZIP(), []int{3} } -func (x *AttachInterfaceResponse) GetOpenflowId() int64 { +func (x *AttachInterfaceResponse) GetInterfaceNum() int64 { if x != nil { - return x.OpenflowId + return x.InterfaceNum } return 0 } @@ -246,25 +246,26 @@ var file_ned_proto_rawDesc = []byte{ 0x72, 0x66, 0x61, 0x63, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x25, 0x0a, 0x0e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x66, 0x61, 0x63, 0x65, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x66, 0x61, 0x63, 0x65, 0x4e, - 0x61, 0x6d, 0x65, 0x22, 0x57, 0x0a, 0x17, 0x41, 0x74, 0x74, 0x61, 0x63, 0x68, 0x49, 0x6e, 0x74, - 0x65, 0x72, 0x66, 0x61, 0x63, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x1f, - 0x0a, 0x0b, 0x6f, 0x70, 0x65, 0x6e, 0x66, 0x6c, 0x6f, 0x77, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, - 0x01, 0x28, 0x03, 0x52, 0x0a, 0x6f, 0x70, 0x65, 0x6e, 0x66, 0x6c, 0x6f, 0x77, 0x49, 0x64, 0x12, - 0x1b, 0x0a, 0x09, 0x6e, 0x6f, 0x64, 0x65, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, - 0x28, 0x09, 0x52, 0x08, 0x6e, 0x6f, 0x64, 0x65, 0x4e, 0x61, 0x6d, 0x65, 0x32, 0xa6, 0x01, 0x0a, - 0x0c, 0x56, 0x78, 0x6c, 0x61, 0x6e, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x44, 0x0a, - 0x0b, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x56, 0x78, 0x6c, 0x61, 0x6e, 0x12, 0x19, 0x2e, 0x6e, - 0x65, 0x64, 0x70, 0x62, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x56, 0x78, 0x6c, 0x61, 0x6e, - 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1a, 0x2e, 0x6e, 0x65, 0x64, 0x70, 0x62, 0x2e, - 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x56, 0x78, 0x6c, 0x61, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, - 0x6e, 0x73, 0x65, 0x12, 0x50, 0x0a, 0x0f, 0x41, 0x74, 0x74, 0x61, 0x63, 0x68, 0x49, 0x6e, 0x74, - 0x65, 0x72, 0x66, 0x61, 0x63, 0x65, 0x12, 0x1d, 0x2e, 0x6e, 0x65, 0x64, 0x70, 0x62, 0x2e, 0x41, - 0x74, 0x74, 0x61, 0x63, 0x68, 0x49, 0x6e, 0x74, 0x65, 0x72, 0x66, 0x61, 0x63, 0x65, 0x52, 0x65, - 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1e, 0x2e, 0x6e, 0x65, 0x64, 0x70, 0x62, 0x2e, 0x41, 0x74, - 0x74, 0x61, 0x63, 0x68, 0x49, 0x6e, 0x74, 0x65, 0x72, 0x66, 0x61, 0x63, 0x65, 0x52, 0x65, 0x73, - 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x42, 0x21, 0x5a, 0x1f, 0x6c, 0x32, 0x73, 0x6d, 0x2e, 0x6c, 0x6f, - 0x63, 0x61, 0x6c, 0x2f, 0x6f, 0x76, 0x73, 0x2d, 0x73, 0x77, 0x69, 0x74, 0x63, 0x68, 0x2f, 0x70, - 0x6b, 0x67, 0x2f, 0x6e, 0x65, 0x64, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x61, 0x6d, 0x65, 0x22, 0x5b, 0x0a, 0x17, 0x41, 0x74, 0x74, 0x61, 0x63, 0x68, 0x49, 0x6e, 0x74, + 0x65, 0x72, 0x66, 0x61, 0x63, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x23, + 0x0a, 0x0d, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x66, 0x61, 0x63, 0x65, 0x5f, 0x6e, 0x75, 0x6d, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0c, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x66, 0x61, 0x63, 0x65, + 0x4e, 0x75, 0x6d, 0x12, 0x1b, 0x0a, 0x09, 0x6e, 0x6f, 0x64, 0x65, 0x5f, 0x6e, 0x61, 0x6d, 0x65, + 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x6e, 0x6f, 0x64, 0x65, 0x4e, 0x61, 0x6d, 0x65, + 0x32, 0xa4, 0x01, 0x0a, 0x0a, 0x4e, 0x65, 0x64, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, + 0x44, 0x0a, 0x0b, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x56, 0x78, 0x6c, 0x61, 0x6e, 0x12, 0x19, + 0x2e, 0x6e, 0x65, 0x64, 0x70, 0x62, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x56, 0x78, 0x6c, + 0x61, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1a, 0x2e, 0x6e, 0x65, 0x64, 0x70, + 0x62, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x56, 0x78, 0x6c, 0x61, 0x6e, 0x52, 0x65, 0x73, + 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x50, 0x0a, 0x0f, 0x41, 0x74, 0x74, 0x61, 0x63, 0x68, 0x49, + 0x6e, 0x74, 0x65, 0x72, 0x66, 0x61, 0x63, 0x65, 0x12, 0x1d, 0x2e, 0x6e, 0x65, 0x64, 0x70, 0x62, + 0x2e, 0x41, 0x74, 0x74, 0x61, 0x63, 0x68, 0x49, 0x6e, 0x74, 0x65, 0x72, 0x66, 0x61, 0x63, 0x65, + 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1e, 0x2e, 0x6e, 0x65, 0x64, 0x70, 0x62, 0x2e, + 0x41, 0x74, 0x74, 0x61, 0x63, 0x68, 0x49, 0x6e, 0x74, 0x65, 0x72, 0x66, 0x61, 0x63, 0x65, 0x52, + 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x42, 0x21, 0x5a, 0x1f, 0x6c, 0x32, 0x73, 0x6d, 0x2e, + 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x2f, 0x6f, 0x76, 0x73, 0x2d, 0x73, 0x77, 0x69, 0x74, 0x63, 0x68, + 0x2f, 0x70, 0x6b, 0x67, 0x2f, 0x6e, 0x65, 0x64, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, + 0x6f, 0x33, } var ( @@ -287,10 +288,10 @@ var file_ned_proto_goTypes = []any{ (*AttachInterfaceResponse)(nil), // 3: nedpb.AttachInterfaceResponse } var file_ned_proto_depIdxs = []int32{ - 0, // 0: nedpb.VxlanService.CreateVxlan:input_type -> nedpb.CreateVxlanRequest - 2, // 1: nedpb.VxlanService.AttachInterface:input_type -> nedpb.AttachInterfaceRequest - 1, // 2: nedpb.VxlanService.CreateVxlan:output_type -> nedpb.CreateVxlanResponse - 3, // 3: nedpb.VxlanService.AttachInterface:output_type -> nedpb.AttachInterfaceResponse + 0, // 0: nedpb.NedService.CreateVxlan:input_type -> nedpb.CreateVxlanRequest + 2, // 1: nedpb.NedService.AttachInterface:input_type -> nedpb.AttachInterfaceRequest + 1, // 2: nedpb.NedService.CreateVxlan:output_type -> nedpb.CreateVxlanResponse + 3, // 3: nedpb.NedService.AttachInterface:output_type -> nedpb.AttachInterfaceResponse 2, // [2:4] is the sub-list for method output_type 0, // [0:2] is the sub-list for method input_type 0, // [0:0] is the sub-list for extension type_name diff --git a/src/switch/pkg/nedpb/ned_grpc.pb.go b/src/switch/pkg/nedpb/ned_grpc.pb.go new file mode 100644 index 0000000000000000000000000000000000000000..30f0b9b81a1d39e178cd32e81098c742708bf8d9 --- /dev/null +++ b/src/switch/pkg/nedpb/ned_grpc.pb.go @@ -0,0 +1,163 @@ +// Code generated by protoc-gen-go-grpc. DO NOT EDIT. +// versions: +// - protoc-gen-go-grpc v1.5.1 +// - protoc v5.28.2 +// source: ned.proto + +package nedpb + +import ( + context "context" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" +) + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +// Requires gRPC-Go v1.64.0 or later. +const _ = grpc.SupportPackageIsVersion9 + +const ( + NedService_CreateVxlan_FullMethodName = "/nedpb.NedService/CreateVxlan" + NedService_AttachInterface_FullMethodName = "/nedpb.NedService/AttachInterface" +) + +// NedServiceClient is the client API for NedService service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. +type NedServiceClient interface { + // Creates a VxLAN with the specified IP address. + CreateVxlan(ctx context.Context, in *CreateVxlanRequest, opts ...grpc.CallOption) (*CreateVxlanResponse, error) + // Attaches the specified interface to the bridge. + AttachInterface(ctx context.Context, in *AttachInterfaceRequest, opts ...grpc.CallOption) (*AttachInterfaceResponse, error) +} + +type nedServiceClient struct { + cc grpc.ClientConnInterface +} + +func NewNedServiceClient(cc grpc.ClientConnInterface) NedServiceClient { + return &nedServiceClient{cc} +} + +func (c *nedServiceClient) CreateVxlan(ctx context.Context, in *CreateVxlanRequest, opts ...grpc.CallOption) (*CreateVxlanResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(CreateVxlanResponse) + err := c.cc.Invoke(ctx, NedService_CreateVxlan_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *nedServiceClient) AttachInterface(ctx context.Context, in *AttachInterfaceRequest, opts ...grpc.CallOption) (*AttachInterfaceResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(AttachInterfaceResponse) + err := c.cc.Invoke(ctx, NedService_AttachInterface_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +// NedServiceServer is the server API for NedService service. +// All implementations must embed UnimplementedNedServiceServer +// for forward compatibility. +type NedServiceServer interface { + // Creates a VxLAN with the specified IP address. + CreateVxlan(context.Context, *CreateVxlanRequest) (*CreateVxlanResponse, error) + // Attaches the specified interface to the bridge. + AttachInterface(context.Context, *AttachInterfaceRequest) (*AttachInterfaceResponse, error) + mustEmbedUnimplementedNedServiceServer() +} + +// UnimplementedNedServiceServer must be embedded to have +// forward compatible implementations. +// +// NOTE: this should be embedded by value instead of pointer to avoid a nil +// pointer dereference when methods are called. +type UnimplementedNedServiceServer struct{} + +func (UnimplementedNedServiceServer) CreateVxlan(context.Context, *CreateVxlanRequest) (*CreateVxlanResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method CreateVxlan not implemented") +} +func (UnimplementedNedServiceServer) AttachInterface(context.Context, *AttachInterfaceRequest) (*AttachInterfaceResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method AttachInterface not implemented") +} +func (UnimplementedNedServiceServer) mustEmbedUnimplementedNedServiceServer() {} +func (UnimplementedNedServiceServer) testEmbeddedByValue() {} + +// UnsafeNedServiceServer may be embedded to opt out of forward compatibility for this service. +// Use of this interface is not recommended, as added methods to NedServiceServer will +// result in compilation errors. +type UnsafeNedServiceServer interface { + mustEmbedUnimplementedNedServiceServer() +} + +func RegisterNedServiceServer(s grpc.ServiceRegistrar, srv NedServiceServer) { + // If the following call pancis, it indicates UnimplementedNedServiceServer was + // embedded by pointer and is nil. This will cause panics if an + // unimplemented method is ever invoked, so we test this at initialization + // time to prevent it from happening at runtime later due to I/O. + if t, ok := srv.(interface{ testEmbeddedByValue() }); ok { + t.testEmbeddedByValue() + } + s.RegisterService(&NedService_ServiceDesc, srv) +} + +func _NedService_CreateVxlan_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(CreateVxlanRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(NedServiceServer).CreateVxlan(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: NedService_CreateVxlan_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(NedServiceServer).CreateVxlan(ctx, req.(*CreateVxlanRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _NedService_AttachInterface_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(AttachInterfaceRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(NedServiceServer).AttachInterface(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: NedService_AttachInterface_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(NedServiceServer).AttachInterface(ctx, req.(*AttachInterfaceRequest)) + } + return interceptor(ctx, in, info, handler) +} + +// NedService_ServiceDesc is the grpc.ServiceDesc for NedService service. +// It's only intended for direct use with grpc.RegisterService, +// and not to be introspected or modified (even as a copy) +var NedService_ServiceDesc = grpc.ServiceDesc{ + ServiceName: "nedpb.NedService", + HandlerType: (*NedServiceServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "CreateVxlan", + Handler: _NedService_CreateVxlan_Handler, + }, + { + MethodName: "AttachInterface", + Handler: _NedService_AttachInterface_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "ned.proto", +}