blob: 59fd9f9249ee377faee70d870bd3df0988550171 [file] [log] [blame]
Patrick Ventured26fff42018-09-18 15:37:59 -07001/*
2 * Copyright 2018 Google Inc.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#include "config.h"
18
19#include "ethstats.hpp"
20
Patrick Venture08f879c2019-03-18 10:51:42 -070021#include <cstdio>
William A. Kennington III539f03f2019-02-12 13:28:45 -080022#include <ipmid/iana.hpp>
23#include <ipmid/oemopenbmc.hpp>
24#include <ipmid/oemrouter.hpp>
Patrick Ventured26fff42018-09-18 15:37:59 -070025
26void setupGlobalOemEthStats() __attribute__((constructor));
27
28void setupGlobalOemEthStats()
29{
30 oem::Router* oemRouter = oem::mutableRouter();
31
Patrick Ventured72f8b52019-03-07 16:54:57 -080032#if ENABLE_GOOGLE
Patrick Ventured26fff42018-09-18 15:37:59 -070033 /* Install in Google OEM Namespace when enabled. */
34 std::fprintf(stderr,
35 "Registering OEM:[%#08X], Cmd:[%#04X] for Ethstats Commands\n",
Patrick Ventureddee9d02018-11-15 14:50:52 -080036 oem::googOemNumber, oem::Cmd::ethStatsCmd);
Patrick Ventured26fff42018-09-18 15:37:59 -070037
Patrick Ventureddee9d02018-11-15 14:50:52 -080038 oemRouter->registerHandler(oem::googOemNumber, oem::Cmd::ethStatsCmd,
Patrick Venture08f879c2019-03-18 10:51:42 -070039 ethstats::handleEthStatCommand);
Patrick Ventured26fff42018-09-18 15:37:59 -070040#endif
41
42 std::fprintf(stderr,
43 "Registering OEM:[%#08X], Cmd:[%#04X] for Ethstats Commands\n",
Patrick Ventureddee9d02018-11-15 14:50:52 -080044 oem::obmcOemNumber, oem::Cmd::ethStatsCmd);
Patrick Ventured26fff42018-09-18 15:37:59 -070045
Patrick Ventureddee9d02018-11-15 14:50:52 -080046 oemRouter->registerHandler(oem::obmcOemNumber, oem::Cmd::ethStatsCmd,
Patrick Venture08f879c2019-03-18 10:51:42 -070047 ethstats::handleEthStatCommand);
Patrick Ventured26fff42018-09-18 15:37:59 -070048}