add handler logic to handle SysGetEthDevice
Add a handler to handle code logic outside of the actual IPMI
processing.
Tested: Only ran unit-tests (added new ones).
Change-Id: Iadd8c4f2d9b3e2cfba24ae32cda2ef66177b1177
Signed-off-by: Patrick Venture <venture@google.com>
diff --git a/handler.cpp b/handler.cpp
new file mode 100644
index 0000000..6a346ba
--- /dev/null
+++ b/handler.cpp
@@ -0,0 +1,48 @@
+/*
+ * Copyright 2019 Google Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "handler.hpp"
+
+// The phosphor-host-ipmi daemon requires a configuration that maps
+// the if_name to the IPMI LAN channel. However, that doesn't strictly
+// define which is meant to be used for NCSI.
+#ifndef NCSI_IPMI_CHANNEL
+#define NCSI_IPMI_CHANNEL 1
+#endif
+
+#ifndef NCSI_IF_NAME
+#define NCSI_IF_NAME eth0
+#endif
+
+// To deal with receiving a string without quotes.
+#define QUOTE(name) #name
+#define STR(macro) QUOTE(macro)
+#define NCSI_IF_NAME_STR STR(NCSI_IF_NAME)
+
+namespace google
+{
+namespace ipmi
+{
+
+std::tuple<std::uint8_t, std::string> Handler::getEthDetails() const
+{
+ return std::make_tuple(NCSI_IPMI_CHANNEL, NCSI_IF_NAME_STR);
+}
+
+Handler handlerImpl;
+
+} // namespace ipmi
+} // namespace google