shim_ipc.h 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613
  1. /* -*- mode:c; c-file-style:"k&r"; c-basic-offset: 4; tab-width:4; indent-tabs-mode:nil; mode:auto-fill; fill-column:78; -*- */
  2. /* vim: set ts=4 sw=4 et tw=78 fo=cqt wm=0: */
  3. /* Copyright (C) 2014 Stony Brook University
  4. This file is part of Graphene Library OS.
  5. Graphene Library OS is free software: you can redistribute it and/or
  6. modify it under the terms of the GNU Lesser General Public License
  7. as published by the Free Software Foundation, either version 3 of the
  8. License, or (at your option) any later version.
  9. Graphene Library OS is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU Lesser General Public License for more details.
  13. You should have received a copy of the GNU Lesser General Public License
  14. along with this program. If not, see <http://www.gnu.org/licenses/>. */
  15. /*
  16. * shim_ipc.h
  17. *
  18. * Definitions of types and functions for IPC bookkeeping.
  19. */
  20. #ifndef _SHIM_IPC_H_
  21. #define _SHIM_IPC_H_
  22. #include <shim_types.h>
  23. #include <shim_defs.h>
  24. #include <shim_handle.h>
  25. #include <shim_thread.h>
  26. #include <shim_sysv.h>
  27. #include <pal.h>
  28. #include <list.h>
  29. DEFINE_LIST(shim_ipc_info);
  30. struct shim_ipc_info {
  31. IDTYPE vmid;
  32. struct shim_ipc_port * port;
  33. PAL_HANDLE pal_handle;
  34. struct shim_qstr uri;
  35. LIST_TYPE(shim_ipc_info) hlist;
  36. REFTYPE ref_count;
  37. };
  38. enum { PID_NS, SYSV_NS, TOTAL_NS };
  39. struct shim_process {
  40. IDTYPE vmid;
  41. LOCKTYPE lock;
  42. int exit_code;
  43. struct shim_ipc_info * self, * parent;
  44. struct shim_ipc_info * ns[TOTAL_NS];
  45. };
  46. extern struct shim_process cur_process;
  47. #define IPC_MSG_MINIMAL_SIZE 48
  48. #define IPC_MSG_READAHEAD 96
  49. struct shim_ipc_msg {
  50. unsigned char code;
  51. unsigned int size;
  52. IDTYPE src, dst;
  53. unsigned long seq;
  54. #ifdef PROFILE
  55. unsigned long time;
  56. #endif
  57. char msg[];
  58. } __attribute__((packed));
  59. struct shim_ipc_port;
  60. struct shim_thread;
  61. DEFINE_LIST(shim_ipc_msg_obj);
  62. struct shim_ipc_msg_obj {
  63. struct shim_thread * thread;
  64. LIST_TYPE(shim_ipc_msg_obj) list;
  65. int retval;
  66. void * private;
  67. struct shim_ipc_msg msg;
  68. };
  69. typedef void (*port_fini) (struct shim_ipc_port *, IDTYPE vmid,
  70. unsigned int exitcode);
  71. #define MAX_IPC_PORT_FINI_CB 3
  72. DEFINE_LIST(shim_ipc_port);
  73. DEFINE_LISTP(shim_ipc_msg_obj);
  74. struct shim_ipc_port {
  75. PAL_HANDLE pal_handle;
  76. REFTYPE ref_count;
  77. LIST_TYPE(shim_ipc_port) hlist;
  78. LIST_TYPE(shim_ipc_port) list;
  79. LISTP_TYPE(shim_ipc_msg_obj) msgs;
  80. LOCKTYPE msgs_lock;
  81. port_fini fini[MAX_IPC_PORT_FINI_CB];
  82. bool update, recent;
  83. struct {
  84. unsigned int type;
  85. IDTYPE vmid;
  86. } info, private;
  87. };
  88. #define IPC_CALLBACK_ARGS \
  89. struct shim_ipc_msg * msg, struct shim_ipc_port * port
  90. /* if callback return RESPONSE_CALLBACK, send a response even if the callback
  91. succeed. */
  92. #define RESPONSE_CALLBACK 1
  93. typedef int (*ipc_callback) (IPC_CALLBACK_ARGS);
  94. /* Messagge code to response the connection */
  95. enum {
  96. IPC_RESP = 0,
  97. IPC_FINDURI,
  98. IPC_TELLURI,
  99. IPC_CHECKPOINT,
  100. IPC_BASE_BOUND,
  101. };
  102. /* IPC_RESP: response for incoming messages */
  103. struct shim_ipc_resp {
  104. int retval;
  105. } __attribute__((packed));
  106. /* IPC_FINDURI: request a URI from a connect process */
  107. int ipc_finduri_send (struct shim_ipc_port * port, IDTYPE dest,
  108. struct shim_ipc_info ** info);
  109. int ipc_finduri_callback (IPC_CALLBACK_ARGS);
  110. /* IPC_TELLURI: replying with a connectable URI */
  111. struct shim_ipc_telluri {
  112. char uri[1];
  113. } __attribute__((packed));
  114. int ipc_telluri_send (struct shim_ipc_port * port, IDTYPE dest,
  115. struct shim_ipc_info * info);
  116. int ipc_telluri_callback (IPC_CALLBACK_ARGS);
  117. /* PID_CHECKPOINT: broadcast checkpointing */
  118. struct shim_ipc_checkpoint {
  119. IDTYPE cpsession;
  120. char cpdir[1];
  121. } __attribute__((packed));
  122. int ipc_checkpoint_send (const char * cpdir, IDTYPE cpsession);
  123. int ipc_checkpoint_callback (IPC_CALLBACK_ARGS);
  124. /* Message code from child to parent */
  125. #define IPC_CLD_BASE IPC_BASE_BOUND
  126. enum {
  127. IPC_CLD_EXIT = IPC_CLD_BASE,
  128. IPC_CLD_JOIN,
  129. #ifdef PROFILE
  130. IPC_CLD_PROFILE,
  131. #endif
  132. IPC_CLD_BOUND,
  133. };
  134. /* CLD_EXIT: thread exit */
  135. struct shim_ipc_cld_exit {
  136. IDTYPE ppid, tid;
  137. unsigned int exitcode;
  138. unsigned int term_signal;
  139. #ifdef PROFILE
  140. unsigned long time;
  141. #endif
  142. } __attribute__((packed));
  143. int ipc_cld_exit_send (IDTYPE ppid, IDTYPE tid, unsigned int exitcode, unsigned int term_signal);
  144. int ipc_cld_exit_callback (IPC_CALLBACK_ARGS);
  145. /* CLD_JOIN: child join the parent group */
  146. int ipc_cld_join_send (IDTYPE dest);
  147. int ipc_cld_join_callback (IPC_CALLBACK_ARGS);
  148. #ifdef PROFILE
  149. # include <shim_profile.h>
  150. struct shim_ipc_cld_profile {
  151. unsigned long time;
  152. int nprofile;
  153. struct profile_val profile[];
  154. } __attribute__((packed));
  155. int ipc_cld_profile_send (void);
  156. int ipc_cld_profile_callback (IPC_CALLBACK_ARGS);
  157. #endif
  158. /* Message code to namespace manager */
  159. #define IPC_PID_BASE IPC_CLD_BOUND
  160. #define NS pid
  161. #define NS_CAP PID
  162. #include "shim_ipc_ns.h"
  163. enum {
  164. IPC_PID_KILL = IPC_PID_TEMPLATE_BOUND,
  165. IPC_PID_GETSTATUS,
  166. IPC_PID_RETSTATUS,
  167. IPC_PID_GETMETA,
  168. IPC_PID_RETMETA,
  169. IPC_PID_NOP,
  170. IPC_PID_SENDRPC,
  171. IPC_PID_BOUND,
  172. };
  173. enum kill_type { KILL_THREAD, KILL_PROCESS, KILL_PGROUP, KILL_ALL };
  174. /* PID_KILL: send signal to certain pid */
  175. struct shim_ipc_pid_kill {
  176. IDTYPE sender;
  177. enum kill_type type;
  178. IDTYPE id;
  179. int signum;
  180. } __attribute__((packed));
  181. int ipc_pid_kill_send (IDTYPE sender, IDTYPE id, enum kill_type type,
  182. int signum);
  183. int ipc_pid_kill_callback (IPC_CALLBACK_ARGS);
  184. struct pid_status {
  185. IDTYPE pid, tgid, pgid;
  186. } __attribute__((packed));
  187. /* PID_GETSTATUS: check if certain pid(s) exists */
  188. struct shim_ipc_pid_getstatus {
  189. int npids;
  190. IDTYPE pids[];
  191. } __attribute__((packed));
  192. int ipc_pid_getstatus_send (struct shim_ipc_port * port, IDTYPE dest,
  193. int npids, IDTYPE * pids,
  194. struct pid_status ** status);
  195. int ipc_pid_getstatus_callback (IPC_CALLBACK_ARGS);
  196. /* PID_RETSTATUS: return status of pid(s) */
  197. struct shim_ipc_pid_retstatus {
  198. int nstatus;
  199. struct pid_status status[];
  200. } __attribute__((packed));
  201. int ipc_pid_retstatus_send (struct shim_ipc_port * port, IDTYPE dest,
  202. int nstatus, struct pid_status * status,
  203. unsigned long seq);
  204. int ipc_pid_retstatus_callback (IPC_CALLBACK_ARGS);
  205. /* PID_GETMETA: get metadata of certain pid */
  206. enum pid_meta_code {
  207. PID_META_CRED,
  208. PID_META_EXEC,
  209. PID_META_CWD,
  210. PID_META_ROOT,
  211. };
  212. struct shim_ipc_pid_getmeta {
  213. IDTYPE pid;
  214. enum pid_meta_code code;
  215. } __attribute__((packed));
  216. int ipc_pid_getmeta_send (IDTYPE pid, enum pid_meta_code code,
  217. void ** data);
  218. int ipc_pid_getmeta_callback (IPC_CALLBACK_ARGS);
  219. /* PID_RETMETA: return metadata of certain pid */
  220. struct shim_ipc_pid_retmeta {
  221. IDTYPE pid;
  222. enum pid_meta_code code;
  223. int datasize;
  224. char data[];
  225. } __attribute__((packed));
  226. int ipc_pid_retmeta_send (struct shim_ipc_port * port, IDTYPE dest,
  227. IDTYPE pid, enum pid_meta_code code,
  228. const void * data, int datasize,
  229. unsigned long seq);
  230. int ipc_pid_retmeta_callback (IPC_CALLBACK_ARGS);
  231. /* PID_NOP: send junk message (for benchmarking) */
  232. struct shim_ipc_pid_nop {
  233. int count;
  234. char payload[];
  235. } __attribute__((packed));
  236. int ipc_pid_nop_send (struct shim_ipc_port * port, IDTYPE dest, int count,
  237. const void * buf, int len);
  238. int ipc_pid_nop_callback(IPC_CALLBACK_ARGS);
  239. /* PID_SENDRPC: send arbitary message (for benchmarking) */
  240. struct shim_ipc_pid_sendrpc {
  241. IDTYPE sender;
  242. int len;
  243. char payload[];
  244. } __attribute__((packed));
  245. int ipc_pid_sendrpc_send (IDTYPE pid, IDTYPE sender, const void * buf,
  246. int len);
  247. int ipc_pid_sendrpc_callback (IPC_CALLBACK_ARGS);
  248. #define IPC_SYSV_BASE IPC_PID_BOUND
  249. struct sysv_key {
  250. unsigned long key;
  251. enum sysv_type type;
  252. };
  253. #define NS sysv
  254. #define NS_CAP SYSV
  255. #define NS_KEY struct sysv_key
  256. #include "shim_ipc_ns.h"
  257. enum {
  258. IPC_SYSV_DELRES = IPC_SYSV_TEMPLATE_BOUND,
  259. IPC_SYSV_MOVRES,
  260. IPC_SYSV_MSGSND,
  261. IPC_SYSV_MSGRCV,
  262. IPC_SYSV_MSGMOV,
  263. IPC_SYSV_SEMOP,
  264. IPC_SYSV_SEMCTL,
  265. IPC_SYSV_SEMRET,
  266. IPC_SYSV_SEMMOV,
  267. #ifdef USE_SHARED_SEMAPHORE
  268. IPC_SYSV_SEMQUERY,
  269. IPC_SYSV_SEMREPLY,
  270. #endif
  271. IPC_SYSV_BOUND,
  272. };
  273. /* SYSV_DELRES */
  274. struct shim_ipc_sysv_delres {
  275. IDTYPE resid;
  276. enum sysv_type type;
  277. } __attribute__((packed));
  278. int ipc_sysv_delres_send (struct shim_ipc_port * port, IDTYPE dest,
  279. IDTYPE resid, enum sysv_type type);
  280. int ipc_sysv_delres_callback (IPC_CALLBACK_ARGS);
  281. /* SYSV_MOVRES */
  282. struct shim_ipc_sysv_movres {
  283. IDTYPE resid;
  284. enum sysv_type type;
  285. IDTYPE owner;
  286. LEASETYPE lease;
  287. char uri[1];
  288. } __attribute__((packed));
  289. int ipc_sysv_movres_send (struct sysv_client * client, IDTYPE owner,
  290. const char * uri, LEASETYPE lease, IDTYPE resid,
  291. enum sysv_type type);
  292. int ipc_sysv_movres_callback (IPC_CALLBACK_ARGS);
  293. /* SYSV_MSGSND */
  294. struct shim_ipc_sysv_msgsnd {
  295. IDTYPE msgid;
  296. long msgtype;
  297. char msg[];
  298. } __attribute__((packed));
  299. int ipc_sysv_msgsnd_send (struct shim_ipc_port * port, IDTYPE dest,
  300. IDTYPE msgid, long msgtype,
  301. const void * buf, size_t size, unsigned long seq);
  302. int ipc_sysv_msgsnd_callback (IPC_CALLBACK_ARGS);
  303. /* SYSV_MSGRCV */
  304. struct shim_ipc_sysv_msgrcv {
  305. IDTYPE msgid;
  306. long msgtype;
  307. int size;
  308. int flags;
  309. } __attribute__((packed));
  310. int ipc_sysv_msgrcv_send (IDTYPE msgid, long msgtype, int flags, void * buf,
  311. size_t size);
  312. int ipc_sysv_msgrcv_callback (IPC_CALLBACK_ARGS);
  313. /* SYSV_MSGMOV */
  314. struct shim_ipc_sysv_msgmov {
  315. IDTYPE msgid;
  316. LEASETYPE lease;
  317. unsigned short nscores;
  318. struct sysv_score scores[];
  319. } __attribute__((packed));
  320. int ipc_sysv_msgmov_send (struct shim_ipc_port * port, IDTYPE dest,
  321. IDTYPE msgid, LEASETYPE lease,
  322. struct sysv_score * scores, int nscores);
  323. int ipc_sysv_msgmov_callback (IPC_CALLBACK_ARGS);
  324. /* SYSV_SEMOP */
  325. struct shim_ipc_sysv_semop {
  326. IDTYPE semid;
  327. unsigned long timeout;
  328. int nsops;
  329. struct sembuf sops[];
  330. } __attribute__((packed));
  331. #define IPC_SEM_NOTIMEOUT ((unsigned long) -1)
  332. int ipc_sysv_semop_send (IDTYPE semid, struct sembuf * sops, int nsops,
  333. unsigned long timeout, unsigned long * seq);
  334. int ipc_sysv_semop_callback (IPC_CALLBACK_ARGS);
  335. /* SYSV_SEMCTL */
  336. struct shim_ipc_sysv_semctl {
  337. IDTYPE semid;
  338. int semnum;
  339. int cmd;
  340. int valsize;
  341. unsigned char vals[];
  342. } __attribute__((packed));
  343. int ipc_sysv_semctl_send (IDTYPE semid, int semnum, int cmd, void * vals,
  344. int valsize);
  345. int ipc_sysv_semctl_callback (IPC_CALLBACK_ARGS);
  346. /* SYSV_SEMRET */
  347. struct shim_ipc_sysv_semret {
  348. int valsize;
  349. unsigned char vals[];
  350. } __attribute__((packed));
  351. int ipc_sysv_semret_send (struct shim_ipc_port * port, IDTYPE dest,
  352. void * vals, int valsize, unsigned long seq);
  353. int ipc_sysv_semret_callback (IPC_CALLBACK_ARGS);
  354. /* SYSV_SEMMOV */
  355. struct shim_ipc_sysv_semmov {
  356. IDTYPE semid;
  357. LEASETYPE lease;
  358. unsigned short nsems, nsrcs, nscores;
  359. struct sem_backup sems[];
  360. } __attribute__((packed));
  361. int ipc_sysv_semmov_send (struct shim_ipc_port * port, IDTYPE dest,
  362. IDTYPE semid, LEASETYPE lease,
  363. struct sem_backup * sems, int nsems,
  364. struct sem_client_backup * srcs, int nsrcs,
  365. struct sysv_score * scores, int nscores);
  366. int ipc_sysv_semmov_callback (IPC_CALLBACK_ARGS);
  367. #ifdef USE_SHARED_SEMAPHORE
  368. /* SYSV_SEMQUERY */
  369. struct shim_ipc_sysv_semquery {
  370. IDTYPE semid;
  371. } __attribute__((packed));
  372. int ipc_sysv_semquery_send (IDTYPE semid, int * nsems, PAL_NUM ** host_sem_ids);
  373. int ipc_sysv_semquery_callback (IPC_CALLBACK_ARGS);
  374. /* SYSV_SEMREPLY */
  375. struct shim_ipc_sysv_semreply {
  376. IDTYPE semid;
  377. int nsems;
  378. PAL_NUM host_sem_ids[];
  379. } __attribute__((packed));
  380. int ipc_sysv_semreply_send (struct shim_ipc_port * port, IDTYPE dest,
  381. IDTYPE semid, int nsems, PAL_NUM * host_sem_ids,
  382. unsigned long seq);
  383. int ipc_sysv_semreply_callback (IPC_CALLBACK_ARGS);
  384. #endif
  385. #define IPC_CODE_NUM IPC_SYSV_BOUND
  386. /* functions and routines */
  387. int init_ipc (void);
  388. int init_ipc_helper (void);
  389. struct shim_process * create_new_process (bool inherit_parent);
  390. void destroy_process (struct shim_process * proc);
  391. struct shim_ipc_info * create_ipc_port (IDTYPE vmid, bool listen);
  392. int create_ipc_location (struct shim_ipc_info ** pinfo);
  393. enum {
  394. LISTEN, /* listening */
  395. SERVER, /* connect as a server */
  396. KEEPALIVE, /* keep the connetion alive */
  397. DIRCLD, /* direct child */
  398. DIRPRT, /* direct parent */
  399. NS_PORT_CONSTS(PID)
  400. NS_PORT_CONSTS(SYSV)
  401. };
  402. enum {
  403. IPC_PORT_LISTEN = 1<<LISTEN,
  404. IPC_PORT_SERVER = 1<<SERVER,
  405. IPC_PORT_KEEPALIVE = 1<<KEEPALIVE,
  406. IPC_PORT_DIRCLD = 1<<DIRCLD,
  407. IPC_PORT_DIRPRT = 1<<DIRPRT,
  408. NS_PORT_TYPES(PID)
  409. NS_PORT_TYPES(SYSV)
  410. };
  411. #define IPC_PORT_IFPOLL (IPC_PORT_SERVER|IPC_PORT_LISTEN)
  412. /* general-purpose routines */
  413. void add_ipc_port_by_id (IDTYPE vmid, PAL_HANDLE hdl, int type,
  414. port_fini fini,
  415. struct shim_ipc_port ** portptr);
  416. void add_ipc_port (struct shim_ipc_port * port, IDTYPE vmid, int type,
  417. port_fini fini);
  418. void del_ipc_port_by_id (IDTYPE vm_pid, int type);
  419. void del_ipc_port (struct shim_ipc_port * port, int type);
  420. void del_ipc_port_fini (struct shim_ipc_port * port, unsigned int exitcode);
  421. struct shim_ipc_port * lookup_ipc_port (IDTYPE vmid, int type);
  422. void get_ipc_port (struct shim_ipc_port * port);
  423. void put_ipc_port (struct shim_ipc_port * port);
  424. void del_all_ipc_ports (int type);
  425. struct shim_ipc_info * get_new_ipc_info (IDTYPE vmid, const char * uri,
  426. size_t len);
  427. void get_ipc_info(struct shim_ipc_info * port);
  428. void put_ipc_info(struct shim_ipc_info * port);
  429. struct shim_ipc_info * lookup_and_alloc_client (IDTYPE vmid, const char * uri);
  430. void put_client (struct shim_ipc_info * info);
  431. struct shim_ipc_info * discover_client (struct shim_ipc_port * port,
  432. IDTYPE vmid);
  433. #define IPC_MSG_SIZE(extra) \
  434. ({ int _size = (extra) + sizeof(struct shim_ipc_msg); \
  435. _size > IPC_MSG_MINIMAL_SIZE ? _size : IPC_MSG_MINIMAL_SIZE; })
  436. #define IPC_MSGOBJ_SIZE(extra) \
  437. ({ int _size = (extra) + sizeof(struct shim_ipc_msg); \
  438. (_size > IPC_MSG_MINIMAL_SIZE ? _size : IPC_MSG_MINIMAL_SIZE) + \
  439. (sizeof(struct shim_ipc_msg_obj) - sizeof(struct shim_ipc_msg)); })
  440. int __init_ipc_msg (struct shim_ipc_msg * msg, int code, int size, IDTYPE dest);
  441. struct shim_ipc_msg * create_ipc_msg (int code, int size, IDTYPE dest);
  442. static_inline
  443. struct shim_ipc_msg * create_ipc_msg_on_stack (int code, int size, IDTYPE dest)
  444. {
  445. struct shim_ipc_msg * msg = __alloca(IPC_MSG_SIZE(size));
  446. return (!__init_ipc_msg(msg, code, size, dest)) ? msg : NULL;
  447. }
  448. int __init_ipc_msg_duplex (struct shim_ipc_msg_obj * msg, int code, int size,
  449. IDTYPE dest);
  450. struct shim_ipc_msg_obj *
  451. create_ipc_msg_duplex (int code, int size, IDTYPE dest);
  452. static_inline
  453. struct shim_ipc_msg_obj *
  454. create_ipc_msg_duplex_on_stack (int code, int size, IDTYPE dest)
  455. {
  456. struct shim_ipc_msg_obj * msg = __alloca(IPC_MSGOBJ_SIZE(size));
  457. return (!__init_ipc_msg_duplex(msg, code, size, dest)) ?
  458. msg : NULL;
  459. }
  460. int __init_ipc_resp_msg (struct shim_ipc_msg * resp, int ret,
  461. unsigned long seq);
  462. struct shim_ipc_msg *
  463. create_ipc_resp_msg (int ret, IDTYPE dest, unsigned long seq);
  464. static_inline
  465. struct shim_ipc_msg *
  466. create_ipc_resp_msg_on_stack (int ret, IDTYPE dest, unsigned long seq)
  467. {
  468. struct shim_ipc_msg * resp = create_ipc_msg_on_stack(IPC_RESP,
  469. sizeof(struct shim_ipc_resp), dest);
  470. return (resp && !__init_ipc_resp_msg(resp, ret, seq)) ? resp : NULL;
  471. }
  472. int send_ipc_message (struct shim_ipc_msg * msg, struct shim_ipc_port * port);
  473. int send_ipc_message_duplex (struct shim_ipc_msg_obj * msg,
  474. struct shim_ipc_port * port, bool save,
  475. void * private_data);
  476. int close_ipc_message_duplex (struct shim_ipc_msg_obj * msg,
  477. struct shim_ipc_port * port);
  478. int broadcast_ipc (struct shim_ipc_msg * msg, struct shim_ipc_port ** exclude,
  479. int exsize, int target_type);
  480. struct shim_ipc_msg_obj * find_ipc_msg_duplex (struct shim_ipc_port * port,
  481. unsigned long seq);
  482. int receive_ipc_message (struct shim_ipc_port * port, unsigned long seq,
  483. struct shim_ipc_msg ** msg);
  484. /* for convenience */
  485. int __response_ipc_message (struct shim_ipc_port * port, IDTYPE dest,
  486. int ret, unsigned long seq);
  487. int do_ipc_duplex (struct shim_ipc_msg_obj * msg,
  488. struct shim_ipc_port * port, unsigned long * seq,
  489. void * private_data);
  490. void ipc_parent_exit (struct shim_ipc_port * port, IDTYPE vmid,
  491. unsigned int exitcode);
  492. void ipc_child_exit (struct shim_ipc_port * port, IDTYPE vmid,
  493. unsigned int exitcode);
  494. int exit_with_ipc_helper (bool handover);
  495. #define IPC_FORCE_RECONNECT ((void *) -1)
  496. int prepare_ns_leaders (void);
  497. #endif /* _SHIM_IPC_H_ */