/*
 * pipe.h
 *
 * Copyright (C) 2017 Aleksandar Andrejevic <theflash@sdf.lonestar.org>
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as
 * published by the Free Software Foundation, either version 3 of the
 * License, or (at your option) any later version.
 *
 * This program 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 Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

#ifndef __MONOLITHIUM_PIPE_H__
#define __MONOLITHIUM_PIPE_H__

#include "object.h"

#define PIPELINE_REQUEST_ONLY     (1 << 0)
#define PIPELINE_REQUEST_MESSAGE  (1 << 1)
#define PIPELINE_RESPONSE_MESSAGE (1 << 2)

typedef struct
{
    dword_t server_pid;
    dword_t client_pid;
    handle_t request_pipe;
    handle_t response_pipe;
} pipe_connection_t;

sysret_t syscall_create_pipeline(const char *name, dword_t flags, access_flags_t access,  handle_t *handle);
sysret_t syscall_open_pipeline(const char *name, access_flags_t access, handle_t *handle);
sysret_t syscall_listen_pipeline(handle_t handle, dword_t timeout, pipe_connection_t *connection);
sysret_t syscall_connect_pipeline(handle_t handle, access_flags_t access, pipe_connection_t *connection);
sysret_t syscall_read_pipe(handle_t handle, void *buffer, dword_t *size, dword_t timeout);
sysret_t syscall_write_pipe(handle_t handle, void *buffer, dword_t size);

#endif
