Lines Matching refs:code

27 static bool CheckOptSoverloaded(const struct DhcpPacket *packet, int code, int maxLen, int *over, int *index)
36 DHCP_LOGW("CheckOptSoverloaded code:%{public}d,*index:%{public}d more than max bytes:%{public}d!",
37 code, *index, maxLen);
45 /* Check packet options based on the code and index. */
46 static int CheckOptionsData(const struct DhcpPacket *packet, int code, int index, int maxLen)
54 DHCP_LOGW("CheckOptionsData code:%{public}d,index:%{public}d more than max bytes:%{public}d!",
55 code, index, maxLen);
60 if (pOption[index + DHCP_OPT_CODE_INDEX] != code) {
65 DHCP_LOGW("CheckOptionsData failed, options data too long, code:%{public}d,index:%{public}d!", code, index);
72 /* Obtains the data type based on the code. */
73 static uint8_t GetDhcpOptionCodeType(const uint8_t code)
75 if ((code <= PAD_OPTION) || (code >= END_OPTION)) {
76 DHCP_LOGE("GetDhcpOptionCodeType error, code:%{public}d is error!", code);
81 switch (code) {
110 DHCP_LOGE("GetDhcpOptionCodeType failed, code:%{public}d is invalid!", code);
117 /* Obtains the data length based on the code. */
118 uint8_t GetDhcpOptionDataLen(const uint8_t code)
120 uint8_t nDataType = GetDhcpOptionCodeType(code);
122 DHCP_LOGE("GetDhcpOptionDataLen code:%{public}d error, GetDhcpOptionCodeType invalid!", code);
144 DHCP_LOGE("GetDhcpOptionDataLen code:%{public}d failed, nDataType:%{public}d is invalid!",
145 code, nDataType);
152 /* Obtains the data pointer and length from the packet based on the code. */
153 const uint8_t *GetDhcpOption(const struct DhcpPacket *packet, int code, size_t *length)
164 int nRet = CheckOptionsData(packet, code, nIndex, maxLen);
177 if (!CheckOptSoverloaded(packet, code, maxLen, &nOver, &nIndex)) {
201 DHCP_LOGW("GetDhcpOption options no find code:%{public}d, nIndex:%{public}d!", code, nIndex);
205 /* Obtains the uint8 data from the packet based on the code. */
206 bool GetDhcpOptionUint8(const struct DhcpPacket *packet, int code, uint8_t *data)
209 const uint8_t *p = GetDhcpOption(packet, code, &len);
211 DHCP_LOGW("GetDhcpOptionUint8 GetDhcpOption nullptr, code:%{public}d!", code);
215 DHCP_LOGE("GetDhcpOptionUint8 failed, len:%{public}zu less data:%{public}zu, code:%{public}d!",
216 len, sizeof(uint8_t), code);
225 /* Obtains the uint32 data from the packet based on the code. */
226 bool GetDhcpOptionUint32(const struct DhcpPacket *packet, int code, uint32_t *data)
229 const uint8_t *p = GetDhcpOption(packet, code, &len);
231 DHCP_LOGW("GetDhcpOptionUint32 GetDhcpOption nullptr, code:%{public}d!", code);
236 DHCP_LOGE("GetDhcpOptionUint32 failed, len:%{public}zu less uData:%{public}zu, code:%{public}d!",
237 len, sizeof(uData), code);
249 /* Obtains the uint32n data from the packet based on the code. */
250 bool GetDhcpOptionUint32n(const struct DhcpPacket *packet, int code, uint32_t *data1, uint32_t *data2)
253 const uint8_t *p = GetDhcpOption(packet, code, &len);
255 DHCP_LOGW("GetDhcpOptionUint32n GetDhcpOption nullptr, code:%{public}d!", code);
260 DHCP_LOGE("GetDhcpOptionUint32n failed, len:%{public}zu is not %{public}zu * n, code:%{public}d!",
261 len, sizeof(uData), code);
283 /* Obtains the string data from the packet based on the code. */
284 char *GetDhcpOptionString(const struct DhcpPacket *packet, int code)
287 const uint8_t *p = GetDhcpOption(packet, code, &len);
289 DHCP_LOGW("GetDhcpOptionString GetDhcpOption nullptr, code:%{public}d!", code);
293 DHCP_LOGE("GetDhcpOptionString failed, len:%{public}zu less data:%{public}zu, code:%{public}d!",
294 len, sizeof(uint8_t), code);
329 DHCP_LOGE("AddOptStrToOpts() code:%{public}u nOptLen:%{public}d no equal optStrLen:%{public}d!",
336 DHCP_LOGE("AddOptStrToOpts() code:%{public}u did not fit into the packet!", pOpt[DHCP_OPT_CODE_INDEX]);
340 DHCP_LOGD("AddOptStrToOpts() adding option code %{public}u.", pOpt[DHCP_OPT_CODE_INDEX]);
349 int AddOptValueToOpts(uint8_t *pOpts, uint8_t code, uint32_t value)
351 uint8_t uLen = GetDhcpOptionDataLen(code);
353 DHCP_LOGE("AddOptValueToOpts() code:%{public}d failed, GetDhcpOptionDataLen uLen:0!", code);
377 uOption[DHCP_OPT_CODE_INDEX] = code;