summaryrefslogtreecommitdiff
path: root/src/api/cifs_pc_to_net.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/api/cifs_pc_to_net.h')
-rw-r--r--src/api/cifs_pc_to_net.h45
1 files changed, 44 insertions, 1 deletions
diff --git a/src/api/cifs_pc_to_net.h b/src/api/cifs_pc_to_net.h
index 5b9ef6b..2587bd2 100644
--- a/src/api/cifs_pc_to_net.h
+++ b/src/api/cifs_pc_to_net.h
@@ -51,11 +51,24 @@ namespace SMBv2
template<class T>
constexpr T pc_to_net(T t)
{
- static_assert(t == 0, "try to not use pc_to_net w/o specialization");
+ static_assert(t == T{}, "try to not use pc_to_net w/o specialization");
return t;
}
template<>
+constexpr std::uint64_t pc_to_net(std::uint64_t t)
+{
+ return ((t & 0xFF00000000000000) >> 56)
+ | ((t & 0x00FF000000000000) >> 40)
+ | ((t & 0x0000FF0000000000) >> 24)
+ | ((t & 0x000000FF00000000) >> 8)
+ | ((t & 0x00000000FF000000) << 8)
+ | ((t & 0x0000000000FF0000) << 24)
+ | ((t & 0x000000000000FF00) << 40)
+ | ((t & 0x00000000000000FF) << 56);
+}
+
+template<>
constexpr uint32_t pc_to_net(uint32_t t)
{
return ((t & 0xFF000000) >> 24)
@@ -71,6 +84,36 @@ constexpr uint16_t pc_to_net(uint16_t t)
| ((t & 0x00FF) << 8);
}
+template<>
+constexpr std::uint8_t pc_to_net(std::uint8_t v)
+{
+ return v;
+}
+
+template<>
+constexpr std::int64_t pc_to_net(std::int64_t v)
+{
+ return pc_to_net((std::uint64_t)v);
+}
+
+template<>
+constexpr std::int32_t pc_to_net(std::int32_t v)
+{
+ return pc_to_net((std::uint32_t)v);
+}
+
+template<>
+constexpr std::int16_t pc_to_net(std::int16_t v)
+{
+ return pc_to_net((std::uint16_t)v);
+}
+
+template<>
+constexpr std::int8_t pc_to_net(std::int8_t v)
+{
+ return pc_to_net((std::uint8_t)v);
+}
+
# else
# if NFSTRACE_BYTE_ORDER == NFSTRACE_LITTLE_ENDIAN