summaryrefslogtreecommitdiffstats
path: root/srs.h
diff options
context:
space:
mode:
Diffstat (limited to 'srs.h')
-rw-r--r--srs.h95
1 files changed, 75 insertions, 20 deletions
diff --git a/srs.h b/srs.h
index 873d764..5dfb4f3 100644
--- a/srs.h
+++ b/srs.h
@@ -1,7 +1,7 @@
/*
* This file is part of Samsung-RIL.
*
- * Copyright (C) 2011-2013 Paul Kocialkowski <contact@paulk.fr>
+ * Copyright (C) 2011-2014 Paul Kocialkowski <contact@paulk.fr>
*
* Samsung-RIL is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -20,39 +20,94 @@
#ifndef _SRS_H_
#define _SRS_H_
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <sys/select.h>
-#include <sys/un.h>
+#include <stdlib.h>
-#include <arpa/inet.h>
-#include <netinet/in.h>
+#include <samsung-ril.h>
-#include <samsung-ril-socket.h>
+/*
+ * Values
+ */
+
+#define SRS_CLIENT_CLOSE 0x00
+#define SRS_SERVER_CLOSE 0x01
+#define SRS_CLIENT_CHANGE 0x02
+#define SRS_CLIENT_IO_ERROR 0x03
-#define SRS_CLIENT_LOCK() pthread_mutex_lock(&srs_client_data->mutex)
-#define SRS_CLIENT_UNLOCK() pthread_mutex_unlock(&srs_client_data->mutex)
+/*
+ * Structures
+ */
-struct srs_client_info {
+struct srs_client {
int fd;
};
-struct srs_client_data {
- struct ril_client *client;
-
+struct srs_data {
int server_fd;
int client_fd;
+ int server_event_fd;
+ int event_fd;
+
+ pthread_t server_thread;
+
struct list_head *clients;
+};
- pthread_t thread;
- pthread_mutex_t mutex;
- int running;
+struct srs_dispatch_handler {
+ unsigned short command;
+ int (*handler)(struct srs_message *message);
};
-extern struct ril_client_funcs srs_client_funcs;
+/*
+ * Helpers
+ */
+
+/* Utils */
+const char *srs_command_string(unsigned short command);
+void srs_log_send(struct ril_client *client, struct srs_message *message);
+void srs_log_recv(struct ril_client *client, struct srs_message *message);
+int srs_header_setup(struct srs_header *header,
+ const struct srs_message *message);
+int srs_message_setup(const struct srs_header *header,
+ struct srs_message *message);
+
+/* SRS */
+int srs_send(unsigned short command, const void *data, size_t size);
+int srs_control_ping(struct srs_message *message);
+
+/* SRS client */
+int srs_client_register(struct ril_client *ril_client, int fd);
+int srs_client_unregister(struct ril_client *ril_client,
+ struct srs_client *client);
+int srs_client_flush(struct ril_client *ril_client);
+struct srs_client *srs_client_find(struct ril_client *ril_client);
+struct srs_client *srs_client_find_fd(struct ril_client *ril_client, int fd);
+struct srs_client *srs_client_find_fd_set(struct ril_client *ril_client,
+ fd_set *fds);
+int srs_client_fd_set_setup(struct ril_client *ril_client, fd_set *fds);
+int srs_client_send(struct ril_client *client, struct srs_message *message);
+int srs_client_recv(struct ril_client *client, struct srs_message *message);
+
+/* SRS server */
+int srs_server_open(struct ril_client *client);
+int srs_server_close(struct ril_client *client);
+int srs_server_loop(struct ril_client *client);
+void *srs_server_thread(void *data);
+
+/* SRS client */
+int srs_create(struct ril_client *client);
+int srs_destroy(struct ril_client *client);
+int srs_open(struct ril_client *client);
+int srs_close(struct ril_client *ril_client);
+int srs_dispatch(struct ril_client *client, struct srs_message *message);
+int srs_loop(struct ril_client *ril_client);
+
+/*
+ * RIL client
+ */
-int srs_send(unsigned short command, void *data, int length);
-void srs_control_ping(struct srs_message *message);
+extern struct ril_client_handlers srs_handlers;
+extern struct ril_client_callbacks srs_callbacks;
+extern struct ril_client srs_client;
#endif