generic.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217
  1. /*++
  2. Copyright (c) 2016 Minoca Corp. All Rights Reserved
  3. Module Name:
  4. generic.h
  5. Abstract:
  6. This header contains definitions for the generic netlink protocol.
  7. Author:
  8. Chris Stevens 10-Feb-2016
  9. --*/
  10. //
  11. // ------------------------------------------------------------------- Includes
  12. //
  13. //
  14. // ---------------------------------------------------------------- Definitions
  15. //
  16. #define NETLINK_GENERIC_ALLOCATION_TAG 0x65676C4E // 'eglN'
  17. //
  18. // ------------------------------------------------------ Data Type Definitions
  19. //
  20. /*++
  21. Structure Description:
  22. This structure defines a generic netlink family.
  23. Members:
  24. TreeNode - Stores a node in the global tree of generic netlink families.
  25. ReferenceCount - Stores the number of references take on the family.
  26. MulticastGroupOffset - Stores the offset into the entire generic netlink
  27. multicast group ID namespace where this family's multicast group IDs
  28. begin.
  29. Properties - Stores the generic netlink family properties, including its ID
  30. name, and interface.
  31. --*/
  32. struct _NETLINK_GENERIC_FAMILY {
  33. RED_BLACK_TREE_NODE TreeNode;
  34. volatile ULONG ReferenceCount;
  35. ULONG MulticastGroupOffset;
  36. NETLINK_GENERIC_FAMILY_PROPERTIES Properties;
  37. };
  38. //
  39. // -------------------------------------------------------------------- Globals
  40. //
  41. //
  42. // Store the lock and tree for storing the generic netlink families.
  43. //
  44. extern PSHARED_EXCLUSIVE_LOCK NetlinkGenericFamilyLock;
  45. extern RED_BLACK_TREE NetlinkGenericFamilyTree;
  46. //
  47. // -------------------------------------------------------- Function Prototypes
  48. //
  49. VOID
  50. NetlinkpGenericControlInitialize (
  51. VOID
  52. );
  53. /*++
  54. Routine Description:
  55. This routine initializes the built in generic netlink control family.
  56. Arguments:
  57. None.
  58. Return Value:
  59. None.
  60. --*/
  61. KSTATUS
  62. NetlinkpGenericControlSendNotification (
  63. PNETLINK_GENERIC_FAMILY Family,
  64. UCHAR Command,
  65. PNETLINK_GENERIC_MULTICAST_GROUP Group
  66. );
  67. /*++
  68. Routine Description:
  69. This routine sends a generic netlink control command based on the family
  70. and or group information.
  71. Arguments:
  72. Family - Supplies a pointer to the generic netlink family for which the
  73. command is being sent.
  74. Command - Supplies the generic netlink control command to be sent.
  75. Group - Supplies an optional pointers to the multicast group that has
  76. just arrived or is being deleted.
  77. Return Value:
  78. Status code.
  79. --*/
  80. PNETLINK_GENERIC_FAMILY
  81. NetlinkpGenericLookupFamilyById (
  82. ULONG FamilyId
  83. );
  84. /*++
  85. Routine Description:
  86. This routine searches the database of registered generic netlink families
  87. for one with the given ID. If successful, the family is returned with an
  88. added reference which the caller must release.
  89. Arguments:
  90. FamilyId - Supplies the ID of the desired family.
  91. Return Value:
  92. Returns a pointer to the generic netlink family on success or NULL on
  93. failure.
  94. --*/
  95. PNETLINK_GENERIC_FAMILY
  96. NetlinkpGenericLookupFamilyByName (
  97. PSTR FamilyName
  98. );
  99. /*++
  100. Routine Description:
  101. This routine searches the database of registered generic netlink families
  102. for one with the given name. If successful, the family is returned with an
  103. added reference which the caller must release.
  104. Arguments:
  105. FamilyName - Supplies the name of the desired family.
  106. Return Value:
  107. Returns a pointer to the generic netlink family on success or NULL on
  108. failure.
  109. --*/
  110. VOID
  111. NetlinkpGenericFamilyAddReference (
  112. PNETLINK_GENERIC_FAMILY Family
  113. );
  114. /*++
  115. Routine Description:
  116. This routine increments the reference count of a generic netlink family.
  117. Arguments:
  118. Family - Supplies a pointer to a generic netlink family.
  119. Return Value:
  120. None.
  121. --*/
  122. VOID
  123. NetlinkpGenericFamilyReleaseReference (
  124. PNETLINK_GENERIC_FAMILY Family
  125. );
  126. /*++
  127. Routine Description:
  128. This routine decrements the reference count of a generic netlink family,
  129. releasing all of its resources if the reference count drops to zero.
  130. Arguments:
  131. Family - Supplies a pointer to a generic netlink family.
  132. Return Value:
  133. None.
  134. --*/