diff options
author | Paul Kocialkowski <contact@paulk.fr> | 2014-08-07 13:12:15 +0200 |
---|---|---|
committer | Paul Kocialkowski <contact@paulk.fr> | 2014-08-07 13:12:15 +0200 |
commit | a7ff1df1869ce543171a6ee92cbf821647b1bf7d (patch) | |
tree | 659e315b3d609f0f9e661d4de21b52077e6e2b81 /srs.h | |
parent | c8408cd2c116b0b99a399282032b6607a1318b84 (diff) | |
download | hardware_ril_samsung-ril-a7ff1df1869ce543171a6ee92cbf821647b1bf7d.zip hardware_ril_samsung-ril-a7ff1df1869ce543171a6ee92cbf821647b1bf7d.tar.gz hardware_ril_samsung-ril-a7ff1df1869ce543171a6ee92cbf821647b1bf7d.tar.bz2 |
Samsung-RIL rewrite: harder, better, probably not faster but definitely stronger
Signed-off-by: Paul Kocialkowski <contact@paulk.fr>
Diffstat (limited to 'srs.h')
-rw-r--r-- | srs.h | 95 |
1 files changed, 75 insertions, 20 deletions
@@ -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 |