Patrick Venture | d26fff4 | 2018-09-18 15:37:59 -0700 | [diff] [blame] | 1 | /* |
| 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 Venture | 08f879c | 2019-03-18 10:51:42 -0700 | [diff] [blame^] | 21 | #include <cstdio> |
William A. Kennington III | 539f03f | 2019-02-12 13:28:45 -0800 | [diff] [blame] | 22 | #include <ipmid/iana.hpp> |
| 23 | #include <ipmid/oemopenbmc.hpp> |
| 24 | #include <ipmid/oemrouter.hpp> |
Patrick Venture | d26fff4 | 2018-09-18 15:37:59 -0700 | [diff] [blame] | 25 | |
| 26 | void setupGlobalOemEthStats() __attribute__((constructor)); |
| 27 | |
| 28 | void setupGlobalOemEthStats() |
| 29 | { |
| 30 | oem::Router* oemRouter = oem::mutableRouter(); |
| 31 | |
Patrick Venture | d72f8b5 | 2019-03-07 16:54:57 -0800 | [diff] [blame] | 32 | #if ENABLE_GOOGLE |
Patrick Venture | d26fff4 | 2018-09-18 15:37:59 -0700 | [diff] [blame] | 33 | /* Install in Google OEM Namespace when enabled. */ |
| 34 | std::fprintf(stderr, |
| 35 | "Registering OEM:[%#08X], Cmd:[%#04X] for Ethstats Commands\n", |
Patrick Venture | ddee9d0 | 2018-11-15 14:50:52 -0800 | [diff] [blame] | 36 | oem::googOemNumber, oem::Cmd::ethStatsCmd); |
Patrick Venture | d26fff4 | 2018-09-18 15:37:59 -0700 | [diff] [blame] | 37 | |
Patrick Venture | ddee9d0 | 2018-11-15 14:50:52 -0800 | [diff] [blame] | 38 | oemRouter->registerHandler(oem::googOemNumber, oem::Cmd::ethStatsCmd, |
Patrick Venture | 08f879c | 2019-03-18 10:51:42 -0700 | [diff] [blame^] | 39 | ethstats::handleEthStatCommand); |
Patrick Venture | d26fff4 | 2018-09-18 15:37:59 -0700 | [diff] [blame] | 40 | #endif |
| 41 | |
| 42 | std::fprintf(stderr, |
| 43 | "Registering OEM:[%#08X], Cmd:[%#04X] for Ethstats Commands\n", |
Patrick Venture | ddee9d0 | 2018-11-15 14:50:52 -0800 | [diff] [blame] | 44 | oem::obmcOemNumber, oem::Cmd::ethStatsCmd); |
Patrick Venture | d26fff4 | 2018-09-18 15:37:59 -0700 | [diff] [blame] | 45 | |
Patrick Venture | ddee9d0 | 2018-11-15 14:50:52 -0800 | [diff] [blame] | 46 | oemRouter->registerHandler(oem::obmcOemNumber, oem::Cmd::ethStatsCmd, |
Patrick Venture | 08f879c | 2019-03-18 10:51:42 -0700 | [diff] [blame^] | 47 | ethstats::handleEthStatCommand); |
Patrick Venture | d26fff4 | 2018-09-18 15:37:59 -0700 | [diff] [blame] | 48 | } |