Holger Hans Peter Freyther | 9e2c5f5 | 2010-06-15 18:44:42 +0800 | [diff] [blame] | 1 | /* BSC Multiplexer/NAT */ |
| 2 | |
| 3 | /* |
| 4 | * (C) 2010 by Holger Hans Peter Freyther <zecke@selfish.org> |
| 5 | * (C) 2010 by on-waves.com |
| 6 | * All Rights Reserved |
| 7 | * |
| 8 | * This program is free software; you can redistribute it and/or modify |
| 9 | * it under the terms of the GNU General Public License as published by |
| 10 | * the Free Software Foundation; either version 2 of the License, or |
| 11 | * (at your option) any later version. |
| 12 | * |
| 13 | * This program is distributed in the hope that it will be useful, |
| 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 16 | * GNU General Public License for more details. |
| 17 | * |
| 18 | * You should have received a copy of the GNU General Public License along |
| 19 | * with this program; if not, write to the Free Software Foundation, Inc., |
| 20 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
| 21 | * |
| 22 | */ |
| 23 | #include <sys/socket.h> |
| 24 | #include <netinet/in.h> |
| 25 | #include <arpa/inet.h> |
| 26 | |
| 27 | #include <stdio.h> |
| 28 | #include <stdlib.h> |
| 29 | #include <unistd.h> |
| 30 | |
| 31 | #define _GNU_SOURCE |
| 32 | #include <getopt.h> |
| 33 | |
| 34 | #include <openbsc/debug.h> |
| 35 | |
| 36 | static const char *config_file = "openbsc.cfg"; |
| 37 | static char *msc_address = "127.0.0.1"; |
| 38 | static struct in_addr local_addr; |
| 39 | |
| 40 | static void print_usage() |
| 41 | { |
| 42 | printf("Usage: bsc_nat\n"); |
| 43 | } |
| 44 | |
| 45 | static void print_help() |
| 46 | { |
| 47 | printf(" Some useful help...\n"); |
| 48 | printf(" -h --help this text\n"); |
| 49 | printf(" -d option --debug=DRLL:DCC:DMM:DRR:DRSL:DNM enable debugging\n"); |
| 50 | printf(" -s --disable-color\n"); |
| 51 | printf(" -c --config-file filename The config file to use.\n"); |
| 52 | printf(" -m --msc=IP. The address of the MSC.\n"); |
| 53 | printf(" -l --local=IP. The local address of the MGCP.\n"); |
| 54 | } |
| 55 | |
| 56 | static void handle_options(int argc, char** argv) |
| 57 | { |
| 58 | while (1) { |
| 59 | int option_index = 0, c; |
| 60 | static struct option long_options[] = { |
| 61 | {"help", 0, 0, 'h'}, |
| 62 | {"debug", 1, 0, 'd'}, |
| 63 | {"config-file", 1, 0, 'c'}, |
| 64 | {"disable-color", 0, 0, 's'}, |
| 65 | {"timestamp", 0, 0, 'T'}, |
| 66 | {"msc", 1, 0, 'm'}, |
| 67 | {"local", 1, 0, 'l'}, |
| 68 | {0, 0, 0, 0} |
| 69 | }; |
| 70 | |
| 71 | c = getopt_long(argc, argv, "hd:sTPc:m:l:", |
| 72 | long_options, &option_index); |
| 73 | if (c == -1) |
| 74 | break; |
| 75 | |
| 76 | switch (c) { |
| 77 | case 'h': |
| 78 | print_usage(); |
| 79 | print_help(); |
| 80 | exit(0); |
| 81 | case 's': |
| 82 | debug_use_color(0); |
| 83 | break; |
| 84 | case 'd': |
| 85 | debug_parse_category_mask(optarg); |
| 86 | break; |
| 87 | case 'c': |
| 88 | config_file = strdup(optarg); |
| 89 | break; |
| 90 | case 'T': |
| 91 | debug_timestamp(1); |
| 92 | break; |
| 93 | case 'm': |
| 94 | msc_address = strdup(optarg); |
| 95 | break; |
| 96 | case 'l': |
| 97 | inet_aton(optarg, &local_addr); |
| 98 | break; |
| 99 | default: |
| 100 | /* ignore */ |
| 101 | break; |
| 102 | } |
| 103 | } |
| 104 | } |
| 105 | |
| 106 | int main(int argc, char** argv) |
| 107 | { |
| 108 | /* parse options */ |
| 109 | handle_options(argc, argv); |
| 110 | |
| 111 | /* seed the PRNG */ |
| 112 | srand(time(NULL)); |
| 113 | |
| 114 | return 0; |
| 115 | } |