/*********************************************************************** * * utils.c * * Utility functions for l2tp * * Copyright (C) 2002 Roaring Penguin Software Inc. * * This software may be distributed under the terms of the GNU General * Public License, Version 2, or (at your option) any later version. * * LIC: GPL * ***********************************************************************/ static char const RCSID[] = "$Id: utils.c,v 1.1.48.1 2005/08/08 12:05:25 honor Exp $"; #include #include #include #include #include #include #include #include #include #include #include #include "l2tp.h" #define MAX_ERRMSG_LEN 512 static int random_fd = -1; static char errmsg[MAX_ERRMSG_LEN]; struct sd_handler { l2tp_shutdown_func f; void *data; }; static struct sd_handler shutdown_handlers[16]; static int n_shutdown_handlers = 0; int l2tp_register_shutdown_handler(l2tp_shutdown_func f, void *data) { if (n_shutdown_handlers == 16) return -1; shutdown_handlers[n_shutdown_handlers].f = f; shutdown_handlers[n_shutdown_handlers].data = data; n_shutdown_handlers++; return n_shutdown_handlers; } void l2tp_cleanup(void) { int i; for (i=0; i