add all files from Hong
This commit is contained in:
369
grpc_server/dhcpServer/dhcp_server.pb.go
Normal file
369
grpc_server/dhcpServer/dhcp_server.pb.go
Normal file
@@ -0,0 +1,369 @@
|
||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-go v1.34.2-devel
|
||||
// protoc v3.12.4
|
||||
// source: dhcp_server.proto
|
||||
|
||||
package dhcpServer
|
||||
|
||||
import (
|
||||
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
|
||||
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
|
||||
reflect "reflect"
|
||||
sync "sync"
|
||||
)
|
||||
|
||||
const (
|
||||
// Verify that this generated code is sufficiently up-to-date.
|
||||
_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
|
||||
// Verify that runtime/protoimpl is sufficiently up-to-date.
|
||||
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
|
||||
)
|
||||
|
||||
type MacAddr struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
Mac string `protobuf:"bytes,1,opt,name=mac,proto3" json:"mac,omitempty"`
|
||||
}
|
||||
|
||||
func (x *MacAddr) Reset() {
|
||||
*x = MacAddr{}
|
||||
mi := &file_dhcp_server_proto_msgTypes[0]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
|
||||
func (x *MacAddr) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*MacAddr) ProtoMessage() {}
|
||||
|
||||
func (x *MacAddr) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_dhcp_server_proto_msgTypes[0]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use MacAddr.ProtoReflect.Descriptor instead.
|
||||
func (*MacAddr) Descriptor() ([]byte, []int) {
|
||||
return file_dhcp_server_proto_rawDescGZIP(), []int{0}
|
||||
}
|
||||
|
||||
func (x *MacAddr) GetMac() string {
|
||||
if x != nil {
|
||||
return x.Mac
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
// The response message containing the staInfo.
|
||||
type StaDhcpInfo struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
Ip string `protobuf:"bytes,1,opt,name=ip,proto3" json:"ip,omitempty"`
|
||||
Hostname string `protobuf:"bytes,2,opt,name=hostname,proto3" json:"hostname,omitempty"`
|
||||
}
|
||||
|
||||
func (x *StaDhcpInfo) Reset() {
|
||||
*x = StaDhcpInfo{}
|
||||
mi := &file_dhcp_server_proto_msgTypes[1]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
|
||||
func (x *StaDhcpInfo) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*StaDhcpInfo) ProtoMessage() {}
|
||||
|
||||
func (x *StaDhcpInfo) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_dhcp_server_proto_msgTypes[1]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use StaDhcpInfo.ProtoReflect.Descriptor instead.
|
||||
func (*StaDhcpInfo) Descriptor() ([]byte, []int) {
|
||||
return file_dhcp_server_proto_rawDescGZIP(), []int{1}
|
||||
}
|
||||
|
||||
func (x *StaDhcpInfo) GetIp() string {
|
||||
if x != nil {
|
||||
return x.Ip
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *StaDhcpInfo) GetHostname() string {
|
||||
if x != nil {
|
||||
return x.Hostname
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
type EmptyRequest struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
}
|
||||
|
||||
func (x *EmptyRequest) Reset() {
|
||||
*x = EmptyRequest{}
|
||||
mi := &file_dhcp_server_proto_msgTypes[2]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
|
||||
func (x *EmptyRequest) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*EmptyRequest) ProtoMessage() {}
|
||||
|
||||
func (x *EmptyRequest) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_dhcp_server_proto_msgTypes[2]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use EmptyRequest.ProtoReflect.Descriptor instead.
|
||||
func (*EmptyRequest) Descriptor() ([]byte, []int) {
|
||||
return file_dhcp_server_proto_rawDescGZIP(), []int{2}
|
||||
}
|
||||
|
||||
// The response message containing the dhcpInfo.
|
||||
type DhcpInfo struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
UeInfo []*UeInfo `protobuf:"bytes,1,rep,name=ueInfo,proto3" json:"ueInfo,omitempty"`
|
||||
}
|
||||
|
||||
func (x *DhcpInfo) Reset() {
|
||||
*x = DhcpInfo{}
|
||||
mi := &file_dhcp_server_proto_msgTypes[3]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
|
||||
func (x *DhcpInfo) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*DhcpInfo) ProtoMessage() {}
|
||||
|
||||
func (x *DhcpInfo) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_dhcp_server_proto_msgTypes[3]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use DhcpInfo.ProtoReflect.Descriptor instead.
|
||||
func (*DhcpInfo) Descriptor() ([]byte, []int) {
|
||||
return file_dhcp_server_proto_rawDescGZIP(), []int{3}
|
||||
}
|
||||
|
||||
func (x *DhcpInfo) GetUeInfo() []*UeInfo {
|
||||
if x != nil {
|
||||
return x.UeInfo
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type UeInfo struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
Ip string `protobuf:"bytes,1,opt,name=ip,proto3" json:"ip,omitempty"`
|
||||
Mac string `protobuf:"bytes,2,opt,name=mac,proto3" json:"mac,omitempty"`
|
||||
Hostname string `protobuf:"bytes,3,opt,name=hostname,proto3" json:"hostname,omitempty"`
|
||||
StartTime string `protobuf:"bytes,4,opt,name=startTime,proto3" json:"startTime,omitempty"`
|
||||
EndTime string `protobuf:"bytes,5,opt,name=endTime,proto3" json:"endTime,omitempty"`
|
||||
}
|
||||
|
||||
func (x *UeInfo) Reset() {
|
||||
*x = UeInfo{}
|
||||
mi := &file_dhcp_server_proto_msgTypes[4]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
|
||||
func (x *UeInfo) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*UeInfo) ProtoMessage() {}
|
||||
|
||||
func (x *UeInfo) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_dhcp_server_proto_msgTypes[4]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use UeInfo.ProtoReflect.Descriptor instead.
|
||||
func (*UeInfo) Descriptor() ([]byte, []int) {
|
||||
return file_dhcp_server_proto_rawDescGZIP(), []int{4}
|
||||
}
|
||||
|
||||
func (x *UeInfo) GetIp() string {
|
||||
if x != nil {
|
||||
return x.Ip
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *UeInfo) GetMac() string {
|
||||
if x != nil {
|
||||
return x.Mac
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *UeInfo) GetHostname() string {
|
||||
if x != nil {
|
||||
return x.Hostname
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *UeInfo) GetStartTime() string {
|
||||
if x != nil {
|
||||
return x.StartTime
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *UeInfo) GetEndTime() string {
|
||||
if x != nil {
|
||||
return x.EndTime
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
var File_dhcp_server_proto protoreflect.FileDescriptor
|
||||
|
||||
var file_dhcp_server_proto_rawDesc = []byte{
|
||||
0x0a, 0x11, 0x64, 0x68, 0x63, 0x70, 0x5f, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x2e, 0x70, 0x72,
|
||||
0x6f, 0x74, 0x6f, 0x22, 0x1b, 0x0a, 0x07, 0x4d, 0x61, 0x63, 0x41, 0x64, 0x64, 0x72, 0x12, 0x10,
|
||||
0x0a, 0x03, 0x6d, 0x61, 0x63, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6d, 0x61, 0x63,
|
||||
0x22, 0x39, 0x0a, 0x0b, 0x53, 0x74, 0x61, 0x44, 0x68, 0x63, 0x70, 0x49, 0x6e, 0x66, 0x6f, 0x12,
|
||||
0x0e, 0x0a, 0x02, 0x69, 0x70, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x70, 0x12,
|
||||
0x1a, 0x0a, 0x08, 0x68, 0x6f, 0x73, 0x74, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28,
|
||||
0x09, 0x52, 0x08, 0x68, 0x6f, 0x73, 0x74, 0x6e, 0x61, 0x6d, 0x65, 0x22, 0x0e, 0x0a, 0x0c, 0x45,
|
||||
0x6d, 0x70, 0x74, 0x79, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x22, 0x2b, 0x0a, 0x08, 0x44,
|
||||
0x68, 0x63, 0x70, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x1f, 0x0a, 0x06, 0x75, 0x65, 0x49, 0x6e, 0x66,
|
||||
0x6f, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x07, 0x2e, 0x55, 0x65, 0x49, 0x6e, 0x66, 0x6f,
|
||||
0x52, 0x06, 0x75, 0x65, 0x49, 0x6e, 0x66, 0x6f, 0x22, 0x7e, 0x0a, 0x06, 0x55, 0x65, 0x49, 0x6e,
|
||||
0x66, 0x6f, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x70, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02,
|
||||
0x69, 0x70, 0x12, 0x10, 0x0a, 0x03, 0x6d, 0x61, 0x63, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52,
|
||||
0x03, 0x6d, 0x61, 0x63, 0x12, 0x1a, 0x0a, 0x08, 0x68, 0x6f, 0x73, 0x74, 0x6e, 0x61, 0x6d, 0x65,
|
||||
0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x68, 0x6f, 0x73, 0x74, 0x6e, 0x61, 0x6d, 0x65,
|
||||
0x12, 0x1c, 0x0a, 0x09, 0x73, 0x74, 0x61, 0x72, 0x74, 0x54, 0x69, 0x6d, 0x65, 0x18, 0x04, 0x20,
|
||||
0x01, 0x28, 0x09, 0x52, 0x09, 0x73, 0x74, 0x61, 0x72, 0x74, 0x54, 0x69, 0x6d, 0x65, 0x12, 0x18,
|
||||
0x0a, 0x07, 0x65, 0x6e, 0x64, 0x54, 0x69, 0x6d, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52,
|
||||
0x07, 0x65, 0x6e, 0x64, 0x54, 0x69, 0x6d, 0x65, 0x32, 0x30, 0x0a, 0x0a, 0x53, 0x74, 0x61, 0x53,
|
||||
0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x22, 0x0a, 0x06, 0x47, 0x65, 0x74, 0x53, 0x74, 0x61,
|
||||
0x12, 0x08, 0x2e, 0x4d, 0x61, 0x63, 0x41, 0x64, 0x64, 0x72, 0x1a, 0x0c, 0x2e, 0x53, 0x74, 0x61,
|
||||
0x44, 0x68, 0x63, 0x70, 0x49, 0x6e, 0x66, 0x6f, 0x22, 0x00, 0x32, 0x34, 0x0a, 0x0b, 0x44, 0x68,
|
||||
0x63, 0x70, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x25, 0x0a, 0x07, 0x47, 0x65, 0x74,
|
||||
0x44, 0x68, 0x63, 0x70, 0x12, 0x0d, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x52, 0x65, 0x71, 0x75,
|
||||
0x65, 0x73, 0x74, 0x1a, 0x09, 0x2e, 0x44, 0x68, 0x63, 0x70, 0x49, 0x6e, 0x66, 0x6f, 0x22, 0x00,
|
||||
0x42, 0x0e, 0x5a, 0x0c, 0x2e, 0x2f, 0x64, 0x68, 0x63, 0x70, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72,
|
||||
0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||
}
|
||||
|
||||
var (
|
||||
file_dhcp_server_proto_rawDescOnce sync.Once
|
||||
file_dhcp_server_proto_rawDescData = file_dhcp_server_proto_rawDesc
|
||||
)
|
||||
|
||||
func file_dhcp_server_proto_rawDescGZIP() []byte {
|
||||
file_dhcp_server_proto_rawDescOnce.Do(func() {
|
||||
file_dhcp_server_proto_rawDescData = protoimpl.X.CompressGZIP(file_dhcp_server_proto_rawDescData)
|
||||
})
|
||||
return file_dhcp_server_proto_rawDescData
|
||||
}
|
||||
|
||||
var file_dhcp_server_proto_msgTypes = make([]protoimpl.MessageInfo, 5)
|
||||
var file_dhcp_server_proto_goTypes = []any{
|
||||
(*MacAddr)(nil), // 0: MacAddr
|
||||
(*StaDhcpInfo)(nil), // 1: StaDhcpInfo
|
||||
(*EmptyRequest)(nil), // 2: EmptyRequest
|
||||
(*DhcpInfo)(nil), // 3: DhcpInfo
|
||||
(*UeInfo)(nil), // 4: UeInfo
|
||||
}
|
||||
var file_dhcp_server_proto_depIdxs = []int32{
|
||||
4, // 0: DhcpInfo.ueInfo:type_name -> UeInfo
|
||||
0, // 1: StaService.GetSta:input_type -> MacAddr
|
||||
2, // 2: DhcpService.GetDhcp:input_type -> EmptyRequest
|
||||
1, // 3: StaService.GetSta:output_type -> StaDhcpInfo
|
||||
3, // 4: DhcpService.GetDhcp:output_type -> DhcpInfo
|
||||
3, // [3:5] is the sub-list for method output_type
|
||||
1, // [1:3] is the sub-list for method input_type
|
||||
1, // [1:1] is the sub-list for extension type_name
|
||||
1, // [1:1] is the sub-list for extension extendee
|
||||
0, // [0:1] is the sub-list for field type_name
|
||||
}
|
||||
|
||||
func init() { file_dhcp_server_proto_init() }
|
||||
func file_dhcp_server_proto_init() {
|
||||
if File_dhcp_server_proto != nil {
|
||||
return
|
||||
}
|
||||
type x struct{}
|
||||
out := protoimpl.TypeBuilder{
|
||||
File: protoimpl.DescBuilder{
|
||||
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
||||
RawDescriptor: file_dhcp_server_proto_rawDesc,
|
||||
NumEnums: 0,
|
||||
NumMessages: 5,
|
||||
NumExtensions: 0,
|
||||
NumServices: 2,
|
||||
},
|
||||
GoTypes: file_dhcp_server_proto_goTypes,
|
||||
DependencyIndexes: file_dhcp_server_proto_depIdxs,
|
||||
MessageInfos: file_dhcp_server_proto_msgTypes,
|
||||
}.Build()
|
||||
File_dhcp_server_proto = out.File
|
||||
file_dhcp_server_proto_rawDesc = nil
|
||||
file_dhcp_server_proto_goTypes = nil
|
||||
file_dhcp_server_proto_depIdxs = nil
|
||||
}
|
||||
231
grpc_server/dhcpServer/dhcp_server_grpc.pb.go
Normal file
231
grpc_server/dhcpServer/dhcp_server_grpc.pb.go
Normal file
@@ -0,0 +1,231 @@
|
||||
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
|
||||
// versions:
|
||||
// - protoc-gen-go-grpc v1.5.1
|
||||
// - protoc v3.12.4
|
||||
// source: dhcp_server.proto
|
||||
|
||||
package dhcpServer
|
||||
|
||||
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 (
|
||||
StaService_GetSta_FullMethodName = "/StaService/GetSta"
|
||||
)
|
||||
|
||||
// StaServiceClient is the client API for StaService 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.
|
||||
//
|
||||
// The get sta service definition.
|
||||
type StaServiceClient interface {
|
||||
GetSta(ctx context.Context, in *MacAddr, opts ...grpc.CallOption) (*StaDhcpInfo, error)
|
||||
}
|
||||
|
||||
type staServiceClient struct {
|
||||
cc grpc.ClientConnInterface
|
||||
}
|
||||
|
||||
func NewStaServiceClient(cc grpc.ClientConnInterface) StaServiceClient {
|
||||
return &staServiceClient{cc}
|
||||
}
|
||||
|
||||
func (c *staServiceClient) GetSta(ctx context.Context, in *MacAddr, opts ...grpc.CallOption) (*StaDhcpInfo, error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
out := new(StaDhcpInfo)
|
||||
err := c.cc.Invoke(ctx, StaService_GetSta_FullMethodName, in, out, cOpts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
// StaServiceServer is the server API for StaService service.
|
||||
// All implementations must embed UnimplementedStaServiceServer
|
||||
// for forward compatibility.
|
||||
//
|
||||
// The get sta service definition.
|
||||
type StaServiceServer interface {
|
||||
GetSta(context.Context, *MacAddr) (*StaDhcpInfo, error)
|
||||
mustEmbedUnimplementedStaServiceServer()
|
||||
}
|
||||
|
||||
// UnimplementedStaServiceServer 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 UnimplementedStaServiceServer struct{}
|
||||
|
||||
func (UnimplementedStaServiceServer) GetSta(context.Context, *MacAddr) (*StaDhcpInfo, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method GetSta not implemented")
|
||||
}
|
||||
func (UnimplementedStaServiceServer) mustEmbedUnimplementedStaServiceServer() {}
|
||||
func (UnimplementedStaServiceServer) testEmbeddedByValue() {}
|
||||
|
||||
// UnsafeStaServiceServer may be embedded to opt out of forward compatibility for this service.
|
||||
// Use of this interface is not recommended, as added methods to StaServiceServer will
|
||||
// result in compilation errors.
|
||||
type UnsafeStaServiceServer interface {
|
||||
mustEmbedUnimplementedStaServiceServer()
|
||||
}
|
||||
|
||||
func RegisterStaServiceServer(s grpc.ServiceRegistrar, srv StaServiceServer) {
|
||||
// If the following call panics, it indicates UnimplementedStaServiceServer 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(&StaService_ServiceDesc, srv)
|
||||
}
|
||||
|
||||
func _StaService_GetSta_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(MacAddr)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(StaServiceServer).GetSta(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: StaService_GetSta_FullMethodName,
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(StaServiceServer).GetSta(ctx, req.(*MacAddr))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
// StaService_ServiceDesc is the grpc.ServiceDesc for StaService service.
|
||||
// It's only intended for direct use with grpc.RegisterService,
|
||||
// and not to be introspected or modified (even as a copy)
|
||||
var StaService_ServiceDesc = grpc.ServiceDesc{
|
||||
ServiceName: "StaService",
|
||||
HandlerType: (*StaServiceServer)(nil),
|
||||
Methods: []grpc.MethodDesc{
|
||||
{
|
||||
MethodName: "GetSta",
|
||||
Handler: _StaService_GetSta_Handler,
|
||||
},
|
||||
},
|
||||
Streams: []grpc.StreamDesc{},
|
||||
Metadata: "dhcp_server.proto",
|
||||
}
|
||||
|
||||
const (
|
||||
DhcpService_GetDhcp_FullMethodName = "/DhcpService/GetDhcp"
|
||||
)
|
||||
|
||||
// DhcpServiceClient is the client API for DhcpService 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.
|
||||
//
|
||||
// The get dhcp service definition.
|
||||
type DhcpServiceClient interface {
|
||||
GetDhcp(ctx context.Context, in *EmptyRequest, opts ...grpc.CallOption) (*DhcpInfo, error)
|
||||
}
|
||||
|
||||
type dhcpServiceClient struct {
|
||||
cc grpc.ClientConnInterface
|
||||
}
|
||||
|
||||
func NewDhcpServiceClient(cc grpc.ClientConnInterface) DhcpServiceClient {
|
||||
return &dhcpServiceClient{cc}
|
||||
}
|
||||
|
||||
func (c *dhcpServiceClient) GetDhcp(ctx context.Context, in *EmptyRequest, opts ...grpc.CallOption) (*DhcpInfo, error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
out := new(DhcpInfo)
|
||||
err := c.cc.Invoke(ctx, DhcpService_GetDhcp_FullMethodName, in, out, cOpts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
// DhcpServiceServer is the server API for DhcpService service.
|
||||
// All implementations must embed UnimplementedDhcpServiceServer
|
||||
// for forward compatibility.
|
||||
//
|
||||
// The get dhcp service definition.
|
||||
type DhcpServiceServer interface {
|
||||
GetDhcp(context.Context, *EmptyRequest) (*DhcpInfo, error)
|
||||
mustEmbedUnimplementedDhcpServiceServer()
|
||||
}
|
||||
|
||||
// UnimplementedDhcpServiceServer 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 UnimplementedDhcpServiceServer struct{}
|
||||
|
||||
func (UnimplementedDhcpServiceServer) GetDhcp(context.Context, *EmptyRequest) (*DhcpInfo, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method GetDhcp not implemented")
|
||||
}
|
||||
func (UnimplementedDhcpServiceServer) mustEmbedUnimplementedDhcpServiceServer() {}
|
||||
func (UnimplementedDhcpServiceServer) testEmbeddedByValue() {}
|
||||
|
||||
// UnsafeDhcpServiceServer may be embedded to opt out of forward compatibility for this service.
|
||||
// Use of this interface is not recommended, as added methods to DhcpServiceServer will
|
||||
// result in compilation errors.
|
||||
type UnsafeDhcpServiceServer interface {
|
||||
mustEmbedUnimplementedDhcpServiceServer()
|
||||
}
|
||||
|
||||
func RegisterDhcpServiceServer(s grpc.ServiceRegistrar, srv DhcpServiceServer) {
|
||||
// If the following call panics, it indicates UnimplementedDhcpServiceServer 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(&DhcpService_ServiceDesc, srv)
|
||||
}
|
||||
|
||||
func _DhcpService_GetDhcp_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(EmptyRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(DhcpServiceServer).GetDhcp(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: DhcpService_GetDhcp_FullMethodName,
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(DhcpServiceServer).GetDhcp(ctx, req.(*EmptyRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
// DhcpService_ServiceDesc is the grpc.ServiceDesc for DhcpService service.
|
||||
// It's only intended for direct use with grpc.RegisterService,
|
||||
// and not to be introspected or modified (even as a copy)
|
||||
var DhcpService_ServiceDesc = grpc.ServiceDesc{
|
||||
ServiceName: "DhcpService",
|
||||
HandlerType: (*DhcpServiceServer)(nil),
|
||||
Methods: []grpc.MethodDesc{
|
||||
{
|
||||
MethodName: "GetDhcp",
|
||||
Handler: _DhcpService_GetDhcp_Handler,
|
||||
},
|
||||
},
|
||||
Streams: []grpc.StreamDesc{},
|
||||
Metadata: "dhcp_server.proto",
|
||||
}
|
||||
54
grpc_server/grpc_server.go
Normal file
54
grpc_server/grpc_server.go
Normal file
@@ -0,0 +1,54 @@
|
||||
package grpcServer
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net"
|
||||
|
||||
"google.golang.org/grpc"
|
||||
|
||||
"github.com/coredhcp/coredhcp/grpc_server/dhcpServer"
|
||||
"github.com/coredhcp/coredhcp/logger"
|
||||
rangeplugin "github.com/coredhcp/coredhcp/plugins/range"
|
||||
)
|
||||
|
||||
var log = logger.GetLogger("grpc")
|
||||
|
||||
type staServer struct {
|
||||
dhcpServer.UnimplementedStaServiceServer
|
||||
}
|
||||
|
||||
func (s *staServer) GetSta(ctx context.Context, req *dhcpServer.MacAddr) (*dhcpServer.StaDhcpInfo, error) {
|
||||
record := rangeplugin.GetRecord(req.Mac)
|
||||
if record != nil {
|
||||
return &dhcpServer.StaDhcpInfo{
|
||||
Ip: record.IP.String(),
|
||||
Hostname: record.Hostname,
|
||||
}, nil
|
||||
} else {
|
||||
return nil, nil
|
||||
}
|
||||
}
|
||||
|
||||
type dhcpService struct {
|
||||
dhcpServer.UnimplementedDhcpServiceServer
|
||||
}
|
||||
|
||||
func (d *dhcpService) GetDhcp(ctx context.Context, req *dhcpServer.EmptyRequest) (dhcpInfo *dhcpServer.DhcpInfo, err error) {
|
||||
return rangeplugin.GetDhcpInfo()
|
||||
}
|
||||
|
||||
func Run() {
|
||||
lis, err := net.Listen("tcp", "127.0.0.1:50051")
|
||||
if err != nil {
|
||||
log.Errorf("failed to listen: %v", err)
|
||||
}
|
||||
|
||||
s := grpc.NewServer()
|
||||
|
||||
dhcpServer.RegisterStaServiceServer(s, &staServer{})
|
||||
dhcpServer.RegisterDhcpServiceServer(s, &dhcpService{})
|
||||
|
||||
if err := s.Serve(lis); err != nil {
|
||||
log.Errorf("failed to serve: %v", err)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user