diff options
author | Paul Kocialkowski <contact@paulk.fr> | 2014-02-09 13:51:38 +0100 |
---|---|---|
committer | Paul Kocialkowski <contact@paulk.fr> | 2014-02-09 13:51:38 +0100 |
commit | 828f125ee5957ee3f64d45329f5ac261a2a3c1a7 (patch) | |
tree | 7cb2c2433a4fae20f660dd60819350034ea1ebeb /samsung-ipc/gprs.c | |
parent | 6cb0b59e3f0a7b8f2c9690b7e8d171d88d000270 (diff) | |
download | hardware_replicant_libsamsung-ipc-828f125ee5957ee3f64d45329f5ac261a2a3c1a7.tar.gz hardware_replicant_libsamsung-ipc-828f125ee5957ee3f64d45329f5ac261a2a3c1a7.tar.bz2 hardware_replicant_libsamsung-ipc-828f125ee5957ee3f64d45329f5ac261a2a3c1a7.zip |
Consistent coding style in helpers
Signed-off-by: Paul Kocialkowski <contact@paulk.fr>
Diffstat (limited to 'samsung-ipc/gprs.c')
-rw-r--r-- | samsung-ipc/gprs.c | 67 |
1 files changed, 35 insertions, 32 deletions
diff --git a/samsung-ipc/gprs.c b/samsung-ipc/gprs.c index 7c14df9..a7c0bc1 100644 --- a/samsung-ipc/gprs.c +++ b/samsung-ipc/gprs.c @@ -2,6 +2,7 @@ * This file is part of libsamsung-ipc. * * Copyright (C) 2011 Simon Busch <morphis@gravedo.de> + * Copyright (C) 2014 Paul Kocialkowski <contact@paulk.fr> * * libsamsung-ipc is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -22,54 +23,56 @@ #include <samsung-ipc.h> -void ipc_gprs_port_list_setup(struct ipc_gprs_port_list_data *message) +int ipc_gprs_define_pdp_context_setup(struct ipc_gprs_define_pdp_context_data *data, + unsigned char enable, unsigned char cid, const char *apn) { - // FIXME: These are only known-to-work values used on most devices - unsigned char bytes[] = { - 0x02, 0x04, 0x16, 0x00, 0x17, 0x00, 0x87, 0x00, 0xBD, 0x01 - }; + if (data == NULL || apn == NULL) + return -1; - if (message == NULL) - return; + memset(data, 0, sizeof(struct ipc_gprs_define_pdp_context_data)); + data->enable = enable; + data->cid = cid; + data->magic = 0x02; - memset(message, 0, sizeof(struct ipc_gprs_port_list_data)); + strncpy((char *) data->apn, apn, sizeof(data->apn)); - memcpy(message->magic, bytes, sizeof(bytes)); + return 0; } -void ipc_gprs_define_pdp_context_setup(struct ipc_gprs_define_pdp_context_data *message, - unsigned char cid, int enable, char *apn) +int ipc_gprs_pdp_context_request_set_setup(struct ipc_gprs_pdp_context_request_set_data *data, + unsigned char enable, unsigned char cid, const char *username, + const char *password) { - if (message == NULL) - return; + if (data == NULL) + return -1; + + memset(data, 0, sizeof(struct ipc_gprs_pdp_context_request_set_data)); + data->enable = enable; + data->cid = cid; - memset(message, 0, sizeof(struct ipc_gprs_define_pdp_context_data)); + if (enable && username != NULL && password != NULL) { + data->magic1[2] = 0x13; + data->magic2 = 0x01; - message->enable = enable ? 1 : 0; - message->cid = cid; - message->magic = 0x2; + strncpy((char *) data->username, username, sizeof(data->username)); + strncpy((char *) data->password, password, sizeof(data->password)); + } - strncpy((char *) message->apn, apn, 124); + return 0; } -void ipc_gprs_pdp_context_request_set_setup(struct ipc_gprs_pdp_context_request_set_data *message, - unsigned char cid, int enable, char *username, char *password) +int ipc_gprs_port_list_setup(struct ipc_gprs_port_list_data *data) { - if (message == NULL) - return; + // FIXME: These are only known-to-work values used on most devices + unsigned char magic[] = { 0x02, 0x04, 0x16, 0x00, 0x17, 0x00, 0x87, 0x00, 0xBD, 0x01 }; - memset(message, 0, sizeof(struct ipc_gprs_pdp_context_request_set_data)); + if (data == NULL) + return -1; - message->enable = enable ? 1 : 0; - message->cid = cid; + memset(data, 0, sizeof(struct ipc_gprs_port_list_data)); + memcpy(data->magic, magic, sizeof(magic)); - if (enable && username != NULL && password != NULL) - { - message->magic[2] = 0x13; - message->unknown2 = 0x1; - strncpy((char *) message->username, username, 32); - strncpy((char *) message->password, password, 32); - } + return 0; } // vim:ts=4:sw=4:expandtab |