comparison src/common.c @ 22:38d495566d1c

Re-added some debugging messages to nacltai protocol code, enabled by the DEBUG environment variable
author Ivo Smits <Ivo@UCIS.nl>
date Sun, 27 Feb 2011 23:52:32 +0100
parents 1fa5b5fa49e1
children 5ba185ca7102
comparison
equal deleted inserted replaced
21:c1e5af9329f1 22:38d495566d1c
75 extern char* (*getconf)(const char*); 75 extern char* (*getconf)(const char*);
76 extern int errorexit(const char*); 76 extern int errorexit(const char*);
77 extern int errorexitp(const char*); 77 extern int errorexitp(const char*);
78 extern void print_header(); 78 extern void print_header();
79 extern void hex2bin(unsigned char*, unsigned char*, int); 79 extern void hex2bin(unsigned char*, unsigned char*, int);
80 extern int debug;
80 #else 81 #else
81 82
82 char* (*getconf)(const char*) = getenv; 83 char* (*getconf)(const char*) = getenv;
84 int debug = 0;
83 85
84 int errorexit(const char* text) { 86 int errorexit(const char* text) {
85 fprintf(stderr, "%s\n", text); 87 fprintf(stderr, "%s\n", text);
86 return -1; 88 return -1;
87 } 89 }
90 return -1; 92 return -1;
91 } 93 }
92 94
93 void print_header() { 95 void print_header() {
94 fprintf(stderr, "UCIS QuickTun (c) 2010 Ivo Smits <Ivo@UCIS.nl>\n"); 96 fprintf(stderr, "UCIS QuickTun (c) 2010 Ivo Smits <Ivo@UCIS.nl>\n");
95 fprintf(stderr, "More information: http://wiki.qontrol.nl/QuickTun\n"); 97 fprintf(stderr, "More information: http://wiki.ucis.nl/QuickTun\n");
96 } 98 }
97 99
98 int init_udp(struct qtsession* session) { 100 int init_udp(struct qtsession* session) {
99 char* envval; 101 char* envval;
100 fprintf(stderr, "Initializing UDP socket...\n"); 102 fprintf(stderr, "Initializing UDP socket...\n");
187 src++; dest++; 189 src++; dest++;
188 } 190 }
189 } 191 }
190 192
191 int qtrun(struct qtproto* p) { 193 int qtrun(struct qtproto* p) {
194 if (getconf("DEBUG")) debug = 1;
192 struct qtsession session; 195 struct qtsession session;
193 session.protocol = *p; 196 session.protocol = *p;
194 197
195 init_udp(&session); 198 init_udp(&session);
196 int sfd = session.fd_socket; 199 int sfd = session.fd_socket;