myco-daemon.h 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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-daemon
  17. * @Short_description: daemon library
  18. * @Title: MycoDaemon
  19. *
  20. * MycoDaemon implements the daemon side of the Mycorrhiza distributed system.
  21. */
  22. #ifndef __MYCO_DAEMON_H
  23. #define __MYCO_DAEMON_H
  24. #include <sys/types.h>
  25. #include <sys/ipc.h>
  26. #include <sys/msg.h>
  27. #include <sys/stat.h>
  28. #include <stdio.h>
  29. #include <unistd.h>
  30. #include <errno.h>
  31. #include <string.h>
  32. #include <sys/socket.h>
  33. #include <netinet/in.h>
  34. #include <arpa/inet.h>
  35. #include <fcntl.h>
  36. #include "myco-ipc.c"
  37. typedef struct myco_agent_ myco_agent;
  38. struct myco_agent_ {
  39. char name[AGENT_NAME_LENGTH];
  40. int message_queue_id;
  41. in_addr_t node_ip;
  42. myco_agent *next;
  43. myco_agent *prev;
  44. };
  45. typedef struct myco_resource_ myco_resource;
  46. struct myco_resource_ {
  47. char name[RESOURCE_NAME_LENGTH];
  48. int transactional;
  49. char agent[AGENT_NAME_LENGTH];
  50. pid_t pid;
  51. void* pointer;
  52. int size;
  53. int read_locked; // 0 = unlocked, 1 = locked
  54. int transfer_locked; // 0 = unlocked, 1 = locked
  55. int version;
  56. in_addr_t node_ip;
  57. myco_resource *next;
  58. myco_resource *prev;
  59. };
  60. int myco_daemon_start (pid_t pid, const char *node_ip, const char *indexer_ip);
  61. myco_agent *myco_daemon_find_agent(const char *agent_name);
  62. int myco_daemon_register_agent(message msg);
  63. int myco_daemon_unregister_agent(message msg);
  64. myco_resource *myco_daemon_find_resource_by_agent(const char *agent_name);
  65. myco_resource *myco_daemon_find_resource(const char *resource_name);
  66. int myco_daemon_register_resource(message msg);
  67. int myco_daemon_unregister_resource(message msg);
  68. int myco_daemon_request_resource(message msg);
  69. int myco_daemon_request_list(message msg, pid_t pid);
  70. int myco_daemon_request_remote_resource(message msg);
  71. int myco_daemon_write_remote_resource(message msg, int force);
  72. int myco_daemon_read_remote_resource(message msg);
  73. #endif //__MYCO_DAEMON_H