rndis_debug.c
Go to the documentation of this file.
1 /**
2  * @file rndis_debug.c
3  * @brief RNDIS (Remote Network Driver Interface Specification)
4  *
5  * @section License
6  *
7  * SPDX-License-Identifier: GPL-2.0-or-later
8  *
9  * Copyright (C) 2010-2024 Oryx Embedded SARL. All rights reserved.
10  *
11  * This file is part of CycloneTCP Open.
12  *
13  * This program is free software; you can redistribute it and/or
14  * modify it under the terms of the GNU General Public License
15  * as published by the Free Software Foundation; either version 2
16  * of the License, or (at your option) any later version.
17  *
18  * This program is distributed in the hope that it will be useful,
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21  * GNU General Public License for more details.
22  *
23  * You should have received a copy of the GNU General Public License
24  * along with this program; if not, write to the Free Software Foundation,
25  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
26  *
27  * @author Oryx Embedded SARL (www.oryx-embedded.com)
28  * @version 2.4.4
29  **/
30 
31 //Switch to the appropriate trace level
32 #define TRACE_LEVEL TRACE_LEVEL_INFO
33 
34 //Dependencies
35 #include "os_port.h"
36 #include "rndis_debug.h"
37 #include "debug.h"
38 
39 //Debug macros
40 #if (TRACE_LEVEL >= TRACE_LEVEL_DEBUG)
41  #undef TRACE_DEBUG
42  #define TRACE_DEBUG(...) fprintf(stderr, __VA_ARGS__)
43  #undef TRACE_DEBUG_ARRAY
44  #define TRACE_DEBUG_ARRAY(p, a, n) debugDisplayArray(stderr, p, a, n)
45 #endif
46 
47 //RNDIS messages
49 {
50  {0x00000001, "REMOTE_NDIS_PACKET_MSG"},
51  {0x00000002, "REMOTE_NDIS_INITIALIZE_MSG"},
52  {0x80000002, "REMOTE_NDIS_INITIALIZE_CMPLT"},
53  {0x00000003, "REMOTE_NDIS_HALT_MSG"},
54  {0x00000004, "REMOTE_NDIS_QUERY_MSG"},
55  {0x80000004, "REMOTE_NDIS_QUERY_CMPLT"},
56  {0x00000005, "REMOTE_NDIS_SET_MSG"},
57  {0x80000005, "REMOTE_NDIS_SET_CMPLT"},
58  {0x00000006, "REMOTE_NDIS_RESET_MSG"},
59  {0x80000006, "REMOTE_NDIS_RESET_CMPLT"},
60  {0x00000007, "REMOTE_NDIS_INDICATE_STATUS_MSG"},
61  {0x00000008, "REMOTE_NDIS_KEEPALIVE_CMPLT"},
62  {0x80000008, "REMOTE_NDIS_KEEPALIVE_CMPLT"}
63 };
64 
65 //Status codes
67 {
68  {0x00000000, "RNDIS_STATUS_SUCCESS"},
69  {0xC0000001, "RNDIS_STATUS_FAILURE"},
70  {0xC0010015, "RNDIS_STATUS_INVALID_DATA"},
71  {0xC00000BB, "RNDIS_STATUS_NOT_SUPPORTED"},
72  {0x4001000B, "RNDIS_STATUS_MEDIA_CONNECT"},
73  {0x4001000C, "RNDIS_STATUS_MEDIA_DISCONNECT"}
74 };
75 
76 //Object identifiers
78 {
79  //General objects
80  {0x00010101, "OID_GEN_SUPPORTED_LIST"},
81  {0x00010102, "OID_GEN_HARDWARE_STATUS"},
82  {0x00010103, "OID_GEN_MEDIA_SUPPORTED"},
83  {0x00010104, "OID_GEN_MEDIA_IN_USE"},
84  {0x00010105, "OID_GEN_MAXIMUM_LOOKAHEAD"},
85  {0x00010106, "OID_GEN_MAXIMUM_FRAME_SIZE"},
86  {0x00010107, "OID_GEN_LINK_SPEED"},
87  {0x00010108, "OID_GEN_TRANSMIT_BUFFER_SPACE"},
88  {0x00010109, "OID_GEN_RECEIVE_BUFFER_SPACE"},
89  {0x0001010A, "OID_GEN_TRANSMIT_BLOCK_SIZE"},
90  {0x0001010B, "OID_GEN_RECEIVE_BLOCK_SIZE"},
91  {0x0001010C, "OID_GEN_VENDOR_ID"},
92  {0x0001010D, "OID_GEN_VENDOR_DESCRIPTION"},
93  {0x0001010E, "OID_GEN_CURRENT_PACKET_FILTER"},
94  {0x0001010F, "OID_GEN_CURRENT_LOOKAHEAD"},
95  {0x00010110, "OID_GEN_DRIVER_VERSION"},
96  {0x00010111, "OID_GEN_MAXIMUM_TOTAL_SIZE"},
97  {0x00010112, "OID_GEN_PROTOCOL_OPTIONS"},
98  {0x00010113, "OID_GEN_MAC_OPTIONS"},
99  {0x00010114, "OID_GEN_MEDIA_CONNECT_STATUS"},
100  {0x00010115, "OID_GEN_MAXIMUM_SEND_PACKETS"},
101  {0x00010116, "OID_GEN_VENDOR_DRIVER_VERSION"},
102  {0x00010117, "OID_GEN_SUPPORTED_GUIDS"},
103  {0x00010118, "OID_GEN_NETWORK_LAYER_ADDRESSES"},
104  {0x00010119, "OID_GEN_TRANSPORT_HEADER_OFFSET"},
105  {0x0001021A, "OID_GEN_MACHINE_NAME"},
106  {0x0001021B, "OID_GEN_RNDIS_CONFIG_PARAMETER"},
107  {0x0001021C, "OID_GEN_VLAN_ID"},
108  //Ethernet objects
109  {0x01010101, "OID_802_3_PERMANENT_ADDRESS"},
110  {0x01010102, "OID_802_3_CURRENT_ADDRESS"},
111  {0x01010103, "OID_802_3_MULTICAST_LIST"},
112  {0x01010104, "OID_802_3_MAXIMUM_LIST_SIZE"},
113  {0x01010105, "OID_802_3_MAC_OPTIONS"},
114 };
115 
116 
117 /**
118  * @brief Dump RNDIS message for debugging purpose
119  * @param[in] message Pointer to the RNDIS message
120  * @param[in] length Length of the message, in bytes
121  * @return Error code
122  **/
123 
125 {
126 //Check current trace level
127 #if (TRACE_LEVEL >= TRACE_LEVEL_DEBUG)
128  error_t error;
129  const char_t *label;
130 
131  //Check the length of the message
132  if(length < sizeof(RndisMsg))
133  return ERROR_INVALID_LENGTH;
134 
135  //Retrieve the name of the RNDIS message
136  label = rndisFindName(message->messageType,
138 
139  //Dump RNDIS message
140  TRACE_DEBUG(" MessageType = 0x%08" PRIX32 " (%s)\r\n", message->messageType, label);
141  TRACE_DEBUG(" MessageLength = %" PRIu32 "\r\n", message->messageLength);
142 
143  //Check message type
144  switch(message->messageType)
145  {
146  //RNDIS Packet message?
147  case RNDIS_PACKET_MSG:
149  break;
150  //RNDIS Initialize message?
153  break;
154  //RNDIS Halt message?
155  case RNDIS_HALT_MSG:
157  break;
158  //RNDIS Query message?
159  case RNDIS_QUERY_MSG:
161  break;
162  //RNDIS Set message?
163  case RNDIS_SET_MSG:
165  break;
166  //RNDIS Reset message?
167  case RNDIS_RESET_MSG:
169  break;
170  //RNDIS Indicate Status message?
173  break;
174  //RNDIS Keep-Alive message?
175  case RNDIS_KEEPALIVE_MSG:
177  break;
178  //RNDIS Initialize Cmplt message?
181  break;
182  //RNDIS Query Cmplt message?
183  case RNDIS_QUERY_CMPLT:
185  break;
186  //RNDIS Set Cmplt message?
187  case RNDIS_SET_CMPLT:
189  break;
190  //RNDIS Reset Cmplt message?
191  case RNDIS_RESET_CMPLT:
193  break;
194  //RNDIS Keep-Alive Cmplt message?
197  break;
198  //Unknown message type?
199  default:
200  error = ERROR_INVALID_TYPE;
201  break;
202  }
203 
204  //Return status code
205  return error;
206 #else
207  //Successful processing
208  return NO_ERROR;
209 #endif
210 }
211 
212 
213 /**
214  * @brief Dump REMOTE_NDIS_PACKET_MSG message
215  * @param[in] message Pointer to the RNDIS message
216  * @param[in] length Length of the message, in bytes
217  * @return Error code
218  **/
219 
221 {
222  //Check the length of the message
223  if(length < sizeof(RndisPacketMsg))
224  return ERROR_INVALID_LENGTH;
225 
226  //Dump RNDIS message
227  TRACE_DEBUG(" DataOffset = 0x%08" PRIX32 "\r\n", message->dataOffset);
228  TRACE_DEBUG(" DataLength = %" PRIu32 "\r\n", message->dataLength);
229  TRACE_DEBUG(" OOBDataOffset = %" PRIu32 "\r\n", message->oobDataOffset);
230  TRACE_DEBUG(" OOBDataLength = %" PRIu32 "\r\n", message->oobDataLength);
231  TRACE_DEBUG(" NumOOBDataElements = %" PRIu32 "\r\n", message->numOobDataElements);
232  TRACE_DEBUG(" PerPacketInfoOffset = 0x%08" PRIX32 "\r\n", message->perPacketInfoOffset);
233  TRACE_DEBUG(" PerPacketInfoLength = %" PRIu32 "\r\n", message->perPacketInfoLength);
234  TRACE_DEBUG(" VcHandle = 0x%08" PRIX32 "\r\n", message->vcHandle);
235  TRACE_DEBUG(" Reserved = 0x%08" PRIX32 "\r\n", message->reserved);
236 
237  //Successful processing
238  return NO_ERROR;
239 }
240 
241 
242 /**
243  * @brief Dump REMOTE_NDIS_INITIALIZE_MSG message
244  * @param[in] message Pointer to the RNDIS message
245  * @param[in] length Length of the message, in bytes
246  * @return Error code
247  **/
248 
250 {
251  //Check the length of the message
252  if(length < sizeof(RndisInitializeMsg))
253  return ERROR_INVALID_LENGTH;
254 
255  //Dump RNDIS message
256  TRACE_DEBUG(" RequestID = 0x%08" PRIX32 "\r\n", message->requestId);
257  TRACE_DEBUG(" MajorVersion = %" PRIu32 "\r\n", message->majorVersion);
258  TRACE_DEBUG(" MinorVersion = %" PRIu32 "\r\n", message->minorVersion);
259  TRACE_DEBUG(" MaxTransferSize = %" PRIu32 "\r\n", message->maxTransferSize);
260 
261  //Successful processing
262  return NO_ERROR;
263 }
264 
265 
266 /**
267  * @brief Dump REMOTE_NDIS_HALT_MSG message
268  * @param[in] message Pointer to the RNDIS message
269  * @param[in] length Length of the message, in bytes
270  * @return Error code
271  **/
272 
274 {
275  //Check the length of the message
276  if(length < sizeof(RndisHaltMsg))
277  return ERROR_INVALID_LENGTH;
278 
279  //Dump RNDIS message
280  TRACE_DEBUG(" RequestID = 0x%08" PRIX32 "\r\n", message->requestId);
281 
282  //Successful processing
283  return NO_ERROR;
284 }
285 
286 
287 /**
288  * @brief Dump REMOTE_NDIS_QUERY_MSG message
289  * @param[in] message Pointer to the RNDIS message
290  * @param[in] length Length of the message, in bytes
291  * @return Error code
292  **/
293 
295 {
296 //Check current trace level
297 #if (TRACE_LEVEL >= TRACE_LEVEL_DEBUG)
298  const char_t *label;
299 
300  //Check the length of the message
301  if(length < sizeof(RndisQueryMsg))
302  return ERROR_INVALID_LENGTH;
303 
304  //Retrieve the corresponding OID
305  label = rndisFindName(message->oid,
307 
308  //Dump RNDIS message
309  TRACE_DEBUG(" RequestID = 0x%08" PRIX32 "\r\n", message->requestId);
310  TRACE_DEBUG(" OID = 0x%08" PRIX32 " (%s)\r\n", message->oid, label);
311  TRACE_DEBUG(" InformationBufferLength = %" PRIu32 "\r\n", message->infoBufferLength);
312  TRACE_DEBUG(" InformationBufferOffset = %" PRIu32 "\r\n", message->infoBufferOffset);
313  TRACE_DEBUG(" Reserved = %" PRIu32 "\r\n", message->reserved);
314 
315  //Retrieve the length of the OID input buffer
316  length -= sizeof(RndisQueryMsg);
317 
318  //Any data to dump?
319  if(length > 0)
320  {
321  //Dump the content of the OID input buffer
322  TRACE_DEBUG(" OIDInputBuffer (%" PRIuSIZE " bytes)\r\n", length);
323  TRACE_DEBUG_ARRAY(" ", message->oidInputBuffer, length);
324  }
325 #endif
326 
327  //Successful processing
328  return NO_ERROR;
329 }
330 
331 
332 /**
333  * @brief Dump REMOTE_NDIS_SET_MSG message
334  * @param[in] message Pointer to the RNDIS message
335  * @param[in] length Length of the message, in bytes
336  * @return Error code
337  **/
338 
340 {
341 //Check current trace level
342 #if (TRACE_LEVEL >= TRACE_LEVEL_DEBUG)
343  const char_t *label;
344 
345  //Check the length of the message
346  if(length < sizeof(RndisSetMsg))
347  return ERROR_INVALID_LENGTH;
348 
349  //Retrieve the corresponding OID
350  label = rndisFindName(message->oid,
352 
353  //Dump RNDIS message
354  TRACE_DEBUG(" RequestID = 0x%08" PRIX32 "\r\n", message->requestId);
355  TRACE_DEBUG(" OID = 0x%08" PRIX32 " (%s)\r\n", message->oid, label);
356  TRACE_DEBUG(" InformationBufferLength = %" PRIu32 "\r\n", message->infoBufferLength);
357  TRACE_DEBUG(" InformationBufferOffset = %" PRIu32 "\r\n", message->infoBufferOffset);
358  TRACE_DEBUG(" Reserved = %" PRIu32 "\r\n", message->reserved);
359 
360  //Retrieve the length of the OID input buffer
361  length -= sizeof(RndisSetMsg);
362 
363  //Any data to dump?
364  if(length > 0)
365  {
366  //Dump the content of the OID input buffer
367  TRACE_DEBUG(" OIDInputBuffer (%" PRIuSIZE " bytes)\r\n", length);
368  TRACE_DEBUG_ARRAY(" ", message->oidInputBuffer, length);
369  }
370 #endif
371 
372  //Successful processing
373  return NO_ERROR;
374 }
375 
376 
377 /**
378  * @brief Dump REMOTE_NDIS_RESET_MSG message
379  * @param[in] message Pointer to the RNDIS message
380  * @param[in] length Length of the message, in bytes
381  * @return Error code
382  **/
383 
385 {
386  //Check the length of the message
387  if(length < sizeof(RndisResetMsg))
388  return ERROR_INVALID_LENGTH;
389 
390  //Dump RNDIS message
391  TRACE_DEBUG(" Reserved = 0x%08" PRIX32 "\r\n", message->reserved);
392 
393  //Successful processing
394  return NO_ERROR;
395 }
396 
397 
398 /**
399  * @brief Dump REMOTE_NDIS_INDICATE_STATUS_MSG message
400  * @param[in] message Pointer to the RNDIS message
401  * @param[in] length Length of the message, in bytes
402  * @return Error code
403  **/
404 
406 {
407 //Check current trace level
408 #if (TRACE_LEVEL >= TRACE_LEVEL_DEBUG)
409  size_t n;
410  const char_t *label;
411 
412  //Check the length of the message
413  if(length < sizeof(RndisIndicateStatusMsg))
414  return ERROR_INVALID_LENGTH;
415 
416  //Retrieve the corresponding status string
417  label = rndisFindName(message->status,
419 
420  //Dump RNDIS message
421  TRACE_DEBUG(" Status = 0x%08" PRIX32 " (%s)\r\n", message->status, label);
422  TRACE_DEBUG(" StatusBufferLength = %" PRIu32 "\r\n", message->statusBufferLength);
423  TRACE_DEBUG(" StatusBufferOffset = %" PRIu32 "\r\n", message->statusBufferOffset);
424 
425  //Calculate the length of the diagnostic information buffer
426  n = length - message->statusBufferLength;
427 
428  //Any data to dump?
429  if(n > 0)
430  {
431  //Dump the content of the diagnostic information buffer
432  TRACE_DEBUG(" DiagnosticInfoBuffer (%" PRIuSIZE " bytes)\r\n", n);
433  //TRACE_DEBUG_ARRAY(" ", message->diagnosticInfoBuffer, n);
434  }
435 
436  //Calculate the length of the status buffer
437  n = message->statusBufferLength;
438 
439  //Any data to dump?
440  if(n > 0)
441  {
442  //Dump the content of the status buffer
443  TRACE_DEBUG(" DiagnosticInfoBuffer (%" PRIuSIZE " bytes)\r\n", n);
444  //TRACE_DEBUG_ARRAY(" ", message->diagnosticInfoBuffer, n);
445  }
446 #endif
447 
448  //Successful processing
449  return NO_ERROR;
450 }
451 
452 
453 /**
454  * @brief Dump REMOTE_NDIS_KEEPALIVE_MSG message
455  * @param[in] message Pointer to the RNDIS message
456  * @param[in] length Length of the message, in bytes
457  * @return Error code
458  **/
459 
461 {
462  //Check the length of the message
463  if(length < sizeof(RndisKeepAliveMsg))
464  return ERROR_INVALID_LENGTH;
465 
466  //Dump RNDIS message
467  TRACE_DEBUG(" RequestID = 0x%08" PRIX32 "\r\n", message->requestId);
468 
469  //Successful processing
470  return NO_ERROR;
471 }
472 
473 
474 /**
475  * @brief Dump REMOTE_NDIS_INITIALIZE_CMPLT message
476  * @param[in] message Pointer to the RNDIS message
477  * @param[in] length Length of the message, in bytes
478  * @return Error code
479  **/
480 
482 {
483 //Check current trace level
484 #if (TRACE_LEVEL >= TRACE_LEVEL_DEBUG)
485  const char_t *label;
486 
487  //Check the length of the message
488  if(length < sizeof(RndisInitializeCmplt))
489  return ERROR_INVALID_LENGTH;
490 
491  //Retrieve the corresponding status string
492  label = rndisFindName(message->status,
494 
495  //Dump RNDIS message
496  TRACE_DEBUG(" RequestID = 0x%08" PRIX32 "\r\n", message->requestId);
497  TRACE_DEBUG(" Status = 0x%08" PRIX32 " (%s)\r\n", message->status, label);
498  TRACE_DEBUG(" MajorVersion = %" PRIu32 "\r\n", message->majorVersion);
499  TRACE_DEBUG(" MinorVersion = %" PRIu32 "\r\n", message->minorVersion);
500  TRACE_DEBUG(" DeviceFlags = 0x%08" PRIX32 "\r\n", message->deviceFlags);
501  TRACE_DEBUG(" Medium = 0x%08" PRIX32 "\r\n", message->medium);
502  TRACE_DEBUG(" MaxPacketsPerTransfer = %" PRIu32 "\r\n", message->maxPacketsPerTransfer);
503  TRACE_DEBUG(" MaxTransferSize = %" PRIu32 "\r\n", message->maxTransferSize);
504  TRACE_DEBUG(" PacketAlignmentFactor = %" PRIu32 "\r\n", message->packetAlignmentFactor);
505  TRACE_DEBUG(" AFListOffset = %" PRIu32 "\r\n", message->afListOffset);
506  TRACE_DEBUG(" AFListSize = %" PRIu32 "\r\n", message->afListSize);
507 #endif
508 
509  //Successful processing
510  return NO_ERROR;
511 }
512 
513 
514 /**
515  * @brief Dump REMOTE_NDIS_QUERY_CMPLT message
516  * @param[in] message Pointer to the RNDIS message
517  * @param[in] length Length of the message, in bytes
518  * @return Error code
519  **/
520 
522 {
523 //Check current trace level
524 #if (TRACE_LEVEL >= TRACE_LEVEL_DEBUG)
525  const char_t *label;
526 
527  //Check the length of the message
528  if(length < sizeof(RndisQueryCmplt))
529  return ERROR_INVALID_LENGTH;
530 
531  //Retrieve the corresponding status string
532  label = rndisFindName(message->status,
534 
535  //Dump RNDIS message
536  TRACE_DEBUG(" RequestID = 0x%08" PRIX32 "\r\n", message->requestId);
537  TRACE_DEBUG(" Status = 0x%08" PRIX32 " (%s)\r\n", message->status, label);
538  TRACE_DEBUG(" InformationBufferLength = %" PRIu32 "\r\n", message->infoBufferLength);
539  TRACE_DEBUG(" InformationBufferOffset = %" PRIu32 "\r\n", message->infoBufferOffset);
540 
541  //Retrieve the length of the OID input buffer
542  length -= sizeof(RndisQueryCmplt);
543 
544  //Any data to dump?
545  if(length > 0)
546  {
547  //Dump the content of the OID input buffer
548  TRACE_DEBUG(" OIDInputBuffer (%" PRIuSIZE " bytes)\r\n", length);
549  TRACE_DEBUG_ARRAY(" ", message->oidInputBuffer, length);
550  }
551 #endif
552 
553  //Successful processing
554  return NO_ERROR;
555 }
556 
557 
558 /**
559  * @brief Dump REMOTE_NDIS_SET_CMPLT message
560  * @param[in] message Pointer to the RNDIS message
561  * @param[in] length Length of the message, in bytes
562  * @return Error code
563  **/
564 
566 {
567 //Check current trace level
568 #if (TRACE_LEVEL >= TRACE_LEVEL_DEBUG)
569  const char_t *label;
570 
571  //Check the length of the message
572  if(length < sizeof(RndisSetCmplt))
573  return ERROR_INVALID_LENGTH;
574 
575  //Retrieve the corresponding status string
576  label = rndisFindName(message->status,
578 
579  //Dump RNDIS message
580  TRACE_DEBUG(" RequestID = 0x%08" PRIX32 "\r\n", message->requestId);
581  TRACE_DEBUG(" Status = 0x%08" PRIX32 " (%s)\r\n", message->status, label);
582 #endif
583 
584  //Successful processing
585  return NO_ERROR;
586 }
587 
588 
589 /**
590  * @brief Dump REMOTE_NDIS_RESET_CMPLT message
591  * @param[in] message Pointer to the RNDIS message
592  * @param[in] length Length of the message, in bytes
593  * @return Error code
594  **/
595 
597 {
598 //Check current trace level
599 #if (TRACE_LEVEL >= TRACE_LEVEL_DEBUG)
600  const char_t *label;
601 
602  //Check the length of the message
603  if(length < sizeof(RndisResetCmplt))
604  return ERROR_INVALID_LENGTH;
605 
606  //Retrieve the corresponding status string
607  label = rndisFindName(message->status,
609 
610  //Dump RNDIS message
611  TRACE_DEBUG(" Status = 0x%08" PRIX32 " (%s)\r\n", message->status, label);
612  TRACE_DEBUG(" AddressingReset = 0x%08" PRIX32 "\r\n", message->addressingReset);
613 #endif
614 
615  //Successful processing
616  return NO_ERROR;
617 }
618 
619 
620 /**
621  * @brief Dump REMOTE_NDIS_KEEPALIVE_CMPLT message
622  * @param[in] message Pointer to the RNDIS message
623  * @param[in] length Length of the message, in bytes
624  * @return Error code
625  **/
626 
628 {
629 //Check current trace level
630 #if (TRACE_LEVEL >= TRACE_LEVEL_DEBUG)
631  const char_t *label;
632 
633  //Check the length of the message
634  if(length < sizeof(RndisKeepAliveCmplt))
635  return ERROR_INVALID_LENGTH;
636 
637  //Retrieve the corresponding status string
638  label = rndisFindName(message->status,
640 
641  //Dump RNDIS message
642  TRACE_DEBUG(" RequestID = 0x%08" PRIX32 "\r\n", message->requestId);
643  TRACE_DEBUG(" Status = 0x%08" PRIX32 " (%s)\r\n", message->status, label);
644 #endif
645 
646  //Successful processing
647  return NO_ERROR;
648 }
649 
650 
651 /**
652  * @brief Helper function
653  * @param[in] value 32-bit value
654  * @param[in] table Look-up table
655  * @param[in] size Number of entries in the look-up table
656  * @return Pointer to the matching name, if any
657  **/
658 
659 const char_t *rndisFindName(uint32_t value, const RndisValueName *table, size_t size)
660 {
661  //Local variables
662  size_t i;
663 
664  //Default name
665  static const char_t defaultName[] = "Unknown";
666 
667  //Loop through the look-up table
668  for(i = 0; i < size; i++)
669  {
670  //Compare values
671  if(table[i].value == value)
672  {
673  //Return a pointer to the corresponding name
674  return table[i].name;
675  }
676  }
677 
678  //No matching entry...
679  return defaultName;
680 }
RNDIS Packet message.
Definition: rndis.h:408
Response to a RNDIS Initialize message.
Definition: rndis.h:331
#define RNDIS_KEEPALIVE_CMPLT
Definition: rndis.h:68
error_t rndisDumpQueryCmplt(const RndisQueryCmplt *message, size_t length)
Dump REMOTE_NDIS_QUERY_CMPLT message.
Definition: rndis_debug.c:521
#define RNDIS_QUERY_MSG
Definition: rndis.h:60
#define RNDIS_PACKET_MSG
Definition: rndis.h:56
#define RNDIS_QUERY_CMPLT
Definition: rndis.h:61
uint8_t message[]
Definition: chap.h:154
error_t rndisDumpKeepAliveCmplt(const RndisKeepAliveCmplt *message, size_t length)
Dump REMOTE_NDIS_KEEPALIVE_CMPLT message.
Definition: rndis_debug.c:627
#define RNDIS_SET_MSG
Definition: rndis.h:62
RNDIS Query message.
Definition: rndis.h:247
#define RNDIS_HALT_MSG
Definition: rndis.h:59
RNDIS Reset message.
Definition: rndis.h:281
RNDIS Indicate Status message.
Definition: rndis.h:293
#define RNDIS_KEEPALIVE_MSG
Definition: rndis.h:67
Response to a RNDIS Query message.
Definition: rndis.h:353
error_t rndisDumpHaltMsg(const RndisHaltMsg *message, size_t length)
Dump REMOTE_NDIS_HALT_MSG message.
Definition: rndis_debug.c:273
error_t rndisDumpInitializeCmplt(const RndisInitializeCmplt *message, size_t length)
Dump REMOTE_NDIS_INITIALIZE_CMPLT message.
Definition: rndis_debug.c:481
error_t rndisDumpSetMsg(const RndisSetMsg *message, size_t length)
Dump REMOTE_NDIS_SET_MSG message.
Definition: rndis_debug.c:339
RNDIS (Remote Network Driver Interface Specification)
#define RNDIS_INDICATE_STATUS_MSG
Definition: rndis.h:66
Response to a RNDIS Keep-Alive message.
Definition: rndis.h:395
error_t
Error codes.
Definition: error.h:43
#define RNDIS_RESET_MSG
Definition: rndis.h:64
#define RNDIS_INITIALIZE_MSG
Definition: rndis.h:57
error_t rndisDumpKeepAliveMsg(const RndisKeepAliveMsg *message, size_t length)
Dump REMOTE_NDIS_KEEPALIVE_MSG message.
Definition: rndis_debug.c:460
const RndisValueName rndisOidLabel[]
Definition: rndis_debug.c:77
#define RNDIS_RESET_CMPLT
Definition: rndis.h:65
Response to a RNDIS Set message.
Definition: rndis.h:369
RNDIS Initialize message.
Definition: rndis.h:220
@ ERROR_INVALID_LENGTH
Definition: error.h:111
const char_t * rndisFindName(uint32_t value, const RndisValueName *table, size_t size)
Helper function.
Definition: rndis_debug.c:659
@ ERROR_INVALID_TYPE
Definition: error.h:115
const RndisValueName rndisStatusLabel[]
Definition: rndis_debug.c:66
uint8_t length
Definition: tcp.h:368
Generic RNDIS message.
Definition: rndis.h:209
#define TRACE_DEBUG_ARRAY(p, a, n)
Definition: rndis_debug.c:44
#define TRACE_DEBUG(...)
Definition: rndis_debug.c:42
error_t rndisDumpPacketMsg(const RndisPacketMsg *message, size_t length)
Dump REMOTE_NDIS_PACKET_MSG message.
Definition: rndis_debug.c:220
char char_t
Definition: compiler_port.h:48
const RndisValueName rndisMsgLabel[]
Definition: rndis_debug.c:48
RNDIS Set message.
Definition: rndis.h:264
uint8_t n
Value/name pair.
Definition: rndis_debug.h:43
error_t rndisDumpResetCmplt(const RndisResetCmplt *message, size_t length)
Dump REMOTE_NDIS_RESET_CMPLT message.
Definition: rndis_debug.c:596
error_t rndisDumpQueryMsg(const RndisQueryMsg *message, size_t length)
Dump REMOTE_NDIS_QUERY_MSG message.
Definition: rndis_debug.c:294
error_t rndisDumpMsg(const RndisMsg *message, size_t length)
Dump RNDIS message for debugging purpose.
Definition: rndis_debug.c:124
uint8_t value[]
Definition: tcp.h:369
error_t rndisDumpSetCmplt(const RndisSetCmplt *message, size_t length)
Dump REMOTE_NDIS_SET_CMPLT message.
Definition: rndis_debug.c:565
error_t rndisDumpInitializeMsg(const RndisInitializeMsg *message, size_t length)
Dump REMOTE_NDIS_INITIALIZE_MSG message.
Definition: rndis_debug.c:249
const char_t * name
Definition: rndis_debug.h:45
Response to a RNDIS Reset message.
Definition: rndis.h:382
#define PRIuSIZE
#define RNDIS_INITIALIZE_CMPLT
Definition: rndis.h:58
error_t rndisDumpIndicateStatusMsg(const RndisIndicateStatusMsg *message, size_t length)
Dump REMOTE_NDIS_INDICATE_STATUS_MSG message.
Definition: rndis_debug.c:405
RTOS abstraction layer.
RNDIS Keep-Alive message.
Definition: rndis.h:319
@ NO_ERROR
Success.
Definition: error.h:44
Debugging facilities.
RNDIS Halt message.
Definition: rndis.h:235
error_t rndisDumpResetMsg(const RndisResetMsg *message, size_t length)
Dump REMOTE_NDIS_RESET_MSG message.
Definition: rndis_debug.c:384
#define arraysize(a)
Definition: os_port.h:71
#define RNDIS_SET_CMPLT
Definition: rndis.h:63