From 63bbc710b23893742e5ccbd430f95bf2d29c2da6 Mon Sep 17 00:00:00 2001 From: Jakub Sławiński Date: Thu, 3 Nov 2005 20:37:56 +0100 Subject: v0.7.4 - Fixed: sockets in CLOSE_WAIT state left by afclient - Added: --localname and --localport options - Added: --localdesname option - Added: kicking user in 'opening' state - Fixed: info about kicked user - Fixed: TERM signal handling - Fixed: id lost after reconnection - Fixed: printing wrong client name in 'SSL_accept failed (timeout)' message - Fixed: ignored 'certificate' and 'key' options from config file - Added: config files for afclient - Modified: some options in afserver config file --- src/client_configuration_struct.c | 282 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 282 insertions(+) create mode 100644 src/client_configuration_struct.c (limited to 'src/client_configuration_struct.c') diff --git a/src/client_configuration_struct.c b/src/client_configuration_struct.c new file mode 100644 index 0000000..6de1b5b --- /dev/null +++ b/src/client_configuration_struct.c @@ -0,0 +1,282 @@ +/* + * active port forwarder - software for secure forwarding + * Copyright (C) 2003,2004,2005 jeremian + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + */ + +#include + +#include +#include + +#include "string_functions.h" +#include "client_configuration_struct.h" + +/* + * Function name: ClientConfiguration_new + * Description: Create and initialize new ClientConfiguration structure. + * Returns: Pointer to newly created ClientConfiguration structure. + */ + +ClientConfiguration* +ClientConfiguration_new() +{ + ClientConfiguration* tmp = calloc(1, sizeof(ClientConfiguration)); + if (tmp == NULL) { + return NULL; + } + return tmp; +} + +/* + * Function name: ClientConfiguration_free + * Description: Free the memory allocated for ClientConfiguration structure. + * Arguments: cc - pointer to pointer to ClientConfiguration structure + */ + +void +ClientConfiguration_free(ClientConfiguration** cc) +{ + int i; + if (cc == NULL) { + return; + } + if ((*cc) == NULL) { + return; + } + if ((*cc)->keysFile) { + free((*cc)->keysFile); + (*cc)->keysFile = NULL; + } + if ((*cc)->storeFile) { + free((*cc)->storeFile); + (*cc)->storeFile = NULL; + } + if ((*cc)->realmsTable) { + for (i = 0; i < (*cc)->realmsNumber; ++i) { + if ((*cc)->realmsTable[i]) { + ClientRealm_free(&((*cc)->realmsTable[i])); + } + } + free((*cc)->realmsTable); + (*cc)->realmsTable = NULL; + } + free((*cc)); + (*cc) = NULL; +} + +/* + * Function name: ClientConfiguration_set_keysFile + * Description: Set keys filename. + * Arguments: cc - pointer to ClientConfiguration structure + * keysFile - keys filename + */ + +void +ClientConfiguration_set_keysFile(ClientConfiguration* cc, char* keysFile) +{ + if (cc == NULL) { + return; + } + string_cp(&(cc->keysFile), keysFile); +} + +/* + * Function name: ClientConfiguration_set_storeFile + * Description: Set store filename. + * Arguments: cc - pointer to ClientConfiguration structure + * storeFile - store filename + */ + +void +ClientConfiguration_set_storeFile(ClientConfiguration* cc, char* storeFile) +{ + if (cc == NULL) { + return; + } + string_cp(&(cc->storeFile), storeFile); +} + +/* + * Function name: ClientConfiguration_set_dateFormat + * Description: Set format of the date string. + * Arguments: cc - pointer to ClientConfiguration structure + * dateFormat - format of the date string + */ + +void +ClientConfiguration_set_dateFormat(ClientConfiguration* cc, char* dateFormat) +{ + if (cc == NULL) { + return; + } + string_cp(&(cc->dateFormat), dateFormat); +} + +/* + * Function name: ClientConfiguration_set_realmsNumber + * Description: Set number of realms. + * Arguments: cc - pointer to ClientConfiguration structure + * realmsNumber - number of realms + */ + +void +ClientConfiguration_set_realmsNumber(ClientConfiguration* cc, int realmsNumber) +{ + if (cc == NULL) { + return; + } + cc->realmsNumber = realmsNumber; +} + +/* + * Function name: ClientConfiguration_set_realmsTable + * Description: Set table of realms. + * Arguments: cc - pointer to ClientConfiguration structure + * realmsTable - table of realms + */ + +void +ClientConfiguration_set_realmsTable(ClientConfiguration* cc, ClientRealm** realmsTable) +{ + int i; + if (cc == NULL) { + return; + } + if (cc->realmsTable) { + for (i = 0; i < cc->realmsNumber; ++i) { + if (cc->realmsTable[i]) { + ClientRealm_free(&(cc->realmsTable[i])); + } + } + free(cc->realmsTable); + cc->realmsTable = NULL; + } + cc->realmsTable = realmsTable; +} + +/* + * Function name: ClientConfiguration_set_ignorePublicKeys + * Description: Enable/disable the public keys checking. + * Arguments: cc - pointer to ClientConfiguration structure + * ignorePublicKeys - if the public keys checking is enabled/disabled + */ + +void +ClientConfiguration_set_ignorePublicKeys(ClientConfiguration* cc, char ignorePublicKeys) +{ + if (cc == NULL) { + return; + } + cc->ignorePublicKeys = ignorePublicKeys; +} + +/* + * Function name: ClientConfiguration_get_keysFile + * Description: Get keys filename. + * Arguments: cc - pointer to ClientConfiguration structure + * Returns: Keys filename. + */ + +char* +ClientConfiguration_get_keysFile(ClientConfiguration* cc) +{ + if (cc == NULL) { + return NULL; + } + return cc->keysFile; +} + +/* + * Function name: ClientConfiguration_get_storeFile + * Description: Get store filename. + * Arguments: cc - pointer to ClientConfiguration structure + * Returns: Store filename. + */ + +char* +ClientConfiguration_get_storeFile(ClientConfiguration* cc) +{ + if (cc == NULL) { + return NULL; + } + return cc->storeFile; +} + +/* + * Function name: ClientConfiguration_get_dateFormat + * Description: Get format of the date string. + * Arguments: cc - pointer to ClientConfiguration structure + * Returns: Format of the date string. + */ + +char* +ClientConfiguration_get_dateFormat(ClientConfiguration* cc) +{ + if (cc == NULL) { + return NULL; + } + return cc->dateFormat; +} + +/* + * Function name: ClientConfiguration_get_realmsNumber + * Description: Get number of realms. + * Arguments: cc - pointer to ClientConfiguration structure + * Returns: Number of realms. + */ + +int +ClientConfiguration_get_realmsNumber(ClientConfiguration* cc) +{ + if (cc == NULL) { + return -1; + } + return cc->realmsNumber; +} + +/* + * Function name: ClientConfiguration_get_realmsTable + * Description: Get table of realms. + * Arguments: cc - pointer to ClientConfiguration structure + * Returns: Table of realms. + */ + +ClientRealm** +ClientConfiguration_get_realmsTable(ClientConfiguration* cc) +{ + if (cc == NULL) { + return NULL; + } + return cc->realmsTable; +} + +/* + * Function name: ClientConfiguration_get_ignorePublicKeys + * Description: Check if the public keys checking is enabled/disabled + * Arguments: cc - pointer to ClientConfiguration structure + * Returns: If the public keys checking is enabled/disabled. + */ + +char +ClientConfiguration_get_ignorePublicKeys(ClientConfiguration* cc) +{ + if (cc == NULL) { + return 0; + } + return cc->ignorePublicKeys; +} -- cgit v1.1