working commit
This commit is contained in:
@@ -217,6 +217,7 @@ distcleancheck_listfiles = \
|
|||||||
ACLOCAL = ${SHELL} '/home/ziggi/Projects/tcpserv09/missing' aclocal-1.17
|
ACLOCAL = ${SHELL} '/home/ziggi/Projects/tcpserv09/missing' aclocal-1.17
|
||||||
AMTAR = $${TAR-tar}
|
AMTAR = $${TAR-tar}
|
||||||
AM_DEFAULT_VERBOSITY = 1
|
AM_DEFAULT_VERBOSITY = 1
|
||||||
|
ASTYLE = /bin/astyle
|
||||||
AUTOCONF = ${SHELL} '/home/ziggi/Projects/tcpserv09/missing' autoconf
|
AUTOCONF = ${SHELL} '/home/ziggi/Projects/tcpserv09/missing' autoconf
|
||||||
AUTOHEADER = ${SHELL} '/home/ziggi/Projects/tcpserv09/missing' autoheader
|
AUTOHEADER = ${SHELL} '/home/ziggi/Projects/tcpserv09/missing' autoheader
|
||||||
AUTOMAKE = ${SHELL} '/home/ziggi/Projects/tcpserv09/missing' automake-1.17
|
AUTOMAKE = ${SHELL} '/home/ziggi/Projects/tcpserv09/missing' automake-1.17
|
||||||
@@ -334,6 +335,7 @@ udpclient_test_SOURCES = \
|
|||||||
udpclient.cpp udpclient.hpp \
|
udpclient.cpp udpclient.hpp \
|
||||||
udpclient_test.cpp
|
udpclient_test.cpp
|
||||||
|
|
||||||
|
ASTYLE_OPTS = --indent=spaces=8 --style=java
|
||||||
all: defines.h
|
all: defines.h
|
||||||
$(MAKE) $(AM_MAKEFLAGS) all-am
|
$(MAKE) $(AM_MAKEFLAGS) all-am
|
||||||
|
|
||||||
@@ -835,11 +837,14 @@ run: helmetd
|
|||||||
|
|
||||||
hello.pb.cc hello.pb.h: hello.proto
|
hello.pb.cc hello.pb.h: hello.proto
|
||||||
$(PROTOC) --cpp_out=. hello.proto
|
$(PROTOC) --cpp_out=. hello.proto
|
||||||
|
format:
|
||||||
|
$(ASTYLE) $(ASTYLE_OPTS) *.hpp *.cpp
|
||||||
|
|
||||||
clean-local:
|
clean-local:
|
||||||
rm -rf autom4te.cache
|
rm -rf autom4te.cache
|
||||||
rm -f *~
|
rm -f *~
|
||||||
rm -f *.o
|
rm -f *.o
|
||||||
|
rm -f *.orig
|
||||||
|
|
||||||
# Tell versions [3.59,3.63) of GNU make to not export all variables.
|
# Tell versions [3.59,3.63) of GNU make to not export all variables.
|
||||||
# Otherwise a system limit (for SysV at least) may be exceeded.
|
# Otherwise a system limit (for SysV at least) may be exceeded.
|
||||||
|
|||||||
@@ -45,8 +45,14 @@ run: helmetd
|
|||||||
hello.pb.cc hello.pb.h: hello.proto
|
hello.pb.cc hello.pb.h: hello.proto
|
||||||
$(PROTOC) --cpp_out=. hello.proto
|
$(PROTOC) --cpp_out=. hello.proto
|
||||||
|
|
||||||
|
ASTYLE_OPTS = --indent=spaces=8 --style=java
|
||||||
|
format:
|
||||||
|
$(ASTYLE) $(ASTYLE_OPTS) *.hpp *.cpp
|
||||||
|
|
||||||
clean-local:
|
clean-local:
|
||||||
rm -rf autom4te.cache
|
rm -rf autom4te.cache
|
||||||
rm -f *~
|
rm -f *~
|
||||||
rm -f *.o
|
rm -f *.o
|
||||||
|
rm -f *.orig
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -217,6 +217,7 @@ distcleancheck_listfiles = \
|
|||||||
ACLOCAL = @ACLOCAL@
|
ACLOCAL = @ACLOCAL@
|
||||||
AMTAR = @AMTAR@
|
AMTAR = @AMTAR@
|
||||||
AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
|
AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
|
||||||
|
ASTYLE = @ASTYLE@
|
||||||
AUTOCONF = @AUTOCONF@
|
AUTOCONF = @AUTOCONF@
|
||||||
AUTOHEADER = @AUTOHEADER@
|
AUTOHEADER = @AUTOHEADER@
|
||||||
AUTOMAKE = @AUTOMAKE@
|
AUTOMAKE = @AUTOMAKE@
|
||||||
@@ -334,6 +335,7 @@ udpclient_test_SOURCES = \
|
|||||||
udpclient.cpp udpclient.hpp \
|
udpclient.cpp udpclient.hpp \
|
||||||
udpclient_test.cpp
|
udpclient_test.cpp
|
||||||
|
|
||||||
|
ASTYLE_OPTS = --indent=spaces=8 --style=java
|
||||||
all: defines.h
|
all: defines.h
|
||||||
$(MAKE) $(AM_MAKEFLAGS) all-am
|
$(MAKE) $(AM_MAKEFLAGS) all-am
|
||||||
|
|
||||||
@@ -835,11 +837,14 @@ run: helmetd
|
|||||||
|
|
||||||
hello.pb.cc hello.pb.h: hello.proto
|
hello.pb.cc hello.pb.h: hello.proto
|
||||||
$(PROTOC) --cpp_out=. hello.proto
|
$(PROTOC) --cpp_out=. hello.proto
|
||||||
|
format:
|
||||||
|
$(ASTYLE) $(ASTYLE_OPTS) *.hpp *.cpp
|
||||||
|
|
||||||
clean-local:
|
clean-local:
|
||||||
rm -rf autom4te.cache
|
rm -rf autom4te.cache
|
||||||
rm -f *~
|
rm -f *~
|
||||||
rm -f *.o
|
rm -f *.o
|
||||||
|
rm -f *.orig
|
||||||
|
|
||||||
# Tell versions [3.59,3.63) of GNU make to not export all variables.
|
# Tell versions [3.59,3.63) of GNU make to not export all variables.
|
||||||
# Otherwise a system limit (for SysV at least) may be exceeded.
|
# Otherwise a system limit (for SysV at least) may be exceeded.
|
||||||
|
|||||||
@@ -610,6 +610,7 @@ ac_subst_vars='am__EXEEXT_FALSE
|
|||||||
am__EXEEXT_TRUE
|
am__EXEEXT_TRUE
|
||||||
LTLIBOBJS
|
LTLIBOBJS
|
||||||
LIBOBJS
|
LIBOBJS
|
||||||
|
ASTYLE
|
||||||
PROTOC
|
PROTOC
|
||||||
am__fastdepCXX_FALSE
|
am__fastdepCXX_FALSE
|
||||||
am__fastdepCXX_TRUE
|
am__fastdepCXX_TRUE
|
||||||
@@ -4879,7 +4880,7 @@ fi
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
for ac_prog in protoc
|
for ac_prog in protoc true
|
||||||
do
|
do
|
||||||
# Extract the first word of "$ac_prog", so it can be a program name with args.
|
# Extract the first word of "$ac_prog", so it can be a program name with args.
|
||||||
set dummy $ac_prog; ac_word=$2
|
set dummy $ac_prog; ac_word=$2
|
||||||
@@ -4930,6 +4931,58 @@ fi
|
|||||||
test -n "$PROTOC" && break
|
test -n "$PROTOC" && break
|
||||||
done
|
done
|
||||||
|
|
||||||
|
for ac_prog in astyle true
|
||||||
|
do
|
||||||
|
# Extract the first word of "$ac_prog", so it can be a program name with args.
|
||||||
|
set dummy $ac_prog; ac_word=$2
|
||||||
|
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
|
||||||
|
printf %s "checking for $ac_word... " >&6; }
|
||||||
|
if test ${ac_cv_path_ASTYLE+y}
|
||||||
|
then :
|
||||||
|
printf %s "(cached) " >&6
|
||||||
|
else case e in #(
|
||||||
|
e) case $ASTYLE in
|
||||||
|
[\\/]* | ?:[\\/]*)
|
||||||
|
ac_cv_path_ASTYLE="$ASTYLE" # Let the user override the test with a path.
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
|
||||||
|
for as_dir in $PATH
|
||||||
|
do
|
||||||
|
IFS=$as_save_IFS
|
||||||
|
case $as_dir in #(((
|
||||||
|
'') as_dir=./ ;;
|
||||||
|
*/) ;;
|
||||||
|
*) as_dir=$as_dir/ ;;
|
||||||
|
esac
|
||||||
|
for ac_exec_ext in '' $ac_executable_extensions; do
|
||||||
|
if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then
|
||||||
|
ac_cv_path_ASTYLE="$as_dir$ac_word$ac_exec_ext"
|
||||||
|
printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5
|
||||||
|
break 2
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
done
|
||||||
|
IFS=$as_save_IFS
|
||||||
|
|
||||||
|
;;
|
||||||
|
esac ;;
|
||||||
|
esac
|
||||||
|
fi
|
||||||
|
ASTYLE=$ac_cv_path_ASTYLE
|
||||||
|
if test -n "$ASTYLE"; then
|
||||||
|
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ASTYLE" >&5
|
||||||
|
printf "%s\n" "$ASTYLE" >&6; }
|
||||||
|
else
|
||||||
|
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5
|
||||||
|
printf "%s\n" "no" >&6; }
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
test -n "$ASTYLE" && break
|
||||||
|
done
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
ac_config_files="$ac_config_files Makefile"
|
ac_config_files="$ac_config_files Makefile"
|
||||||
|
|
||||||
|
|||||||
+3
-1
@@ -7,7 +7,9 @@ AC_PROG_CC([gcc cc])
|
|||||||
AC_PROG_RANLIB
|
AC_PROG_RANLIB
|
||||||
AC_PROG_CXX([g++ c++])
|
AC_PROG_CXX([g++ c++])
|
||||||
|
|
||||||
AC_PATH_PROGS([PROTOC],[protoc])
|
AC_PATH_PROGS([PROTOC],[protoc true])
|
||||||
|
AC_PATH_PROGS([ASTYLE],[astyle true])
|
||||||
|
|
||||||
|
|
||||||
AC_CONFIG_FILES([
|
AC_CONFIG_FILES([
|
||||||
Makefile
|
Makefile
|
||||||
|
|||||||
+176
-173
@@ -19,17 +19,17 @@ namespace _pbi = _pb::internal;
|
|||||||
|
|
||||||
namespace control {
|
namespace control {
|
||||||
PROTOBUF_CONSTEXPR Hello::Hello(
|
PROTOBUF_CONSTEXPR Hello::Hello(
|
||||||
::_pbi::ConstantInitialized): _impl_{
|
::_pbi::ConstantInitialized): _impl_{
|
||||||
/*decltype(_impl_.name_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}}
|
/*decltype(_impl_.name_)*/{&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}}
|
||||||
, /*decltype(_impl_.id_)*/0
|
, /*decltype(_impl_.id_)*/0
|
||||||
, /*decltype(_impl_._cached_size_)*/{}} {}
|
, /*decltype(_impl_._cached_size_)*/{}} {}
|
||||||
struct HelloDefaultTypeInternal {
|
struct HelloDefaultTypeInternal {
|
||||||
PROTOBUF_CONSTEXPR HelloDefaultTypeInternal()
|
PROTOBUF_CONSTEXPR HelloDefaultTypeInternal()
|
||||||
: _instance(::_pbi::ConstantInitialized{}) {}
|
: _instance(::_pbi::ConstantInitialized{}) {}
|
||||||
~HelloDefaultTypeInternal() {}
|
~HelloDefaultTypeInternal() {}
|
||||||
union {
|
union {
|
||||||
Hello _instance;
|
Hello _instance;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 HelloDefaultTypeInternal _Hello_default_instance_;
|
PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 HelloDefaultTypeInternal _Hello_default_instance_;
|
||||||
} // namespace control
|
} // namespace control
|
||||||
@@ -38,232 +38,235 @@ namespace control {
|
|||||||
// ===================================================================
|
// ===================================================================
|
||||||
|
|
||||||
class Hello::_Internal {
|
class Hello::_Internal {
|
||||||
public:
|
public:
|
||||||
};
|
};
|
||||||
|
|
||||||
Hello::Hello(::PROTOBUF_NAMESPACE_ID::Arena* arena,
|
Hello::Hello(::PROTOBUF_NAMESPACE_ID::Arena* arena,
|
||||||
bool is_message_owned)
|
bool is_message_owned)
|
||||||
: ::PROTOBUF_NAMESPACE_ID::MessageLite(arena, is_message_owned) {
|
: ::PROTOBUF_NAMESPACE_ID::MessageLite(arena, is_message_owned) {
|
||||||
SharedCtor(arena, is_message_owned);
|
SharedCtor(arena, is_message_owned);
|
||||||
// @@protoc_insertion_point(arena_constructor:control.Hello)
|
// @@protoc_insertion_point(arena_constructor:control.Hello)
|
||||||
}
|
}
|
||||||
Hello::Hello(const Hello& from)
|
Hello::Hello(const Hello& from)
|
||||||
: ::PROTOBUF_NAMESPACE_ID::MessageLite() {
|
: ::PROTOBUF_NAMESPACE_ID::MessageLite() {
|
||||||
Hello* const _this = this; (void)_this;
|
Hello* const _this = this;
|
||||||
new (&_impl_) Impl_{
|
(void)_this;
|
||||||
decltype(_impl_.name_){}
|
new (&_impl_) Impl_{
|
||||||
, decltype(_impl_.id_){}
|
decltype(_impl_.name_) {}
|
||||||
, /*decltype(_impl_._cached_size_)*/{}};
|
, decltype(_impl_.id_) {}
|
||||||
|
, /*decltype(_impl_._cached_size_)*/{}};
|
||||||
|
|
||||||
_internal_metadata_.MergeFrom<std::string>(from._internal_metadata_);
|
_internal_metadata_.MergeFrom<std::string>(from._internal_metadata_);
|
||||||
_impl_.name_.InitDefault();
|
_impl_.name_.InitDefault();
|
||||||
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
|
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
|
||||||
_impl_.name_.Set("", GetArenaForAllocation());
|
_impl_.name_.Set("", GetArenaForAllocation());
|
||||||
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
|
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
|
||||||
if (!from._internal_name().empty()) {
|
if (!from._internal_name().empty()) {
|
||||||
_this->_impl_.name_.Set(from._internal_name(),
|
_this->_impl_.name_.Set(from._internal_name(),
|
||||||
_this->GetArenaForAllocation());
|
_this->GetArenaForAllocation());
|
||||||
}
|
}
|
||||||
_this->_impl_.id_ = from._impl_.id_;
|
_this->_impl_.id_ = from._impl_.id_;
|
||||||
// @@protoc_insertion_point(copy_constructor:control.Hello)
|
// @@protoc_insertion_point(copy_constructor:control.Hello)
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void Hello::SharedCtor(
|
inline void Hello::SharedCtor(
|
||||||
::_pb::Arena* arena, bool is_message_owned) {
|
::_pb::Arena* arena, bool is_message_owned) {
|
||||||
(void)arena;
|
(void)arena;
|
||||||
(void)is_message_owned;
|
(void)is_message_owned;
|
||||||
new (&_impl_) Impl_{
|
new (&_impl_) Impl_{
|
||||||
decltype(_impl_.name_){}
|
decltype(_impl_.name_) {}
|
||||||
, decltype(_impl_.id_){0}
|
, decltype(_impl_.id_) {
|
||||||
, /*decltype(_impl_._cached_size_)*/{}
|
0
|
||||||
};
|
}
|
||||||
_impl_.name_.InitDefault();
|
, /*decltype(_impl_._cached_size_)*/{}
|
||||||
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
|
};
|
||||||
_impl_.name_.Set("", GetArenaForAllocation());
|
_impl_.name_.InitDefault();
|
||||||
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
|
#ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING
|
||||||
|
_impl_.name_.Set("", GetArenaForAllocation());
|
||||||
|
#endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING
|
||||||
}
|
}
|
||||||
|
|
||||||
Hello::~Hello() {
|
Hello::~Hello() {
|
||||||
// @@protoc_insertion_point(destructor:control.Hello)
|
// @@protoc_insertion_point(destructor:control.Hello)
|
||||||
if (auto *arena = _internal_metadata_.DeleteReturnArena<std::string>()) {
|
if (auto *arena = _internal_metadata_.DeleteReturnArena<std::string>()) {
|
||||||
(void)arena;
|
(void)arena;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
SharedDtor();
|
SharedDtor();
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void Hello::SharedDtor() {
|
inline void Hello::SharedDtor() {
|
||||||
GOOGLE_DCHECK(GetArenaForAllocation() == nullptr);
|
GOOGLE_DCHECK(GetArenaForAllocation() == nullptr);
|
||||||
_impl_.name_.Destroy();
|
_impl_.name_.Destroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Hello::SetCachedSize(int size) const {
|
void Hello::SetCachedSize(int size) const {
|
||||||
_impl_._cached_size_.Set(size);
|
_impl_._cached_size_.Set(size);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Hello::Clear() {
|
void Hello::Clear() {
|
||||||
// @@protoc_insertion_point(message_clear_start:control.Hello)
|
// @@protoc_insertion_point(message_clear_start:control.Hello)
|
||||||
uint32_t cached_has_bits = 0;
|
uint32_t cached_has_bits = 0;
|
||||||
// Prevent compiler warnings about cached_has_bits being unused
|
// Prevent compiler warnings about cached_has_bits being unused
|
||||||
(void) cached_has_bits;
|
(void) cached_has_bits;
|
||||||
|
|
||||||
_impl_.name_.ClearToEmpty();
|
_impl_.name_.ClearToEmpty();
|
||||||
_impl_.id_ = 0;
|
_impl_.id_ = 0;
|
||||||
_internal_metadata_.Clear<std::string>();
|
_internal_metadata_.Clear<std::string>();
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* Hello::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) {
|
const char* Hello::_InternalParse(const char* ptr, ::_pbi::ParseContext* ctx) {
|
||||||
#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure
|
#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure
|
||||||
while (!ctx->Done(&ptr)) {
|
while (!ctx->Done(&ptr)) {
|
||||||
uint32_t tag;
|
uint32_t tag;
|
||||||
ptr = ::_pbi::ReadTag(ptr, &tag);
|
ptr = ::_pbi::ReadTag(ptr, &tag);
|
||||||
switch (tag >> 3) {
|
switch (tag >> 3) {
|
||||||
// int32 id = 1;
|
// int32 id = 1;
|
||||||
case 1:
|
case 1:
|
||||||
if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 8)) {
|
if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 8)) {
|
||||||
_impl_.id_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint32(&ptr);
|
_impl_.id_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint32(&ptr);
|
||||||
CHK_(ptr);
|
CHK_(ptr);
|
||||||
} else
|
} else
|
||||||
goto handle_unusual;
|
goto handle_unusual;
|
||||||
continue;
|
continue;
|
||||||
// string name = 2;
|
// string name = 2;
|
||||||
case 2:
|
case 2:
|
||||||
if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 18)) {
|
if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 18)) {
|
||||||
auto str = _internal_mutable_name();
|
auto str = _internal_mutable_name();
|
||||||
ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx);
|
ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx);
|
||||||
CHK_(ptr);
|
CHK_(ptr);
|
||||||
CHK_(::_pbi::VerifyUTF8(str, nullptr));
|
CHK_(::_pbi::VerifyUTF8(str, nullptr));
|
||||||
} else
|
} else
|
||||||
goto handle_unusual;
|
goto handle_unusual;
|
||||||
continue;
|
continue;
|
||||||
default:
|
default:
|
||||||
goto handle_unusual;
|
goto handle_unusual;
|
||||||
} // switch
|
} // switch
|
||||||
handle_unusual:
|
handle_unusual:
|
||||||
if ((tag == 0) || ((tag & 7) == 4)) {
|
if ((tag == 0) || ((tag & 7) == 4)) {
|
||||||
CHK_(ptr);
|
CHK_(ptr);
|
||||||
ctx->SetLastTag(tag);
|
ctx->SetLastTag(tag);
|
||||||
goto message_done;
|
goto message_done;
|
||||||
}
|
}
|
||||||
ptr = UnknownFieldParse(
|
ptr = UnknownFieldParse(
|
||||||
tag,
|
tag,
|
||||||
_internal_metadata_.mutable_unknown_fields<std::string>(),
|
_internal_metadata_.mutable_unknown_fields<std::string>(),
|
||||||
ptr, ctx);
|
ptr, ctx);
|
||||||
CHK_(ptr != nullptr);
|
CHK_(ptr != nullptr);
|
||||||
} // while
|
} // while
|
||||||
message_done:
|
message_done:
|
||||||
return ptr;
|
return ptr;
|
||||||
failure:
|
failure:
|
||||||
ptr = nullptr;
|
ptr = nullptr;
|
||||||
goto message_done;
|
goto message_done;
|
||||||
#undef CHK_
|
#undef CHK_
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t* Hello::_InternalSerialize(
|
uint8_t* Hello::_InternalSerialize(
|
||||||
uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const {
|
uint8_t* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const {
|
||||||
// @@protoc_insertion_point(serialize_to_array_start:control.Hello)
|
// @@protoc_insertion_point(serialize_to_array_start:control.Hello)
|
||||||
uint32_t cached_has_bits = 0;
|
uint32_t cached_has_bits = 0;
|
||||||
(void) cached_has_bits;
|
(void) cached_has_bits;
|
||||||
|
|
||||||
// int32 id = 1;
|
// int32 id = 1;
|
||||||
if (this->_internal_id() != 0) {
|
if (this->_internal_id() != 0) {
|
||||||
target = stream->EnsureSpace(target);
|
target = stream->EnsureSpace(target);
|
||||||
target = ::_pbi::WireFormatLite::WriteInt32ToArray(1, this->_internal_id(), target);
|
target = ::_pbi::WireFormatLite::WriteInt32ToArray(1, this->_internal_id(), target);
|
||||||
}
|
}
|
||||||
|
|
||||||
// string name = 2;
|
// string name = 2;
|
||||||
if (!this->_internal_name().empty()) {
|
if (!this->_internal_name().empty()) {
|
||||||
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::VerifyUtf8String(
|
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::VerifyUtf8String(
|
||||||
this->_internal_name().data(), static_cast<int>(this->_internal_name().length()),
|
this->_internal_name().data(), static_cast<int>(this->_internal_name().length()),
|
||||||
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::SERIALIZE,
|
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::SERIALIZE,
|
||||||
"control.Hello.name");
|
"control.Hello.name");
|
||||||
target = stream->WriteStringMaybeAliased(
|
target = stream->WriteStringMaybeAliased(
|
||||||
2, this->_internal_name(), target);
|
2, this->_internal_name(), target);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) {
|
if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) {
|
||||||
target = stream->WriteRaw(_internal_metadata_.unknown_fields<std::string>(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).data(),
|
target = stream->WriteRaw(_internal_metadata_.unknown_fields<std::string>(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).data(),
|
||||||
static_cast<int>(_internal_metadata_.unknown_fields<std::string>(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).size()), target);
|
static_cast<int>(_internal_metadata_.unknown_fields<std::string>(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).size()), target);
|
||||||
}
|
}
|
||||||
// @@protoc_insertion_point(serialize_to_array_end:control.Hello)
|
// @@protoc_insertion_point(serialize_to_array_end:control.Hello)
|
||||||
return target;
|
return target;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t Hello::ByteSizeLong() const {
|
size_t Hello::ByteSizeLong() const {
|
||||||
// @@protoc_insertion_point(message_byte_size_start:control.Hello)
|
// @@protoc_insertion_point(message_byte_size_start:control.Hello)
|
||||||
size_t total_size = 0;
|
size_t total_size = 0;
|
||||||
|
|
||||||
uint32_t cached_has_bits = 0;
|
uint32_t cached_has_bits = 0;
|
||||||
// Prevent compiler warnings about cached_has_bits being unused
|
// Prevent compiler warnings about cached_has_bits being unused
|
||||||
(void) cached_has_bits;
|
(void) cached_has_bits;
|
||||||
|
|
||||||
// string name = 2;
|
// string name = 2;
|
||||||
if (!this->_internal_name().empty()) {
|
if (!this->_internal_name().empty()) {
|
||||||
total_size += 1 +
|
total_size += 1 +
|
||||||
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize(
|
::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize(
|
||||||
this->_internal_name());
|
this->_internal_name());
|
||||||
}
|
}
|
||||||
|
|
||||||
// int32 id = 1;
|
// int32 id = 1;
|
||||||
if (this->_internal_id() != 0) {
|
if (this->_internal_id() != 0) {
|
||||||
total_size += ::_pbi::WireFormatLite::Int32SizePlusOne(this->_internal_id());
|
total_size += ::_pbi::WireFormatLite::Int32SizePlusOne(this->_internal_id());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) {
|
if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) {
|
||||||
total_size += _internal_metadata_.unknown_fields<std::string>(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).size();
|
total_size += _internal_metadata_.unknown_fields<std::string>(::PROTOBUF_NAMESPACE_ID::internal::GetEmptyString).size();
|
||||||
}
|
}
|
||||||
int cached_size = ::_pbi::ToCachedSize(total_size);
|
int cached_size = ::_pbi::ToCachedSize(total_size);
|
||||||
SetCachedSize(cached_size);
|
SetCachedSize(cached_size);
|
||||||
return total_size;
|
return total_size;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Hello::CheckTypeAndMergeFrom(
|
void Hello::CheckTypeAndMergeFrom(
|
||||||
const ::PROTOBUF_NAMESPACE_ID::MessageLite& from) {
|
const ::PROTOBUF_NAMESPACE_ID::MessageLite& from) {
|
||||||
MergeFrom(*::_pbi::DownCast<const Hello*>(
|
MergeFrom(*::_pbi::DownCast<const Hello*>(
|
||||||
&from));
|
&from));
|
||||||
}
|
}
|
||||||
|
|
||||||
void Hello::MergeFrom(const Hello& from) {
|
void Hello::MergeFrom(const Hello& from) {
|
||||||
Hello* const _this = this;
|
Hello* const _this = this;
|
||||||
// @@protoc_insertion_point(class_specific_merge_from_start:control.Hello)
|
// @@protoc_insertion_point(class_specific_merge_from_start:control.Hello)
|
||||||
GOOGLE_DCHECK_NE(&from, _this);
|
GOOGLE_DCHECK_NE(&from, _this);
|
||||||
uint32_t cached_has_bits = 0;
|
uint32_t cached_has_bits = 0;
|
||||||
(void) cached_has_bits;
|
(void) cached_has_bits;
|
||||||
|
|
||||||
if (!from._internal_name().empty()) {
|
if (!from._internal_name().empty()) {
|
||||||
_this->_internal_set_name(from._internal_name());
|
_this->_internal_set_name(from._internal_name());
|
||||||
}
|
}
|
||||||
if (from._internal_id() != 0) {
|
if (from._internal_id() != 0) {
|
||||||
_this->_internal_set_id(from._internal_id());
|
_this->_internal_set_id(from._internal_id());
|
||||||
}
|
}
|
||||||
_this->_internal_metadata_.MergeFrom<std::string>(from._internal_metadata_);
|
_this->_internal_metadata_.MergeFrom<std::string>(from._internal_metadata_);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Hello::CopyFrom(const Hello& from) {
|
void Hello::CopyFrom(const Hello& from) {
|
||||||
// @@protoc_insertion_point(class_specific_copy_from_start:control.Hello)
|
// @@protoc_insertion_point(class_specific_copy_from_start:control.Hello)
|
||||||
if (&from == this) return;
|
if (&from == this) return;
|
||||||
Clear();
|
Clear();
|
||||||
MergeFrom(from);
|
MergeFrom(from);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Hello::IsInitialized() const {
|
bool Hello::IsInitialized() const {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Hello::InternalSwap(Hello* other) {
|
void Hello::InternalSwap(Hello* other) {
|
||||||
using std::swap;
|
using std::swap;
|
||||||
auto* lhs_arena = GetArenaForAllocation();
|
auto* lhs_arena = GetArenaForAllocation();
|
||||||
auto* rhs_arena = other->GetArenaForAllocation();
|
auto* rhs_arena = other->GetArenaForAllocation();
|
||||||
_internal_metadata_.InternalSwap(&other->_internal_metadata_);
|
_internal_metadata_.InternalSwap(&other->_internal_metadata_);
|
||||||
::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap(
|
::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap(
|
||||||
&_impl_.name_, lhs_arena,
|
&_impl_.name_, lhs_arena,
|
||||||
&other->_impl_.name_, rhs_arena
|
&other->_impl_.name_, rhs_arena
|
||||||
);
|
);
|
||||||
swap(_impl_.id_, other->_impl_.id_);
|
swap(_impl_.id_, other->_impl_.id_);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string Hello::GetTypeName() const {
|
std::string Hello::GetTypeName() const {
|
||||||
return "control.Hello";
|
return "control.Hello";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -272,7 +275,7 @@ std::string Hello::GetTypeName() const {
|
|||||||
PROTOBUF_NAMESPACE_OPEN
|
PROTOBUF_NAMESPACE_OPEN
|
||||||
template<> PROTOBUF_NOINLINE ::control::Hello*
|
template<> PROTOBUF_NOINLINE ::control::Hello*
|
||||||
Arena::CreateMaybeMessage< ::control::Hello >(Arena* arena) {
|
Arena::CreateMaybeMessage< ::control::Hello >(Arena* arena) {
|
||||||
return Arena::CreateMessageInternal< ::control::Hello >(arena);
|
return Arena::CreateMessageInternal< ::control::Hello >(arena);
|
||||||
}
|
}
|
||||||
PROTOBUF_NAMESPACE_CLOSE
|
PROTOBUF_NAMESPACE_CLOSE
|
||||||
|
|
||||||
|
|||||||
+43
-43
@@ -284,26 +284,26 @@ Interface::~Interface() {
|
|||||||
|
|
||||||
std::expected<void, std::string> Interface::UpN(void) {
|
std::expected<void, std::string> Interface::UpN(void) {
|
||||||
int netlinkfd = 0;
|
int netlinkfd = 0;
|
||||||
if ((netlinkfd = socket(AF_NETLINK, SOCK_RAW | SOCK_CLOEXEC, NETLINK_ROUTE)) < 0) {
|
if ((netlinkfd = socket(AF_NETLINK, SOCK_RAW | SOCK_CLOEXEC, NETLINK_ROUTE)) < 0) {
|
||||||
int errnocopy = errno;
|
int errnocopy = errno;
|
||||||
std::string error = std::strerror(errnocopy);
|
std::string error = std::strerror(errnocopy);
|
||||||
return std::unexpected("Create interface error: " + error);
|
return std::unexpected("Create interface error: " + error);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
struct nlmsghdr header;
|
struct nlmsghdr header;
|
||||||
struct ifinfomsg content;
|
struct ifinfomsg content;
|
||||||
} request;
|
} request;
|
||||||
|
|
||||||
memset(&request, 0, sizeof request);
|
memset(&request, 0, sizeof request);
|
||||||
request.header.nlmsg_len = NLMSG_LENGTH(sizeof request.content);
|
request.header.nlmsg_len = NLMSG_LENGTH(sizeof request.content);
|
||||||
request.header.nlmsg_flags = NLM_F_REQUEST;
|
request.header.nlmsg_flags = NLM_F_REQUEST;
|
||||||
request.header.nlmsg_type = RTM_NEWLINK;
|
request.header.nlmsg_type = RTM_NEWLINK;
|
||||||
request.content.ifi_index = if_nametoindex(ifname.c_str());
|
request.content.ifi_index = if_nametoindex(ifname.c_str());
|
||||||
request.content.ifi_flags = IFF_UP;
|
request.content.ifi_flags = IFF_UP;
|
||||||
request.content.ifi_change = 1;
|
request.content.ifi_change = 1;
|
||||||
|
|
||||||
if (send(netlinkfd, &request, request.header.nlmsg_len, 0) < 0) {
|
if (send(netlinkfd, &request, request.header.nlmsg_len, 0) < 0) {
|
||||||
close(netlinkfd);
|
close(netlinkfd);
|
||||||
int errnocopy = errno;
|
int errnocopy = errno;
|
||||||
std::string error = std::strerror(errnocopy);
|
std::string error = std::strerror(errnocopy);
|
||||||
@@ -316,7 +316,7 @@ std::expected<void, std::string> Interface::UpN(void) {
|
|||||||
|
|
||||||
std::expected<void, std::string> Interface::SetIP4AddrMask(const std::string address, const int prefix) {
|
std::expected<void, std::string> Interface::SetIP4AddrMask(const std::string address, const int prefix) {
|
||||||
int netlinkfd = 0;
|
int netlinkfd = 0;
|
||||||
if ((netlinkfd = socket(AF_NETLINK, SOCK_RAW | SOCK_CLOEXEC, NETLINK_ROUTE)) < 0) {
|
if ((netlinkfd = socket(AF_NETLINK, SOCK_RAW | SOCK_CLOEXEC, NETLINK_ROUTE)) < 0) {
|
||||||
int errnocopy = errno;
|
int errnocopy = errno;
|
||||||
std::string error = std::strerror(errnocopy);
|
std::string error = std::strerror(errnocopy);
|
||||||
return std::unexpected("Create interface error: " + error);
|
return std::unexpected("Create interface error: " + error);
|
||||||
@@ -324,46 +324,46 @@ std::expected<void, std::string> Interface::SetIP4AddrMask(const std::string add
|
|||||||
|
|
||||||
int rc = 0;
|
int rc = 0;
|
||||||
struct sockaddr_nl sockaddr;
|
struct sockaddr_nl sockaddr;
|
||||||
memset(&sockaddr, 0, sizeof sockaddr);
|
memset(&sockaddr, 0, sizeof sockaddr);
|
||||||
sockaddr.nl_family = AF_NETLINK;
|
sockaddr.nl_family = AF_NETLINK;
|
||||||
if ((rc = bind(netlinkfd, (struct sockaddr*) &sockaddr, sizeof sockaddr))< 0) {
|
if ((rc = bind(netlinkfd, (struct sockaddr*) &sockaddr, sizeof sockaddr))< 0) {
|
||||||
close(netlinkfd);
|
close(netlinkfd);
|
||||||
int errnocopy = errno;
|
int errnocopy = errno;
|
||||||
std::string error = std::strerror(errnocopy);
|
std::string error = std::strerror(errnocopy);
|
||||||
return std::unexpected("Set interface address error: " + error);
|
return std::unexpected("Set interface address error: " + error);
|
||||||
}
|
}
|
||||||
struct {
|
struct {
|
||||||
struct nlmsghdr header;
|
struct nlmsghdr header;
|
||||||
struct ifaddrmsg content;
|
struct ifaddrmsg content;
|
||||||
char attributes_buf[64];
|
char attributes_buf[64];
|
||||||
} request;
|
} request;
|
||||||
|
|
||||||
struct rtattr *request_attr;
|
struct rtattr *request_attr;
|
||||||
size_t attributes_buf_avail = sizeof request.attributes_buf;
|
size_t attributes_buf_avail = sizeof request.attributes_buf;
|
||||||
|
|
||||||
memset(&request, 0, sizeof request);
|
memset(&request, 0, sizeof request);
|
||||||
request.header.nlmsg_len = NLMSG_LENGTH(sizeof request.content);
|
request.header.nlmsg_len = NLMSG_LENGTH(sizeof request.content);
|
||||||
request.header.nlmsg_flags = NLM_F_REQUEST | NLM_F_EXCL | NLM_F_CREATE;
|
request.header.nlmsg_flags = NLM_F_REQUEST | NLM_F_EXCL | NLM_F_CREATE;
|
||||||
request.header.nlmsg_type = RTM_NEWADDR;
|
request.header.nlmsg_type = RTM_NEWADDR;
|
||||||
request.content.ifa_index = if_nametoindex(ifname.c_str());
|
request.content.ifa_index = if_nametoindex(ifname.c_str());
|
||||||
request.content.ifa_family = AF_INET;
|
request.content.ifa_family = AF_INET;
|
||||||
request.content.ifa_prefixlen = prefix;
|
request.content.ifa_prefixlen = prefix;
|
||||||
|
|
||||||
/* request.attributes[IFA_LOCAL] = address */
|
/* request.attributes[IFA_LOCAL] = address */
|
||||||
request_attr = IFA_RTA(&request.content);
|
request_attr = IFA_RTA(&request.content);
|
||||||
request_attr->rta_type = IFA_LOCAL;
|
request_attr->rta_type = IFA_LOCAL;
|
||||||
request_attr->rta_len = RTA_LENGTH(sizeof (struct in_addr));
|
request_attr->rta_len = RTA_LENGTH(sizeof (struct in_addr));
|
||||||
request.header.nlmsg_len += request_attr->rta_len;
|
request.header.nlmsg_len += request_attr->rta_len;
|
||||||
inet_pton(AF_INET, address.c_str(), RTA_DATA(request_attr));
|
inet_pton(AF_INET, address.c_str(), RTA_DATA(request_attr));
|
||||||
|
|
||||||
/* request.attributes[IFA_ADDRESS] = address */
|
/* request.attributes[IFA_ADDRESS] = address */
|
||||||
request_attr = RTA_NEXT(request_attr, attributes_buf_avail);
|
request_attr = RTA_NEXT(request_attr, attributes_buf_avail);
|
||||||
request_attr->rta_type = IFA_ADDRESS;
|
request_attr->rta_type = IFA_ADDRESS;
|
||||||
request_attr->rta_len = RTA_LENGTH(sizeof (struct in_addr));
|
request_attr->rta_len = RTA_LENGTH(sizeof (struct in_addr));
|
||||||
request.header.nlmsg_len += request_attr->rta_len;
|
request.header.nlmsg_len += request_attr->rta_len;
|
||||||
inet_pton(AF_INET, address.c_str(), RTA_DATA(request_attr));
|
inet_pton(AF_INET, address.c_str(), RTA_DATA(request_attr));
|
||||||
|
|
||||||
if (send(netlinkfd, &request, request.header.nlmsg_len, 0) < 0) {
|
if (send(netlinkfd, &request, request.header.nlmsg_len, 0) < 0) {
|
||||||
close(netlinkfd);
|
close(netlinkfd);
|
||||||
int errnocopy = errno;
|
int errnocopy = errno;
|
||||||
std::string error = std::strerror(errnocopy);
|
std::string error = std::strerror(errnocopy);
|
||||||
|
|||||||
+2
-2
@@ -3,11 +3,11 @@
|
|||||||
#define INTERFACE_HPP
|
#define INTERFACE_HPP
|
||||||
|
|
||||||
class Interface {
|
class Interface {
|
||||||
private:
|
private:
|
||||||
int tunfd;
|
int tunfd;
|
||||||
std::string ifname;
|
std::string ifname;
|
||||||
int mtu;
|
int mtu;
|
||||||
public:
|
public:
|
||||||
std::expected<void, std::string> Create(const std::string name);
|
std::expected<void, std::string> Create(const std::string name);
|
||||||
std::string Name();
|
std::string Name();
|
||||||
int MTU();
|
int MTU();
|
||||||
|
|||||||
+4
-4
@@ -3,18 +3,18 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
class Address {
|
class Address {
|
||||||
private:
|
private:
|
||||||
int family;
|
int family;
|
||||||
std::string address;
|
std::string address;
|
||||||
public:
|
public:
|
||||||
Address(const std::string iaddress, const int ifamily);
|
Address(const std::string iaddress, const int ifamily);
|
||||||
int GetFamily();
|
int GetFamily();
|
||||||
std::string GetAddress();
|
std::string GetAddress();
|
||||||
};
|
};
|
||||||
|
|
||||||
class Resolver {
|
class Resolver {
|
||||||
private:
|
private:
|
||||||
int family;
|
int family;
|
||||||
public:
|
public:
|
||||||
std::expected<Address, std::string> Resolve(const std::string hostname);
|
std::expected<Address, std::string> Resolve(const std::string hostname);
|
||||||
};
|
};
|
||||||
|
|||||||
+2
-2
@@ -8,8 +8,8 @@
|
|||||||
#include <service.hpp>
|
#include <service.hpp>
|
||||||
|
|
||||||
class Server {
|
class Server {
|
||||||
private:
|
private:
|
||||||
Interface iface;
|
Interface iface;
|
||||||
public:
|
public:
|
||||||
std::expected<void, std::string> Create(const std::string name, const std::string addr, const int prefix);
|
std::expected<void, std::string> Create(const std::string name, const std::string addr, const int prefix);
|
||||||
};
|
};
|
||||||
|
|||||||
+2
-2
@@ -31,7 +31,7 @@ Service::~Service() {
|
|||||||
close(port);
|
close(port);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::expected<void, std::string> Service::Bind(void){
|
std::expected<void, std::string> Service::Bind(void) {
|
||||||
struct sockaddr_in address;
|
struct sockaddr_in address;
|
||||||
int srvsock;
|
int srvsock;
|
||||||
if ((srvsock = socket(AF_INET, SOCK_STREAM, 0)) == 0) {
|
if ((srvsock = socket(AF_INET, SOCK_STREAM, 0)) == 0) {
|
||||||
@@ -62,7 +62,7 @@ std::expected<void, std::string> Service::Bind(void){
|
|||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
std::expected<void, std::string> Service::Listen(Handler *handler){
|
std::expected<void, std::string> Service::Listen(Handler *handler) {
|
||||||
struct sockaddr_in address;
|
struct sockaddr_in address;
|
||||||
int addrlen = sizeof(address);
|
int addrlen = sizeof(address);
|
||||||
int newsock = 0;
|
int newsock = 0;
|
||||||
|
|||||||
+3
-3
@@ -6,15 +6,15 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
class Handler {
|
class Handler {
|
||||||
public:
|
public:
|
||||||
void Handle(int sock);
|
void Handle(int sock);
|
||||||
};
|
};
|
||||||
|
|
||||||
class Service {
|
class Service {
|
||||||
private:
|
private:
|
||||||
int port;
|
int port;
|
||||||
int sock;
|
int sock;
|
||||||
public:
|
public:
|
||||||
explicit Service(int port);
|
explicit Service(int port);
|
||||||
std::expected<void, std::string> Bind(void);
|
std::expected<void, std::string> Bind(void);
|
||||||
std::expected<void, std::string> Listen(Handler *handler);
|
std::expected<void, std::string> Listen(Handler *handler);
|
||||||
|
|||||||
+3
-3
@@ -18,7 +18,7 @@ extern "C" {
|
|||||||
#include <udpclient.hpp>
|
#include <udpclient.hpp>
|
||||||
|
|
||||||
|
|
||||||
UDPClient::UDPClient(void){
|
UDPClient::UDPClient(void) {
|
||||||
sockfd = 0;
|
sockfd = 0;
|
||||||
rmax = 2024;
|
rmax = 2024;
|
||||||
};
|
};
|
||||||
@@ -53,7 +53,7 @@ std::expected<void, std::string> UDPClient::Send(std::string message) {
|
|||||||
servaddr.sin_addr.s_addr = inet_addr(address.c_str());
|
servaddr.sin_addr.s_addr = inet_addr(address.c_str());
|
||||||
|
|
||||||
if (sendto(sockfd, message.data(), message.size(), 0,
|
if (sendto(sockfd, message.data(), message.size(), 0,
|
||||||
(const struct sockaddr*)&servaddr, sizeof(servaddr)) < 0) {
|
(const struct sockaddr*)&servaddr, sizeof(servaddr)) < 0) {
|
||||||
int errnocopy = errno;
|
int errnocopy = errno;
|
||||||
std::string error = std::strerror(errnocopy);
|
std::string error = std::strerror(errnocopy);
|
||||||
return std::unexpected("Send datagram error: " + error);
|
return std::unexpected("Send datagram error: " + error);
|
||||||
@@ -72,7 +72,7 @@ std::expected<std::string, std::string> UDPClient::Recv() {
|
|||||||
int rsize = 0;
|
int rsize = 0;
|
||||||
std::string buffer(rmax, 0);
|
std::string buffer(rmax, 0);
|
||||||
if((rsize = recvfrom(sockfd, buffer.data(), buffer.size(),
|
if((rsize = recvfrom(sockfd, buffer.data(), buffer.size(),
|
||||||
0, (struct sockaddr *)&servaddr, &len)) < 0) {
|
0, (struct sockaddr *)&servaddr, &len)) < 0) {
|
||||||
int errnocopy = errno;
|
int errnocopy = errno;
|
||||||
std::string error = std::strerror(errnocopy);
|
std::string error = std::strerror(errnocopy);
|
||||||
return std::unexpected("Receive datagram error: " + error);
|
return std::unexpected("Receive datagram error: " + error);
|
||||||
|
|||||||
+2
-2
@@ -3,13 +3,13 @@
|
|||||||
#define UPDCLIENT_HPP
|
#define UPDCLIENT_HPP
|
||||||
|
|
||||||
class UDPClient {
|
class UDPClient {
|
||||||
private:
|
private:
|
||||||
int sockfd;
|
int sockfd;
|
||||||
std::string address;
|
std::string address;
|
||||||
int port;
|
int port;
|
||||||
int rmax;
|
int rmax;
|
||||||
int family;
|
int family;
|
||||||
public:
|
public:
|
||||||
UDPClient(void);
|
UDPClient(void);
|
||||||
std::expected<void, std::string> Bind(std::string address, int port);
|
std::expected<void, std::string> Bind(std::string address, int port);
|
||||||
std::expected<void, std::string> Send(std::string buffer);
|
std::expected<void, std::string> Send(std::string buffer);
|
||||||
|
|||||||
Reference in New Issue
Block a user