summaryrefslogtreecommitdiffstats
path: root/src/common/protocol_private.h
diff options
context:
space:
mode:
authorGravatar Ramūnas Mažeikis <ramunasnezinomas@gmail.com> 2019-05-22 20:33:08 +0300
committerGravatar Ramūnas Mažeikis <ramunasnezinomas@gmail.com> 2019-05-22 20:33:08 +0300
commit28b26ca86cf18947d6d9543ad753ef112ff4da89 (patch)
tree00a9205e36efe91e4229ad1c17750aa6aaf0fa68 /src/common/protocol_private.h
parentf810b277752fc42f3a0e951c7501670a596eb387 (diff)
downloadusurpation-28b26ca86cf18947d6d9543ad753ef112ff4da89.tar.gz
usurpation-28b26ca86cf18947d6d9543ad753ef112ff4da89.tar.bz2
usurpation-28b26ca86cf18947d6d9543ad753ef112ff4da89.zip
Protocol: interface redesign.
Every function is a stub now. Reimplementaion coming up. Signed-off-by: Ramūnas Mažeikis <ramunasnezinomas@gmail.com>
Diffstat (limited to 'src/common/protocol_private.h')
-rw-r--r--src/common/protocol_private.h122
1 files changed, 9 insertions, 113 deletions
diff --git a/src/common/protocol_private.h b/src/common/protocol_private.h
index d50a314..5228afd 100644
--- a/src/common/protocol_private.h
+++ b/src/common/protocol_private.h
@@ -1,115 +1,11 @@
-/*
- * Usurpataion --- server-client protocol private interface.
- *
- * Copyright (C) 2019 Ramūnas Mažeikis
- *
- * This program 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; version 2.1
- * of the License.
- *
- * 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
- */
+#ifndef PROTOCOL_PRIVATE_H
+#define PROTOCOL_PRIVATE_H
-#ifndef PROTOCOL_H_PRIVATE
-#define PROTOCOL_H_PRIVATE
+static int push_string(const char *str);
+static int push_fpi1(const char *num);
+static int push_timestamp(const char *data);
+static int push_request(const char *data);
+static int push_reply(const char *data);
+static int push_uuid(const char *data);
-#include "utils.h"
-
-/**
- * Returns the amount of tlv's int a packet.
- *
- * If a tlv reports length that goes beyond the end of a packet, errno is set
- * to TLV_OVERFLOW. To check this, set errno to 0 first.
- *
- * @param packet data parsed from a packet. Function cannot use raw packets.
- *
- * @return Amount of tlv's in a packet.
- * */
-size_t tlv_count(const struct packet_data * const packet_data);
-
-/**
- * Pushes bytes to outgoing packet and adjusts the offset accordingly.
- *
- * Returns E_PACKET_OVERFLOW, if no more bytes can fit into the packet.
- */
-
-int push_bytes(cd_t cd, const char *data, size_t size);
-
-/**
- * Parses tlv's from packet data and writes them to a buffer of given size.
- *
- * Returns how many tlv's were actually parsed.
- *
- * To check for errors, set errno to 0 and check after calling.
- *
- * Not yet implemented.
- *
- * @param data Data from network packet
- * @param buf Buffer to store parsed tlv's
- * @param buf_size Size of buffer used to store tlv's
- *
- * @return Number of tlv's actually parsed. Greter than or equal to buffer
- * size, if an error occurs.
- * */
-size_t get_tlvs( const struct packet_data * const data,
- const struct tlv *buf,
- size_t buf_size);
-
-/** Takes a null-terminated string and appends it to the next outgoing packet.
- *
- * @return Returns 0 on success. Otherwise: E_PACKET_OVERFLOW.
- *
- * */
-int push_string(cd_t connection, char *str);
-
-/** Reinterprets char * as fpi1_t * and appends it to the outgoing packet as a
- * tlv.
- */
-int push_fpi1(cd_t connection, char *num);
-
-/** Reinterprets char * as time_t * and appends it to the outgoing packet as a
- * tlv.
- */
-int push_timestamp(cd_t connection, char *data);
-
-/**
- * Pushes a request for daemon to repeat a message identified by a msg_index_t.
- *
- * @param data Pointer to a msg_index_t.
- *
- * @return 0 on success or E_PACKET_OVERFLOW, if not enough space is available
- * to push all the data.
- */
-int push_request(cd_t connection, char *data);
-
-/**
- * Pushes a message to the outgoing packet buffer as a reply. A reply is just
- * a null terminated string.
- *
- * @param data msg_idx_t representing sequence number since beggining of
- * connection and a null-terminated string.
- *
- * @return On success --- 0 or E_PACKET_OVERFLOW, if not enough buffer is
- * available.
- */
-int push_reply(cd_t connection, char *data);
-
-/** Reinterprets char * as uuid_t * and appends it to the outgoing packet as a
- * tlv.
- */
-int push_uuid(cd_t connection, char *data);
-
-/* Appends tlv_type and size of data to a packet effectively creating a tlv
- * header.
- */
-int push_tlv_header(cd_t connection, enum tlv_type type, size_t size);
-
-#endif /* PROTOCOL_H_PRIVATE */
+#endif /* PROTOCOL_PRIVATE_H */ \ No newline at end of file