5 Author: Pekka Riikonen <priikone@poseidon.pspt.fi>
7 Copyright (C) 1997 - 2000 Pekka Riikonen
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 2 of the License, or
12 (at your option) any later version.
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
23 * Revision 1.1.1.1 2000/06/27 11:36:55 priikone
24 * Importet from internal CVS/Added Log headers.
29 #include "silcincludes.h"
31 /* Allocates a new socket connection object. The allocated object is
32 returned to the new_socket argument. */
34 void silc_socket_alloc(int sock, SilcSocketType type, void *user_data,
35 SilcSocketConnection *new_socket)
37 SILC_LOG_DEBUG(("Allocating new socket connection object"));
39 *new_socket = silc_calloc(1, sizeof(**new_socket));
40 if (*new_socket == NULL) {
41 SILC_LOG_ERROR(("Could not allocate new socket connection object"));
45 /* Set the pointers. Incoming and outgoing data buffers
46 are allocated by the server when they are first used. */
47 (*new_socket)->sock = sock;
48 (*new_socket)->type = type;
49 (*new_socket)->user_data = user_data;
50 (*new_socket)->protocol = NULL;
51 (*new_socket)->flags = 0;
52 (*new_socket)->inbuf = NULL;
53 (*new_socket)->outbuf = NULL;
56 /* Free's the Socket connection object. */
58 void silc_socket_free(SilcSocketConnection sock)
61 // silc_protocol_free(sock->protocol);
62 silc_buffer_free(sock->inbuf);
63 silc_buffer_free(sock->outbuf);