From 828f125ee5957ee3f64d45329f5ac261a2a3c1a7 Mon Sep 17 00:00:00 2001 From: Paul Kocialkowski Date: Sun, 9 Feb 2014 13:51:38 +0100 Subject: Consistent coding style in helpers Signed-off-by: Paul Kocialkowski --- samsung-ipc/gprs.c | 67 ++++++++++++++++++++++++++++-------------------------- 1 file changed, 35 insertions(+), 32 deletions(-) (limited to 'samsung-ipc/gprs.c') 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 + * Copyright (C) 2014 Paul Kocialkowski * * 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 -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 -- cgit v1.1