xref: /openbmc/phosphor-host-ipmid/user_channel/channel_mgmt.hpp (revision 42f64efc1eb8d6c09fb55777da2e6b6305cda3db)
1071f3f2fSAppaRao Puli /*
2071f3f2fSAppaRao Puli // Copyright (c) 2018 Intel Corporation
3071f3f2fSAppaRao Puli //
4071f3f2fSAppaRao Puli // Licensed under the Apache License, Version 2.0 (the "License");
5071f3f2fSAppaRao Puli // you may not use this file except in compliance with the License.
6071f3f2fSAppaRao Puli // You may obtain a copy of the License at
7071f3f2fSAppaRao Puli //
8071f3f2fSAppaRao Puli //      http://www.apache.org/licenses/LICENSE-2.0
9071f3f2fSAppaRao Puli //
10071f3f2fSAppaRao Puli // Unless required by applicable law or agreed to in writing, software
11071f3f2fSAppaRao Puli // distributed under the License is distributed on an "AS IS" BASIS,
12071f3f2fSAppaRao Puli // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13071f3f2fSAppaRao Puli // See the License for the specific language governing permissions and
14071f3f2fSAppaRao Puli // limitations under the License.
15071f3f2fSAppaRao Puli */
16071f3f2fSAppaRao Puli 
17071f3f2fSAppaRao Puli #pragma once
18071f3f2fSAppaRao Puli #include "channel_layer.hpp"
19b541a5a5SNITIN SHARMA #include "ipmid/api-types.hpp"
20071f3f2fSAppaRao Puli 
21071f3f2fSAppaRao Puli #include <boost/interprocess/sync/file_lock.hpp>
22071f3f2fSAppaRao Puli #include <boost/interprocess/sync/named_recursive_mutex.hpp>
23071f3f2fSAppaRao Puli #include <nlohmann/json.hpp>
24071f3f2fSAppaRao Puli #include <sdbusplus/bus.hpp>
25*fbc6c9d7SPatrick Williams 
26*fbc6c9d7SPatrick Williams #include <cstdint>
27*fbc6c9d7SPatrick Williams #include <ctime>
2816b8693dSVernon Mauery #include <variant>
29071f3f2fSAppaRao Puli 
30071f3f2fSAppaRao Puli namespace ipmi
31071f3f2fSAppaRao Puli {
32071f3f2fSAppaRao Puli 
33071f3f2fSAppaRao Puli using Json = nlohmann::json;
34071f3f2fSAppaRao Puli 
3516b8693dSVernon Mauery using DbusVariant = std::variant<std::vector<std::string>, std::string, bool>;
369613ed76SAppaRao Puli 
379613ed76SAppaRao Puli using DbusChObjProperties = std::vector<std::pair<std::string, DbusVariant>>;
389613ed76SAppaRao Puli 
39071f3f2fSAppaRao Puli static constexpr const char* ipmiChannelMutex = "ipmi_channel_mutex";
40071f3f2fSAppaRao Puli static constexpr const char* ipmiChMutexCleanupLockFile =
41071f3f2fSAppaRao Puli     "/var/lib/ipmi/ipmi_channel_mutex_cleanup";
42071f3f2fSAppaRao Puli 
436e1ba9efSRichard Marian Thomaiyar /** @struct ChannelAccessData
446e1ba9efSRichard Marian Thomaiyar  *
456e1ba9efSRichard Marian Thomaiyar  *  Structure to store both non-volatile and volatile channel access information
466e1ba9efSRichard Marian Thomaiyar  *  as used by IPMI specification (refer spec sec 22.22 to 22.24)
476e1ba9efSRichard Marian Thomaiyar  */
48071f3f2fSAppaRao Puli struct ChannelAccessData
49071f3f2fSAppaRao Puli {
50071f3f2fSAppaRao Puli     ChannelAccess chNonVolatileData;
51071f3f2fSAppaRao Puli     ChannelAccess chVolatileData;
52071f3f2fSAppaRao Puli };
53071f3f2fSAppaRao Puli 
544c0435a2SJohnathan Mantey /** @struct ChannelProperties
556e1ba9efSRichard Marian Thomaiyar  *
566e1ba9efSRichard Marian Thomaiyar  *  Structure for channel information - base structure to get all information
576e1ba9efSRichard Marian Thomaiyar  * about the channel.(refer spec sec 22.22 to 22.24)
586e1ba9efSRichard Marian Thomaiyar  */
594c0435a2SJohnathan Mantey struct ChannelProperties
60071f3f2fSAppaRao Puli {
61071f3f2fSAppaRao Puli     std::string chName;
62071f3f2fSAppaRao Puli     uint8_t chID;
63071f3f2fSAppaRao Puli     bool isChValid;
64071f3f2fSAppaRao Puli     uint8_t activeSessCount;
65071f3f2fSAppaRao Puli     ChannelInfo chInfo;
66071f3f2fSAppaRao Puli     ChannelAccessData chAccess;
6758317120SVernon Mauery     size_t maxTransferSize;
68fd61fc3dSJohnathan Mantey     bool isManagementNIC;
69071f3f2fSAppaRao Puli };
70071f3f2fSAppaRao Puli 
71071f3f2fSAppaRao Puli class ChannelConfig;
72071f3f2fSAppaRao Puli 
73071f3f2fSAppaRao Puli ChannelConfig& getChannelConfigObject();
74071f3f2fSAppaRao Puli 
75071f3f2fSAppaRao Puli class ChannelConfig
76071f3f2fSAppaRao Puli {
77071f3f2fSAppaRao Puli   public:
78071f3f2fSAppaRao Puli     ChannelConfig(const ChannelConfig&) = delete;
79071f3f2fSAppaRao Puli     ChannelConfig& operator=(const ChannelConfig&) = delete;
80071f3f2fSAppaRao Puli     ChannelConfig(ChannelConfig&&) = delete;
81071f3f2fSAppaRao Puli     ChannelConfig& operator=(ChannelConfig&&) = delete;
82071f3f2fSAppaRao Puli 
839613ed76SAppaRao Puli     ~ChannelConfig();
84071f3f2fSAppaRao Puli     ChannelConfig();
85071f3f2fSAppaRao Puli 
86071f3f2fSAppaRao Puli     /** @brief determines valid channel
87071f3f2fSAppaRao Puli      *
88071f3f2fSAppaRao Puli      *  @param[in] chNum - channel number
89071f3f2fSAppaRao Puli      *
90071f3f2fSAppaRao Puli      *  @return true if valid, false otherwise
91071f3f2fSAppaRao Puli      */
92a45cb34fSRichard Marian Thomaiyar     bool isValidChannel(const uint8_t chNum);
93071f3f2fSAppaRao Puli 
94071f3f2fSAppaRao Puli     /** @brief determines valid authentication type
95071f3f2fSAppaRao Puli      *
96071f3f2fSAppaRao Puli      *  @param[in] chNum - channel number
97071f3f2fSAppaRao Puli      *  @param[in] authType - authentication type
98071f3f2fSAppaRao Puli      *
99071f3f2fSAppaRao Puli      *  @return true if valid, false otherwise
100071f3f2fSAppaRao Puli      */
101a45cb34fSRichard Marian Thomaiyar     bool isValidAuthType(const uint8_t chNum, const EAuthType& authType);
102071f3f2fSAppaRao Puli 
10373906b9cSRichard Marian Thomaiyar     /** @brief function to get channel name from channel number
10473906b9cSRichard Marian Thomaiyar      *
10573906b9cSRichard Marian Thomaiyar      *  @param[in] chNum - channel number index
10673906b9cSRichard Marian Thomaiyar      *
10773906b9cSRichard Marian Thomaiyar      *  @return network channel interface name
10873906b9cSRichard Marian Thomaiyar      */
10973906b9cSRichard Marian Thomaiyar     std::string getChannelName(const uint8_t chNum);
11073906b9cSRichard Marian Thomaiyar 
111735ee953SVernon Mauery     /** @brief function to get channel number from channel name
112735ee953SVernon Mauery      *
113735ee953SVernon Mauery      *  @param[in] chName - channel name
114735ee953SVernon Mauery      *
115735ee953SVernon Mauery      *  @return network channel interface number
116735ee953SVernon Mauery      */
117735ee953SVernon Mauery 
getChannelByName(const std::string & chName)118735ee953SVernon Mauery     uint8_t getChannelByName(const std::string& chName)
119735ee953SVernon Mauery     {
120735ee953SVernon Mauery         return convertToChannelNumberFromChannelName(chName);
121735ee953SVernon Mauery     }
122735ee953SVernon Mauery 
123071f3f2fSAppaRao Puli     /** @brief determines supported session type of a channel
124071f3f2fSAppaRao Puli      *
125071f3f2fSAppaRao Puli      *  @param[in] chNum - channel number
126071f3f2fSAppaRao Puli      *
127071f3f2fSAppaRao Puli      *  @return EChannelSessSupported - supported session type
128071f3f2fSAppaRao Puli      */
129a45cb34fSRichard Marian Thomaiyar     EChannelSessSupported getChannelSessionSupport(const uint8_t chNum);
130071f3f2fSAppaRao Puli 
131071f3f2fSAppaRao Puli     /** @brief determines number of active sessions on a channel
132071f3f2fSAppaRao Puli      *
133071f3f2fSAppaRao Puli      *  @param[in] chNum - channel number
134071f3f2fSAppaRao Puli      *
135071f3f2fSAppaRao Puli      *  @return numer of active sessions
136071f3f2fSAppaRao Puli      */
137a45cb34fSRichard Marian Thomaiyar     int getChannelActiveSessions(const uint8_t chNum);
138071f3f2fSAppaRao Puli 
13958317120SVernon Mauery     /** @brief determines maximum transfer size for a channel
14058317120SVernon Mauery      *
14158317120SVernon Mauery      *  @param[in] chNum - channel number
14258317120SVernon Mauery      *
14358317120SVernon Mauery      *  @return maximum bytes that can be transferred on this channel
14458317120SVernon Mauery      */
14558317120SVernon Mauery     size_t getChannelMaxTransferSize(uint8_t chNum);
14658317120SVernon Mauery 
147071f3f2fSAppaRao Puli     /** @brief provides channel info details
148071f3f2fSAppaRao Puli      *
149071f3f2fSAppaRao Puli      *  @param[in] chNum - channel number
150071f3f2fSAppaRao Puli      *  @param[out] chInfo - channel info details
151071f3f2fSAppaRao Puli      *
152b541a5a5SNITIN SHARMA      *  @return ccSuccess for success, others for failure.
153071f3f2fSAppaRao Puli      */
154b541a5a5SNITIN SHARMA     Cc getChannelInfo(const uint8_t chNum, ChannelInfo& chInfo);
155071f3f2fSAppaRao Puli 
156071f3f2fSAppaRao Puli     /** @brief provides channel access data
157071f3f2fSAppaRao Puli      *
158071f3f2fSAppaRao Puli      *  @param[in] chNum - channel number
159071f3f2fSAppaRao Puli      *  @param[out] chAccessData - channel access data
160071f3f2fSAppaRao Puli      *
161b541a5a5SNITIN SHARMA      *  @return ccSuccess for success, others for failure.
162071f3f2fSAppaRao Puli      */
163b541a5a5SNITIN SHARMA     Cc getChannelAccessData(const uint8_t chNum, ChannelAccess& chAccessData);
164071f3f2fSAppaRao Puli 
165071f3f2fSAppaRao Puli     /** @brief to set channel access data
166071f3f2fSAppaRao Puli      *
167071f3f2fSAppaRao Puli      *  @param[in] chNum - channel number
168071f3f2fSAppaRao Puli      *  @param[in] chAccessData - channel access data
169071f3f2fSAppaRao Puli      *  @param[in] setFlag - flag to indicate updatable fields
170071f3f2fSAppaRao Puli      *
171b541a5a5SNITIN SHARMA      *  @return ccSuccess for success, others for failure.
172071f3f2fSAppaRao Puli      */
173b541a5a5SNITIN SHARMA     Cc setChannelAccessData(const uint8_t chNum,
174071f3f2fSAppaRao Puli                             const ChannelAccess& chAccessData,
175a45cb34fSRichard Marian Thomaiyar                             const uint8_t setFlag);
176071f3f2fSAppaRao Puli 
177071f3f2fSAppaRao Puli     /** @brief to get channel access data persistent data
178071f3f2fSAppaRao Puli      *
179071f3f2fSAppaRao Puli      *  @param[in] chNum - channel number
180071f3f2fSAppaRao Puli      *  @param[out] chAccessData - channel access data
181071f3f2fSAppaRao Puli      *
182b541a5a5SNITIN SHARMA      *  @return ccSuccess for success, others for failure.
183071f3f2fSAppaRao Puli      */
184b541a5a5SNITIN SHARMA     Cc getChannelAccessPersistData(const uint8_t chNum,
185071f3f2fSAppaRao Puli                                    ChannelAccess& chAccessData);
186071f3f2fSAppaRao Puli 
187071f3f2fSAppaRao Puli     /** @brief to set channel access data persistent data
188071f3f2fSAppaRao Puli      *
189071f3f2fSAppaRao Puli      *  @param[in] chNum - channel number
190071f3f2fSAppaRao Puli      *  @param[in] chAccessData - channel access data
191071f3f2fSAppaRao Puli      *  @param[in] setFlag - flag to indicate updatable fields
192071f3f2fSAppaRao Puli      *
193b541a5a5SNITIN SHARMA      *  @return ccSuccess for success, others for failure.
194071f3f2fSAppaRao Puli      */
195b541a5a5SNITIN SHARMA     Cc setChannelAccessPersistData(const uint8_t chNum,
196071f3f2fSAppaRao Puli                                    const ChannelAccess& chAccessData,
197a45cb34fSRichard Marian Thomaiyar                                    const uint8_t setFlag);
198071f3f2fSAppaRao Puli 
199071f3f2fSAppaRao Puli     /** @brief provides supported authentication type for the channel
200071f3f2fSAppaRao Puli      *
201071f3f2fSAppaRao Puli      *  @param[in] chNum - channel number
202071f3f2fSAppaRao Puli      *  @param[out] authTypeSupported - supported authentication type
203071f3f2fSAppaRao Puli      *
204b541a5a5SNITIN SHARMA      *  @return ccSuccess for success, others for failure.
205071f3f2fSAppaRao Puli      */
206b541a5a5SNITIN SHARMA     Cc getChannelAuthTypeSupported(const uint8_t chNum,
207071f3f2fSAppaRao Puli                                    uint8_t& authTypeSupported);
208071f3f2fSAppaRao Puli 
209071f3f2fSAppaRao Puli     /** @brief provides enabled authentication type for the channel
210071f3f2fSAppaRao Puli      *
211071f3f2fSAppaRao Puli      *  @param[in] chNum - channel number
212071f3f2fSAppaRao Puli      *  @param[in] priv - privilege
213071f3f2fSAppaRao Puli      *  @param[out] authType - enabled authentication type
214071f3f2fSAppaRao Puli      *
215b541a5a5SNITIN SHARMA      *  @return ccSuccess for success, others for failure.
216071f3f2fSAppaRao Puli      */
217b541a5a5SNITIN SHARMA     Cc getChannelEnabledAuthType(const uint8_t chNum, const uint8_t priv,
218071f3f2fSAppaRao Puli                                  EAuthType& authType);
219071f3f2fSAppaRao Puli 
2209613ed76SAppaRao Puli     /** @brief conver to channel privilege from system privilege
2219613ed76SAppaRao Puli      *
2229613ed76SAppaRao Puli      *  @param[in] value - privilege value
2239613ed76SAppaRao Puli      *
2249613ed76SAppaRao Puli      *  @return Channel privilege
2259613ed76SAppaRao Puli      */
2269613ed76SAppaRao Puli     CommandPrivilege convertToPrivLimitIndex(const std::string& value);
2279613ed76SAppaRao Puli 
2289613ed76SAppaRao Puli     /** @brief function to write persistent channel configuration to config file
2299613ed76SAppaRao Puli      *
2309613ed76SAppaRao Puli      *  @return 0 for success, -errno for failure.
2319613ed76SAppaRao Puli      */
2329613ed76SAppaRao Puli     int writeChannelPersistData();
2339613ed76SAppaRao Puli 
2349613ed76SAppaRao Puli     /** @brief function to write volatile channel configuration to config file
2359613ed76SAppaRao Puli      *
2369613ed76SAppaRao Puli      *  @return 0 for success, -errno for failure.
2379613ed76SAppaRao Puli      */
2389613ed76SAppaRao Puli     int writeChannelVolatileData();
2399613ed76SAppaRao Puli 
240fd61fc3dSJohnathan Mantey     /** @brief Returns the IPMI channel ID authorized to push IPMI privilege
241fd61fc3dSJohnathan Mantey      * changes to phosphor-user-manager. Any channel access changes made on
242fd61fc3dSJohnathan Mantey      * any other channel are ignored.
243fd61fc3dSJohnathan Mantey      *
244fd61fc3dSJohnathan Mantey      *  @return IPMI channel ID as defined in channel_config.json
245fd61fc3dSJohnathan Mantey      */
246fd61fc3dSJohnathan Mantey     uint8_t getManagementNICID();
247fd61fc3dSJohnathan Mantey 
2482dfe7f8dSJohnathan Mantey   private:
2499613ed76SAppaRao Puli     uint32_t signalFlag = 0;
250071f3f2fSAppaRao Puli     std::unique_ptr<boost::interprocess::named_recursive_mutex> channelMutex{
251071f3f2fSAppaRao Puli         nullptr};
2524c0435a2SJohnathan Mantey     std::array<ChannelProperties, maxIpmiChannels> channelData;
253071f3f2fSAppaRao Puli     std::time_t nvFileLastUpdatedTime;
254071f3f2fSAppaRao Puli     std::time_t voltFileLastUpdatedTime;
255071f3f2fSAppaRao Puli     boost::interprocess::file_lock mutexCleanupLock;
2565d82f474SPatrick Williams     sdbusplus::bus_t bus;
2579613ed76SAppaRao Puli     bool signalHndlrObjectState = false;
2589613ed76SAppaRao Puli     boost::interprocess::file_lock sigHndlrLock;
259071f3f2fSAppaRao Puli 
260071f3f2fSAppaRao Puli     /** @brief function to initialize persistent channel configuration
261071f3f2fSAppaRao Puli      *
262071f3f2fSAppaRao Puli      */
263071f3f2fSAppaRao Puli     void initChannelPersistData();
264071f3f2fSAppaRao Puli 
265071f3f2fSAppaRao Puli     /** @brief function to set default channel configuration based on channel
266071f3f2fSAppaRao Puli      * number
267071f3f2fSAppaRao Puli      *
268071f3f2fSAppaRao Puli      *  @param[in] chNum - channel number
269071f3f2fSAppaRao Puli      *  @param[in] chName - channel name
270071f3f2fSAppaRao Puli      */
271a45cb34fSRichard Marian Thomaiyar     void setDefaultChannelConfig(const uint8_t chNum,
272071f3f2fSAppaRao Puli                                  const std::string& chName);
273071f3f2fSAppaRao Puli 
274071f3f2fSAppaRao Puli     /** @brief function to load all channel configuration
275071f3f2fSAppaRao Puli      *
276071f3f2fSAppaRao Puli      *  @return 0 for success, -errno for failure.
277071f3f2fSAppaRao Puli      */
278071f3f2fSAppaRao Puli     int loadChannelConfig();
279071f3f2fSAppaRao Puli 
280071f3f2fSAppaRao Puli     /** @brief function to read persistent channel data
281071f3f2fSAppaRao Puli      *
282071f3f2fSAppaRao Puli      *  @return 0 for success, -errno for failure.
283071f3f2fSAppaRao Puli      */
284071f3f2fSAppaRao Puli     int readChannelPersistData();
285071f3f2fSAppaRao Puli 
286071f3f2fSAppaRao Puli     /** @brief function to read volatile channel data
287071f3f2fSAppaRao Puli      *
288071f3f2fSAppaRao Puli      *  @return 0 for success, -errno for failure.
289071f3f2fSAppaRao Puli      */
290071f3f2fSAppaRao Puli     int readChannelVolatileData();
291071f3f2fSAppaRao Puli 
292071f3f2fSAppaRao Puli     /** @brief function to check and reload persistent channel data
293071f3f2fSAppaRao Puli      *
294071f3f2fSAppaRao Puli      *  @return 0 for success, -errno for failure.
295071f3f2fSAppaRao Puli      */
296071f3f2fSAppaRao Puli     int checkAndReloadNVData();
297071f3f2fSAppaRao Puli 
298071f3f2fSAppaRao Puli     /** @brief function to check and reload volatile channel data
299071f3f2fSAppaRao Puli      *
300071f3f2fSAppaRao Puli      *  @return 0 for success, -errno for failure.
301071f3f2fSAppaRao Puli      */
302071f3f2fSAppaRao Puli     int checkAndReloadVolatileData();
303071f3f2fSAppaRao Puli 
3049613ed76SAppaRao Puli     /** @brief function to sync channel privilege with system network channel
3059613ed76SAppaRao Puli      * privilege
3069613ed76SAppaRao Puli      *
3079613ed76SAppaRao Puli      *  @return 0 for success, -errno for failure.
3089613ed76SAppaRao Puli      */
3099613ed76SAppaRao Puli     int syncNetworkChannelConfig();
3109613ed76SAppaRao Puli 
3119613ed76SAppaRao Puli     /** @brief function to set D-Bus property value
3129613ed76SAppaRao Puli      *
3139613ed76SAppaRao Puli      *  @param[in] service - service name
3149613ed76SAppaRao Puli      *  @param[in] objPath - object path
3159613ed76SAppaRao Puli      *  @param[in] interface - interface
3169613ed76SAppaRao Puli      *  @param[in] property - property name
3179613ed76SAppaRao Puli      *  @param[in] value - property value
3189613ed76SAppaRao Puli      *
3199613ed76SAppaRao Puli      *  @return 0 for success, -errno for failure.
3209613ed76SAppaRao Puli      */
321f92261dcSJohnathan Mantey     int setDbusProperty(const std::string& service, const std::string& objPath,
3229613ed76SAppaRao Puli                         const std::string& interface,
3239613ed76SAppaRao Puli                         const std::string& property, const DbusVariant& value);
3249613ed76SAppaRao Puli 
325071f3f2fSAppaRao Puli     /** @brief function to read json config file
326071f3f2fSAppaRao Puli      *
327071f3f2fSAppaRao Puli      *  @param[in] configFile - configuration file name
328071f3f2fSAppaRao Puli      *
329071f3f2fSAppaRao Puli      *  @return Json object
330071f3f2fSAppaRao Puli      */
331071f3f2fSAppaRao Puli     Json readJsonFile(const std::string& configFile);
332071f3f2fSAppaRao Puli 
333071f3f2fSAppaRao Puli     /** @brief function to write json config file
334071f3f2fSAppaRao Puli      *
335071f3f2fSAppaRao Puli      *  @param[in] configFile - configuration file name
336071f3f2fSAppaRao Puli      *  @param[in] jsonData - json object
337071f3f2fSAppaRao Puli      *
338071f3f2fSAppaRao Puli      *  @return 0 for success, -errno for failure.
339071f3f2fSAppaRao Puli      */
340071f3f2fSAppaRao Puli     int writeJsonFile(const std::string& configFile, const Json& jsonData);
341071f3f2fSAppaRao Puli 
342071f3f2fSAppaRao Puli     /** @brief function to convert system access mode to Channel access mode
343071f3f2fSAppaRao Puli      * type
344071f3f2fSAppaRao Puli      *
345071f3f2fSAppaRao Puli      *  @param[in] mode - access mode in string
346071f3f2fSAppaRao Puli      *
347071f3f2fSAppaRao Puli      *  @return Channel access mode.
348071f3f2fSAppaRao Puli      */
349071f3f2fSAppaRao Puli     EChannelAccessMode convertToAccessModeIndex(const std::string& mode);
350071f3f2fSAppaRao Puli 
351071f3f2fSAppaRao Puli     /** @brief function to convert access mode value to string
352071f3f2fSAppaRao Puli      *
353071f3f2fSAppaRao Puli      *  @param[in] value - acess mode value
354071f3f2fSAppaRao Puli      *
355071f3f2fSAppaRao Puli      *  @return access mode in string
356071f3f2fSAppaRao Puli      */
357a45cb34fSRichard Marian Thomaiyar     std::string convertToAccessModeString(const uint8_t value);
358071f3f2fSAppaRao Puli 
359071f3f2fSAppaRao Puli     /** @brief function to convert privilege value to string
360071f3f2fSAppaRao Puli      *
361071f3f2fSAppaRao Puli      *  @param[in] value - privilege value
362071f3f2fSAppaRao Puli      *
363071f3f2fSAppaRao Puli      *  @return privilege in string
364071f3f2fSAppaRao Puli      */
365a45cb34fSRichard Marian Thomaiyar     std::string convertToPrivLimitString(const uint8_t value);
366071f3f2fSAppaRao Puli 
367071f3f2fSAppaRao Puli     /** @brief function to convert session support string to value type
368071f3f2fSAppaRao Puli      *
369071f3f2fSAppaRao Puli      *  @param[in] value - session support type in string
370071f3f2fSAppaRao Puli      *
371071f3f2fSAppaRao Puli      *  @return support session type
372071f3f2fSAppaRao Puli      */
373071f3f2fSAppaRao Puli     EChannelSessSupported
374071f3f2fSAppaRao Puli         convertToSessionSupportIndex(const std::string& value);
375071f3f2fSAppaRao Puli 
376071f3f2fSAppaRao Puli     /** @brief function to convert medium type string to value type
377071f3f2fSAppaRao Puli      *
378071f3f2fSAppaRao Puli      *  @param[in] value - medium type in string
379071f3f2fSAppaRao Puli      *
380071f3f2fSAppaRao Puli      *  @return channel medium type
381071f3f2fSAppaRao Puli      */
382071f3f2fSAppaRao Puli     EChannelMediumType convertToMediumTypeIndex(const std::string& value);
383071f3f2fSAppaRao Puli 
384071f3f2fSAppaRao Puli     /** @brief function to convert protocol type string to value type
385071f3f2fSAppaRao Puli      *
386071f3f2fSAppaRao Puli      *  @param[in] value - protocol type in string
387071f3f2fSAppaRao Puli      *
388071f3f2fSAppaRao Puli      *  @return channel protocol  type
389071f3f2fSAppaRao Puli      */
390071f3f2fSAppaRao Puli     EChannelProtocolType convertToProtocolTypeIndex(const std::string& value);
391e5c4f1d7SJohnathan Mantey 
39274a2102eSJohnathan Mantey     /** @brief function to convert channel name to the IPMI channel number.
393e5c4f1d7SJohnathan Mantey      *
39474a2102eSJohnathan Mantey      *  @param[in] chName - the channel name defined in the JSON input file
39574a2102eSJohnathan Mantey      *  (i.e. LAN1)
396e5c4f1d7SJohnathan Mantey      *
39774a2102eSJohnathan Mantey      *  @return IPMI channel number
398e5c4f1d7SJohnathan Mantey      */
39974a2102eSJohnathan Mantey     int convertToChannelNumberFromChannelName(const std::string& chName);
400e5c4f1d7SJohnathan Mantey 
401e5c4f1d7SJohnathan Mantey     /** @brief function to handle Channel access property update through the
402e5c4f1d7SJohnathan Mantey      * D-Bus handler.
403e5c4f1d7SJohnathan Mantey      *
404e5c4f1d7SJohnathan Mantey      *  @param[in] path - D-Bus path to the network element (i.e. eth0)
405e5c4f1d7SJohnathan Mantey      *  @param[in] chProperties - D-Bus channel properties
406e5c4f1d7SJohnathan Mantey      */
407e5c4f1d7SJohnathan Mantey     void processChAccessPropChange(const std::string& path,
408e5c4f1d7SJohnathan Mantey                                    const DbusChObjProperties& chProperties);
4092dfe7f8dSJohnathan Mantey 
4102dfe7f8dSJohnathan Mantey     /** @brief function to retrieve last modification time for the named file
4112dfe7f8dSJohnathan Mantey      *
4122dfe7f8dSJohnathan Mantey      *  @param[in] fileName - the name of the file for which to acquire
4132dfe7f8dSJohnathan Mantey      *  timestamp data
4142dfe7f8dSJohnathan Mantey      *
4152dfe7f8dSJohnathan Mantey      *  @return time the file was last modified
4162dfe7f8dSJohnathan Mantey      */
4172dfe7f8dSJohnathan Mantey     std::time_t getUpdatedFileTime(const std::string& fileName);
41874a2102eSJohnathan Mantey 
41974a2102eSJohnathan Mantey     /** @brief function to convert the DBus path to a network channel name
42074a2102eSJohnathan Mantey      *
42174a2102eSJohnathan Mantey      *  @param[in] path - The DBus path to the device
42274a2102eSJohnathan Mantey      *
42374a2102eSJohnathan Mantey      *  @return network channel name (i.e. eth0)
42474a2102eSJohnathan Mantey      */
42574a2102eSJohnathan Mantey     std::string getChannelNameFromPath(const std::string& path);
426071f3f2fSAppaRao Puli };
427071f3f2fSAppaRao Puli 
428071f3f2fSAppaRao Puli } // namespace ipmi
429