w1_netlink.h 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. /*
  2. * w1_netlink.h
  3. *
  4. * Copyright (c) 2003 Evgeniy Polyakov <zbr@ioremap.net>
  5. *
  6. *
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License as published by
  9. * the Free Software Foundation; either version 2 of the License, or
  10. * (at your option) any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program; if not, write to the Free Software
  19. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  20. */
  21. #ifndef __W1_NETLINK_H
  22. #define __W1_NETLINK_H
  23. #include <asm/types.h>
  24. #include <linux/connector.h>
  25. #include "w1.h"
  26. /**
  27. * enum w1_cn_msg_flags - bitfield flags for struct cn_msg.flags
  28. *
  29. * @W1_CN_BUNDLE: Request bundling replies into fewer messagse. Be prepared
  30. * to handle multiple struct cn_msg, struct w1_netlink_msg, and
  31. * struct w1_netlink_cmd in one packet.
  32. */
  33. enum w1_cn_msg_flags {
  34. W1_CN_BUNDLE = 1,
  35. };
  36. /**
  37. * enum w1_netlink_message_types - message type
  38. *
  39. * @W1_SLAVE_ADD: notification that a slave device was added
  40. * @W1_SLAVE_REMOVE: notification that a slave device was removed
  41. * @W1_MASTER_ADD: notification that a new bus master was added
  42. * @W1_MASTER_REMOVE: notification that a bus masterwas removed
  43. * @W1_MASTER_CMD: initiate operations on a specific master
  44. * @W1_SLAVE_CMD: sends reset, selects the slave, then does a read/write/touch
  45. * operation
  46. * @W1_LIST_MASTERS: used to determine the bus master identifiers
  47. */
  48. enum w1_netlink_message_types {
  49. W1_SLAVE_ADD = 0,
  50. W1_SLAVE_REMOVE,
  51. W1_MASTER_ADD,
  52. W1_MASTER_REMOVE,
  53. W1_MASTER_CMD,
  54. W1_SLAVE_CMD,
  55. W1_LIST_MASTERS,
  56. };
  57. /**
  58. * struct w1_netlink_msg - holds w1 message type, id, and result
  59. *
  60. * @type: one of enum w1_netlink_message_types
  61. * @status: kernel feedback for success 0 or errno failure value
  62. * @len: length of data following w1_netlink_msg
  63. * @id: union holding master bus id (msg.id) and slave device id (id[8]).
  64. * @data: start address of any following data
  65. *
  66. * The base message structure for w1 messages over netlink.
  67. * The netlink connector data sequence is, struct nlmsghdr, struct cn_msg,
  68. * then one or more struct w1_netlink_msg (each with optional data).
  69. */
  70. struct w1_netlink_msg
  71. {
  72. __u8 type;
  73. __u8 status;
  74. __u16 len;
  75. union {
  76. __u8 id[8];
  77. struct w1_mst {
  78. __u32 id;
  79. __u32 res;
  80. } mst;
  81. } id;
  82. __u8 data[0];
  83. };
  84. /**
  85. * enum w1_commands - commands available for master or slave operations
  86. *
  87. * @W1_CMD_READ: read len bytes
  88. * @W1_CMD_WRITE: write len bytes
  89. * @W1_CMD_SEARCH: initiate a standard search, returns only the slave
  90. * devices found during that search
  91. * @W1_CMD_ALARM_SEARCH: search for devices that are currently alarming
  92. * @W1_CMD_TOUCH: Touches a series of bytes.
  93. * @W1_CMD_RESET: sends a bus reset on the given master
  94. * @W1_CMD_SLAVE_ADD: adds a slave to the given master,
  95. * 8 byte slave id at data[0]
  96. * @W1_CMD_SLAVE_REMOVE: removes a slave to the given master,
  97. * 8 byte slave id at data[0]
  98. * @W1_CMD_LIST_SLAVES: list of slaves registered on this master
  99. * @W1_CMD_MAX: number of available commands
  100. */
  101. enum w1_commands {
  102. W1_CMD_READ = 0,
  103. W1_CMD_WRITE,
  104. W1_CMD_SEARCH,
  105. W1_CMD_ALARM_SEARCH,
  106. W1_CMD_TOUCH,
  107. W1_CMD_RESET,
  108. W1_CMD_SLAVE_ADD,
  109. W1_CMD_SLAVE_REMOVE,
  110. W1_CMD_LIST_SLAVES,
  111. W1_CMD_MAX
  112. };
  113. /**
  114. * struct w1_netlink_cmd - holds the command and data
  115. *
  116. * @cmd: one of enum w1_commands
  117. * @res: reserved
  118. * @len: length of data following w1_netlink_cmd
  119. * @data: start address of any following data
  120. *
  121. * One or more struct w1_netlink_cmd is placed starting at w1_netlink_msg.data
  122. * each with optional data.
  123. */
  124. struct w1_netlink_cmd
  125. {
  126. __u8 cmd;
  127. __u8 res;
  128. __u16 len;
  129. __u8 data[0];
  130. };
  131. #ifdef __KERNEL__
  132. void w1_netlink_send(struct w1_master *, struct w1_netlink_msg *);
  133. int w1_init_netlink(void);
  134. void w1_fini_netlink(void);
  135. #endif /* __KERNEL__ */
  136. #endif /* __W1_NETLINK_H */