myco-agent.h 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. /* Copyright (C) 2016 Max Riechelmann <max.riechelmann@student.kit.edu>
  2. (Karlsruhe Institute of Technology)
  3. This library is free software; you can redistribute it and/or modify it
  4. under the terms of the GNU Lesser General Public License as published by the
  5. Free Software Foundation; either version 2.1 of the License, or (at your
  6. option) any later version.
  7. This library is distributed in the hope that it will be useful, but WITHOUT
  8. ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  9. FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
  10. details.
  11. You should have received a copy of the GNU Lesser General Public License along
  12. with this library; if not, write to the Free Software Foundation, Inc., 51
  13. Franklin St, Fifth Floor, Boston, MA 02110, USA
  14. */
  15. /**
  16. * SECTION: myco-agent
  17. * @Short_description: agent library
  18. * @Title: MycoAgent
  19. *
  20. * MycoAgent implements the agent side of the Mycorrhiza distributed system.
  21. * It (un-)registers with the mycoagent and provides information about
  22. * accessible data RESOURCES.
  23. */
  24. #ifndef __MYCO_AGENT_H
  25. #define __MYCO_AGENT_H
  26. #include <sys/types.h>
  27. #include <sys/socket.h>
  28. #include <netinet/in.h>
  29. #include <arpa/inet.h>
  30. #include <unistd.h>
  31. #include <stdlib.h>
  32. #include <stdio.h>
  33. #include <string.h>
  34. /**
  35. * myco_agent_register:
  36. * @pid: The PID of the user program.
  37. * @myco_daemon_address: The IP address of the daemon (usually localhost).
  38. * @myco_daemon_port: The port of the daemon.
  39. *
  40. * Registers self with the local daemon process.
  41. *
  42. * Returns: 0 on success, -1 on error
  43. */
  44. int myco_agent_register (int pid, const char *myco_daemon_address, uint16_t myco_daemon_port);
  45. /**
  46. * myco_agent_unregister:
  47. * @pid: The PID of the user program.
  48. * @myco_daemon_address: The IP address of the daemon (usually localhost).
  49. * @myco_daemon_port: The port of the daemon.
  50. *
  51. * Unregisters self with the local daemon process.
  52. *
  53. * Returns: 0 on success, -1 on error
  54. */
  55. int myco_agent_unregister (int pid, const char *myco_daemon_address, uint16_t myco_daemon_port);
  56. /**
  57. * myco_agent_register_resource:
  58. * @pid: The PID of the user program.
  59. * @myco_daemon_address: The IP address of the daemon (usually localhost).
  60. * @myco_daemon_port: The port of the daemon.
  61. * @resource_name: Name of resource.
  62. *
  63. * Registers self with the local daemon process.
  64. *
  65. * Returns: -1 on error, the unique resource id on success
  66. */
  67. int myco_agent_register_resource (int pid, const char *myco_daemon_address, uint16_t myco_daemon_port, const char *resource_name);
  68. /**
  69. * myco_agent_request_resource:
  70. * @pid: The PID of the user program.
  71. * @myco_daemon_address: The IP address of the daemon (usually localhost).
  72. * @myco_daemon_port: The port of the daemon.
  73. * @resource_id: The unique resource id.
  74. * @resource_pointer: Pointer to the local memory region where to write the resource to.
  75. * @resource_size: Size in Bytes the resource takes.
  76. * @resource_name: Variable for resource name, filled by daemon.
  77. *
  78. * Requests a resource from the daemon. If size equals actual resource size transfer is
  79. * done immediatly. This only works if resource size is known beforehand. If resource
  80. * size is unknown check with myco_agent_request_resource_info();
  81. *
  82. * Returns: -1 on error, 0 on success
  83. */
  84. int myco_agent_request_resource(int pid, const char *myco_daemon_address, uint16_t myco_daemon_port, int resource_id, void *resource_pointer, int resource_size, char *resource_name);
  85. /**
  86. * myco_agent_request_resource_info:
  87. * @pid: The PID of the user program.
  88. * @myco_daemon_address: The IP address of the daemon (usually localhost).
  89. * @myco_daemon_port: The port of the daemon.
  90. * @resource_id: The unique resource id.
  91. * @resource_size: Size in Bytes the resource takes.
  92. * @resource_name: Variable for resource name, filled by daemon.
  93. *
  94. * Requests resource information from the daemon.
  95. *
  96. * Returns: -1 on error, 0 on success
  97. */
  98. int myco_agent_request_resource_info(int pid, const char *myco_daemon_address, uint16_t myco_daemon_port, int resource_id, int resource_size, char *resource_name);
  99. /**
  100. * myco_agent_request_resource_list:
  101. * @pid: The PID of the user program.
  102. * @myco_daemon_address: The IP address of the daemon (usually localhost).
  103. * @myco_daemon_port: The port of the daemon.
  104. * @resource_list: A comma seperated list of resources (id, name, size).
  105. *
  106. * Requests resource list. Obtains a list of all resources in the current network.
  107. *
  108. * Returns: -1 on error, 0 on success
  109. */
  110. int myco_agent_request_resource_list(int pid, const char *myco_daemon_address, uint16_t myco_daemon_port, char *resource_list);
  111. #endif //__MYCO_AGENT_H