📄 slconfd.c
字号:
/***************************************************************************** @(#) slconfd.c,v openss7-0_9_2_E(0.9.2.2) 2007/01/21 20:22:41 ----------------------------------------------------------------------------- Copyright (c) 2001-2007 OpenSS7 Corporation <http://www.openss7.com/> Copyright (c) 1997-2000 Brian F. G. Bidulock <bidulock@openss7.org> All Rights Reserved. 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; version 2 of the License. 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., 675 Mass Ave, Cambridge, MA 02139, USA. ----------------------------------------------------------------------------- U.S. GOVERNMENT RESTRICTED RIGHTS. If you are licensing this Software on behalf of the U.S. Government ("Government"), the following provisions apply to you. If the Software is supplied by the Department of Defense ("DoD"), it is classified as "Commercial Computer Software" under paragraph 252.227-7014 of the DoD Supplement to the Federal Acquisition Regulations ("DFARS") (or any successor regulations) and the Government is acquiring only the license rights granted herein (the license rights customarily provided to non-Government users). If the Software is supplied to any unit or agency of the Government other than DoD, it is classified as "Restricted Computer Software" and the Government's rights in the Software are defined in paragraph 52.227-19 of the Federal Acquisition Regulations ("FAR") (or any successor regulations) or, in the cases of NASA, in paragraph 18.52.227-86 of the NASA Supplement to the FAR (or any successor regulations). ----------------------------------------------------------------------------- Commercial licensing and support of this software is available from OpenSS7 Corporation at a fee. See http://www.openss7.com/ ----------------------------------------------------------------------------- Last Modified 2007/01/21 20:22:41 by brian ----------------------------------------------------------------------------- slconfd.c,v Revision 0.9.2.2 2007/01/21 20:22:41 brian - working up drivers Revision 0.9.2.1 2007/01/15 11:33:57 brian - added new and old signalling link utilities *****************************************************************************/#ident "@(#) slconfd.c,v openss7-0_9_2_E(0.9.2.2) 2007/01/21 20:22:41"static char const ident[] = "slconfd.c,v openss7-0_9_2_E(0.9.2.2) 2007/01/21 20:22:41";/* * This is a configuration daemon for the SL-MUX multiplexing driver. Its purpose is to open * Signalling Link streams on various drivers, attach them to specific PPAs, and link the SL * streams under the SL-MUX multiplexing driver, configure each SL lower multiplex Stream, and then * wait in the background listening for management events on a management stream. Also, the daemon * watches for updates for the configuration file and applies the updates as they occur. * * The daemon is intended to run at system startup from a System V init script. Once the * configuration of the SL-MUX multiplexing driver is complete, applications programs can open, * attach, enable and use Signalling Link streams opened on the driver. * * The purpose of the SL-MUX driver is to provide a unified interface for accessing signalling * links of a number of forms and from a number of various drivers. Signalling links could * correspond to device drivers, or could be M2UA or M2PA signalling links, or other * implementations. M2PA signalling links require some additional configuration before they can be * used and will be linked under the SL-MUX by a separate M2PA configuration daemon. * * Another possibility is to implement plugable dlopened modules for various devices. A plugable * module would define its own syntax for the last fields in the configuration file entry (after * the selector). New selectors could then be defined. */#include <stropts.h>#include <stdlib.h>#include <unistd.h>#include <stdio.h>#include <string.h>#include <errno.h>#include <sys/types.h>#include <sys/stat.h>#include <sys/poll.h>#include <sys/time.h>#include <sys/ioctl.h>#include <fcntl.h>#include <getopt.h>#include <time.h>#include <signal.h>#include <syslog.h>#include <sys/utsname.h>#include <ss7/lmi.h>#include <ss7/lmi_ioctl.h>#include <ss7/sdli.h>#include <ss7/sdli_ioctl.h>#include <ss7/sdti.h>#include <ss7/sdti_ioctl.h>#include <ss7/sli.h>#include <ss7/sli_ioctl.h>int output = 1;int debug = 0;#define BUFSIZE 512char cbuf[BUFSIZE];char dbuf[BUFSIZE];struct strbuf ctrl = { sizeof(cbuf), 0, cbuf };struct strbuf data = { sizeof(dbuf), 0, dbuf };struct strioctl ctl;voidcopying(int argc, char *argv[]){ if (!output) return; fprintf(stdout, "\\n\Copyright (c) 2001-2007 OpenSS7 Corporation <http://www.openss7.com/>\n\Copyright (c) 1997-2001 Brian F. G. Bidulock <bidulock@openss7.org>\n\\n\All Rights Reserved.\n\\n\Unauthorized distribution or duplication is prohibited.\n\\n\This software and related documentation is protected by copyright and distribut-\n\ed under licenses restricting its use, copying, distribution and decompilation.\n\No part of this software or related documentation may be reproduced in any form\n\by any means without the prior written authorization of the copyright holder,\n\and licensors, if any.\n\\n\The recipient of this document, by its retention and use, warrants that the re-\n\cipient will protect this information and keep it confidential, and will not\n\disclose the information contained in this document without the written permis-\n\sion of its owner.\n\\n\The author reserves the right to revise this software and documentation for any\n\reason, including but not limited to, conformity with standards promulgated by\n\various agencies, utilization of advances in the state of the technical arts, or\n\the reflection of changes in the design of any techniques, or procedures embod-\n\ied, described, or referred to herein. The author is under no obligation to\n\provide any feature listed herein.\n\\n\As an exception to the above, this software may be distributed under the GNU\n\General Public License (GPL) Version 2, so long as the software is distributed\n\with, and only used for the testing of, OpenSS7 modules, drivers, and libraries.\n\\n\U.S. GOVERNMENT RESTRICTED RIGHTS. If you are licensing this Software on behalf\n\of the U.S. Government (\"Government\"), the following provisions apply to you.\n\If the Software is supplied by the Department of Defense (\"DoD\"), it is classi-\n\fied as \"Commercial Computer Software\" under paragraph 252.227-7014 of the DoD\n\Supplement to the Federal Acquisition Regulations (\"DFARS\") (or any successor\n\regulations) and the Government is acquiring only the license rights granted\n\herein (the license rights customarily provided to non-Government users). If\n\the Software is supplied to any unit or agency of the Government other than DoD,\n\it is classified as \"Restricted Computer Software\" and the Government's rights\n\in the Software are defined in paragraph 52.227-19 of the Federal Acquisition\n\Regulations (\"FAR\") (or any successor regulations) or, in the cases of NASA, in\n\paragraph 18.52.227-86 of the NASA Supplement to the FAR (or any successor\n\regulations).\n\\n\");}voidversion(int argc, char *argv[]){ if (!output) return; fprintf(stdout, "\\n\%1$s:\n\ %2$s\n\ Copyright (c) 2003-2007 OpenSS7 Corporation. All Rights Reserved.\n\\n\ Distributed by OpenSS7 Corporation under GPL Version 2,\n\ incorporated here by reference.\n\\n\ See `%1$s --copying' for copying permission.\n\\n\", argv[0], ident);}voidusage(int argc, char *argv[]){ if (!output) return; fprintf(stderr, "\Usage:\n\ %1$s [options] {{-p, --ppa} PPA | {-c, --clei} CLEI}\n\ %1$s {-h, --help}\n\ %1$s {-V, --version}\n\ %1$s {-C, --copying}\n\", argv[0]);}voidhelp(int argc, char *argv[]){ if (!output) return; fprintf(stdout, "\\n\Usage:\n\ %1$s [options] {{-p, --ppa} PPA | {-c, --clei} CLEI}\n\ %1$s {-h, --help}\n\ %1$s {-V, --version}\n\ %1$s {-C, --copying}\n\Arguments:\n\ (none)\n\General Options:\n\ -q, --quiet (default: off)\n\ suppress output\n\ -v, --verbose (default: off)\n\ increase verbosity of output\n\", argv[0]);}intmain(int argc, char **argv){ int c; int val; while (1) { int option_index = 0; /* *INDENT-OFF* */ static struct option long_options[] = { {"quiet", no_argument, NULL, 'q'}, {"verbose", optional_argument, NULL, 'v'}, {"help", no_argument, NULL, 'h'}, {"version", no_argument, NULL, 'V'}, {"copying", no_argument, NULL, 'C'}, {NULL, 0, NULL, 0 } }; /* *INDENT-ON* */ c = getopt_long(argc, argv, "qvhVC?", long_options, &option_index); if (c == -1) break; switch (c) { case 'q': /* -q, --quiet */ output -= output > 0 ? 1 : output; break; case 'v': /* -v, --versbose */ if (optarg == NULL) { output += 1; break; } if ((val = strtol(optarg, NULL, 0)) < 0) goto bad_option; output = val; break; case 'h': /* -h, --help */ help(argc, argv); exit(0); case 'V': /* -V, --version */ version(argc, argv); exit(0); case 'C': /* -C, --copying */ copying(argc, argv); exit(0); case '?': default: bad_option: // syntax_error: if (optind < argc) { fprintf(stderr, "%s: illegal syntax -- ", argv[0]); for (; optind < argc; optind++) fprintf(stderr, "%s ", argv[optind]); fprintf(stderr, "\n"); } usage(argc, argv); exit(2); } } exit(0);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -