12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879 |
- /* Copyright (C) 2016 Max Riechelmann <max.riechelmann@student.kit.edu>
- (Karlsruhe Institute of Technology)
- This library is free software; you can redistribute it and/or modify it
- under the terms of the GNU Lesser General Public License as published by the
- Free Software Foundation; either version 2.1 of the License, or (at your
- option) any later version.
- This library is distributed in the hope that it will be useful, but WITHOUT
- ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
- details.
- You should have received a copy of the GNU Lesser General Public License along
- with this library; if not, write to the Free Software Foundation, Inc., 51
- Franklin St, Fifth Floor, Boston, MA 02110, USA
- */
- /**
- * SECTION: myco-ipc
- * @Short_description: common header for ipc between agents, workers and daemon
- * @Title: MycoIpc
- *
- * MycoIpc organizes the message queues that are used between agents, workers
- * and daemons.
- */
- #ifndef __MYCO_IPC_H
- #define __MYCO_IPC_H
- #include <stdlib.h>
- #include <signal.h>
- #define _GNU_SOURCE
- #include <sys/uio.h>
- #include <sys/types.h>
- #include <sys/ipc.h>
- #include <sys/msg.h>
- #include <sys/stat.h>
- #include <stdio.h>
- #include <unistd.h>
- #include <errno.h>
- #include <string.h>
- #define KEY 5234L
- #define MESSAGE_LENGTH 256
- #define RESOURCE_NAME_LENGTH 256
- #define AGENT_NAME_LENGTH 256
- #define PERM 0666
- #define RESOURCE_TRANSACTIONAL 1
- #define RESOURCE_NOT_TRANSACTIONAL 2
- struct resource {
- void *pointer;
- int size;
- };
- typedef struct {
- char message[MESSAGE_LENGTH];
- char resource_name[RESOURCE_NAME_LENGTH];
- char agent_name[AGENT_NAME_LENGTH];
- int agent_message_queue_id;
- void *resource_pointer;
- int resource_size;
- int resource_transactional;
- pid_t sender_pid;
- int version;
- } message;
- typedef struct {
- long int mtype;
- char mtext[sizeof(message)];
- } message_item;
- int myco_send(int message_queue_id, message msg);
- message myco_receive(int message_queue_id);
- message myco_send_and_receive(message msg, int send_message_queue_id, int receive_message_queue_id);
- int myco_read_transactional(pid_t source_pid, void *source_pointer, int source_length, void *target_pointer, int target_length);
- #endif //__MYCO_IPC_H
|