~ubuntu-branches/ubuntu/breezy/knocker/breezy

« back to all changes in this revision

Viewing changes to src/knocker_services.c

  • Committer: Bazaar Package Importer
  • Author(s): Pablo Lorenzzoni
  • Date: 2004-02-23 13:38:39 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20040223133839-8nkw6632is003mrp
Tags: 0.7.1-2
* Upgraded Standard-Version
* Add URL to the description

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* knocker version 0.7.1
 
2
 * Release date: 24 May 2002
 
3
 *
 
4
 * Project homepage: http://knocker.sourceforge.net
 
5
 *
 
6
 * Copyright 2001,2002 Gabriele Giorgetti <g.gabriele79@genie.it>
 
7
 *
 
8
 *
 
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.
 
13
 *
 
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.
 
18
 *
 
19
 * You should have received a copy of the GNU General Public License
 
20
 * along with this program; if not, write to the Free Software
 
21
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
22
*/
 
23
 
 
24
#include <stdio.h>
 
25
#include <string.h>
 
26
#include <stdlib.h>
 
27
 
 
28
#include "knocker_services.h"
 
29
#include "knocker_core.h"
 
30
 
 
31
/* this following list of services has been automatically
 
32
   generated from /etc/services */
 
33
 
 
34
int init_knocker_core_services_db (void)
 
35
{
 
36
#ifdef DEBUG
 
37
  int n_of_services = 0;
 
38
  int i = 0;
 
39
#endif
 
40
 
 
41
/* if it has been already initialized we do anything */
 
42
  if (knocker_core_services_db_init)
 
43
    return 0;
 
44
 
 
45
  knocker_core_services_db_init = 0;
 
46
 
 
47
#ifdef DEBUG
 
48
  fprintf (stderr, "debug: function init_knocker_core_services_db (...) called.\n");
 
49
#endif
 
50
 
 
51
#ifdef DEBUG
 
52
  fprintf (stderr, "debug: allocating memory to store service strings... ");
 
53
#endif
 
54
 
 
55
  knocker_core_services_db[1] = malloc (6 + 1);
 
56
  strcpy (knocker_core_services_db[1], "tcpmux");
 
57
 
 
58
  if (knocker_core_services_db[1] == NULL)
 
59
    return -1;
 
60
 
 
61
  knocker_core_services_db[7] = malloc (4 + 1);
 
62
  strcpy (knocker_core_services_db[7], "echo");
 
63
 
 
64
  if (knocker_core_services_db[7] == NULL)
 
65
    return -1;
 
66
 
 
67
  knocker_core_services_db[9] = malloc (7 + 1);
 
68
  strcpy (knocker_core_services_db[9], "discard");
 
69
 
 
70
  if (knocker_core_services_db[9] == NULL)
 
71
    return -1;
 
72
 
 
73
  knocker_core_services_db[11] = malloc (6 + 1);
 
74
  strcpy (knocker_core_services_db[11], "systat");
 
75
 
 
76
  if (knocker_core_services_db[11] == NULL)
 
77
    return -1;
 
78
 
 
79
  knocker_core_services_db[13] = malloc (7 + 1);
 
80
  strcpy (knocker_core_services_db[13], "daytime");
 
81
 
 
82
  if (knocker_core_services_db[13] == NULL)
 
83
    return -1;
 
84
 
 
85
  knocker_core_services_db[15] = malloc (7 + 1);
 
86
  strcpy (knocker_core_services_db[15], "netstat");
 
87
 
 
88
  if (knocker_core_services_db[15] == NULL)
 
89
    return -1;
 
90
 
 
91
  knocker_core_services_db[17] = malloc (4 + 1);
 
92
  strcpy (knocker_core_services_db[17], "qotd");
 
93
 
 
94
  if (knocker_core_services_db[17] == NULL)
 
95
    return -1;
 
96
 
 
97
  knocker_core_services_db[18] = malloc (3 + 1);
 
98
  strcpy (knocker_core_services_db[18], "msp");
 
99
 
 
100
  if (knocker_core_services_db[18] == NULL)
 
101
    return -1;
 
102
 
 
103
  knocker_core_services_db[19] = malloc (7 + 1);
 
104
  strcpy (knocker_core_services_db[19], "chargen");
 
105
 
 
106
  if (knocker_core_services_db[19] == NULL)
 
107
    return -1;
 
108
 
 
109
  knocker_core_services_db[20] = malloc (8 + 1);
 
110
  strcpy (knocker_core_services_db[20], "ftp-data");
 
111
 
 
112
  if (knocker_core_services_db[20] == NULL)
 
113
    return -1;
 
114
 
 
115
  knocker_core_services_db[21] = malloc (3 + 1);
 
116
  strcpy (knocker_core_services_db[21], "ftp");
 
117
 
 
118
  if (knocker_core_services_db[21] == NULL)
 
119
    return -1;
 
120
 
 
121
  knocker_core_services_db[22] = malloc (3 + 1);
 
122
  strcpy (knocker_core_services_db[22], "ssh");
 
123
 
 
124
  if (knocker_core_services_db[22] == NULL)
 
125
    return -1;
 
126
 
 
127
  knocker_core_services_db[23] = malloc (6 + 1);
 
128
  strcpy (knocker_core_services_db[23], "telnet");
 
129
 
 
130
  if (knocker_core_services_db[23] == NULL)
 
131
    return -1;
 
132
 
 
133
  knocker_core_services_db[25] = malloc (4 + 1);
 
134
  strcpy (knocker_core_services_db[25], "smtp");
 
135
 
 
136
  if (knocker_core_services_db[25] == NULL)
 
137
    return -1;
 
138
 
 
139
  knocker_core_services_db[37] = malloc (4 + 1);
 
140
  strcpy (knocker_core_services_db[37], "time");
 
141
 
 
142
  if (knocker_core_services_db[37] == NULL)
 
143
    return -1;
 
144
 
 
145
  knocker_core_services_db[39] = malloc (3 + 1);
 
146
  strcpy (knocker_core_services_db[39], "rlp");
 
147
 
 
148
  if (knocker_core_services_db[39] == NULL)
 
149
    return -1;
 
150
 
 
151
  knocker_core_services_db[42] = malloc (10 + 1);
 
152
  strcpy (knocker_core_services_db[42], "nameserver");
 
153
 
 
154
  if (knocker_core_services_db[42] == NULL)
 
155
    return -1;
 
156
 
 
157
  knocker_core_services_db[43] = malloc (5 + 1);
 
158
  strcpy (knocker_core_services_db[43], "whois");
 
159
 
 
160
  if (knocker_core_services_db[43] == NULL)
 
161
    return -1;
 
162
 
 
163
  knocker_core_services_db[50] = malloc (10 + 1);
 
164
  strcpy (knocker_core_services_db[50], "re-mail-ck");
 
165
 
 
166
  if (knocker_core_services_db[50] == NULL)
 
167
    return -1;
 
168
 
 
169
  knocker_core_services_db[53] = malloc (6 + 1);
 
170
  strcpy (knocker_core_services_db[53], "domain");
 
171
 
 
172
  if (knocker_core_services_db[53] == NULL)
 
173
    return -1;
 
174
 
 
175
  knocker_core_services_db[57] = malloc (3 + 1);
 
176
  strcpy (knocker_core_services_db[57], "mtp");
 
177
 
 
178
  if (knocker_core_services_db[57] == NULL)
 
179
    return -1;
 
180
 
 
181
  knocker_core_services_db[67] = malloc (6 + 1);
 
182
  strcpy (knocker_core_services_db[67], "bootps");
 
183
 
 
184
  if (knocker_core_services_db[67] == NULL)
 
185
    return -1;
 
186
 
 
187
  knocker_core_services_db[68] = malloc (6 + 1);
 
188
  strcpy (knocker_core_services_db[68], "bootpc");
 
189
 
 
190
  if (knocker_core_services_db[68] == NULL)
 
191
    return -1;
 
192
 
 
193
  knocker_core_services_db[69] = malloc (4 + 1);
 
194
  strcpy (knocker_core_services_db[69], "tftp");
 
195
 
 
196
  if (knocker_core_services_db[69] == NULL)
 
197
    return -1;
 
198
 
 
199
  knocker_core_services_db[70] = malloc (6 + 1);
 
200
  strcpy (knocker_core_services_db[70], "gopher");
 
201
 
 
202
  if (knocker_core_services_db[70] == NULL)
 
203
    return -1;
 
204
 
 
205
  knocker_core_services_db[77] = malloc (3 + 1);
 
206
  strcpy (knocker_core_services_db[77], "rje");
 
207
 
 
208
  if (knocker_core_services_db[77] == NULL)
 
209
    return -1;
 
210
 
 
211
  knocker_core_services_db[79] = malloc (6 + 1);
 
212
  strcpy (knocker_core_services_db[79], "finger");
 
213
 
 
214
  if (knocker_core_services_db[79] == NULL)
 
215
    return -1;
 
216
 
 
217
  knocker_core_services_db[80] = malloc (3 + 1);
 
218
  strcpy (knocker_core_services_db[80], "www");
 
219
 
 
220
  if (knocker_core_services_db[80] == NULL)
 
221
    return -1;
 
222
 
 
223
  knocker_core_services_db[87] = malloc (4 + 1);
 
224
  strcpy (knocker_core_services_db[87], "link");
 
225
 
 
226
  if (knocker_core_services_db[87] == NULL)
 
227
    return -1;
 
228
 
 
229
  knocker_core_services_db[88] = malloc (8 + 1);
 
230
  strcpy (knocker_core_services_db[88], "kerberos");
 
231
 
 
232
  if (knocker_core_services_db[88] == NULL)
 
233
    return -1;
 
234
 
 
235
  knocker_core_services_db[95] = malloc (6 + 1);
 
236
  strcpy (knocker_core_services_db[95], "supdup");
 
237
 
 
238
  if (knocker_core_services_db[95] == NULL)
 
239
    return -1;
 
240
 
 
241
  knocker_core_services_db[98] = malloc (9 + 1);
 
242
  strcpy (knocker_core_services_db[98], "linuxconf");
 
243
 
 
244
  if (knocker_core_services_db[98] == NULL)
 
245
    return -1;
 
246
 
 
247
  knocker_core_services_db[101] = malloc (9 + 1);
 
248
  strcpy (knocker_core_services_db[101], "hostnames");
 
249
 
 
250
  if (knocker_core_services_db[101] == NULL)
 
251
    return -1;
 
252
 
 
253
  knocker_core_services_db[102] = malloc (8 + 1);
 
254
  strcpy (knocker_core_services_db[102], "iso-tsap");
 
255
 
 
256
  if (knocker_core_services_db[102] == NULL)
 
257
    return -1;
 
258
 
 
259
  knocker_core_services_db[105] = malloc (8 + 1);
 
260
  strcpy (knocker_core_services_db[105], "csnet-ns");
 
261
 
 
262
  if (knocker_core_services_db[105] == NULL)
 
263
    return -1;
 
264
 
 
265
  knocker_core_services_db[107] = malloc (7 + 1);
 
266
  strcpy (knocker_core_services_db[107], "rtelnet");
 
267
 
 
268
  if (knocker_core_services_db[107] == NULL)
 
269
    return -1;
 
270
 
 
271
  knocker_core_services_db[109] = malloc (4 + 1);
 
272
  strcpy (knocker_core_services_db[109], "pop2");
 
273
 
 
274
  if (knocker_core_services_db[109] == NULL)
 
275
    return -1;
 
276
 
 
277
  knocker_core_services_db[110] = malloc (4 + 1);
 
278
  strcpy (knocker_core_services_db[110], "pop3");
 
279
 
 
280
  if (knocker_core_services_db[110] == NULL)
 
281
    return -1;
 
282
 
 
283
  knocker_core_services_db[111] = malloc (6 + 1);
 
284
  strcpy (knocker_core_services_db[111], "sunrpc");
 
285
 
 
286
  if (knocker_core_services_db[111] == NULL)
 
287
    return -1;
 
288
 
 
289
  knocker_core_services_db[113] = malloc (4 + 1);
 
290
  strcpy (knocker_core_services_db[113], "auth");
 
291
 
 
292
  if (knocker_core_services_db[113] == NULL)
 
293
    return -1;
 
294
 
 
295
  knocker_core_services_db[115] = malloc (4 + 1);
 
296
  strcpy (knocker_core_services_db[115], "sftp");
 
297
 
 
298
  if (knocker_core_services_db[115] == NULL)
 
299
    return -1;
 
300
 
 
301
  knocker_core_services_db[117] = malloc (9 + 1);
 
302
  strcpy (knocker_core_services_db[117], "uucp-path");
 
303
 
 
304
  if (knocker_core_services_db[117] == NULL)
 
305
    return -1;
 
306
 
 
307
  knocker_core_services_db[119] = malloc (4 + 1);
 
308
  strcpy (knocker_core_services_db[119], "nntp");
 
309
 
 
310
  if (knocker_core_services_db[119] == NULL)
 
311
    return -1;
 
312
 
 
313
  knocker_core_services_db[123] = malloc (3 + 1);
 
314
  strcpy (knocker_core_services_db[123], "ntp");
 
315
 
 
316
  if (knocker_core_services_db[123] == NULL)
 
317
    return -1;
 
318
 
 
319
  knocker_core_services_db[129] = malloc (6 + 1);
 
320
  strcpy (knocker_core_services_db[129], "pwdgen");
 
321
 
 
322
  if (knocker_core_services_db[129] == NULL)
 
323
    return -1;
 
324
 
 
325
  knocker_core_services_db[137] = malloc (10 + 1);
 
326
  strcpy (knocker_core_services_db[137], "netbios-ns");
 
327
 
 
328
  if (knocker_core_services_db[137] == NULL)
 
329
    return -1;
 
330
 
 
331
  knocker_core_services_db[138] = malloc (11 + 1);
 
332
  strcpy (knocker_core_services_db[138], "netbios-dgm");
 
333
 
 
334
  if (knocker_core_services_db[138] == NULL)
 
335
    return -1;
 
336
 
 
337
  knocker_core_services_db[139] = malloc (11 + 1);
 
338
  strcpy (knocker_core_services_db[139], "netbios-ssn");
 
339
 
 
340
  if (knocker_core_services_db[139] == NULL)
 
341
    return -1;
 
342
 
 
343
  knocker_core_services_db[143] = malloc (5 + 1);
 
344
  strcpy (knocker_core_services_db[143], "imap2");
 
345
 
 
346
  if (knocker_core_services_db[143] == NULL)
 
347
    return -1;
 
348
 
 
349
  knocker_core_services_db[161] = malloc (4 + 1);
 
350
  strcpy (knocker_core_services_db[161], "snmp");
 
351
 
 
352
  if (knocker_core_services_db[161] == NULL)
 
353
    return -1;
 
354
 
 
355
  knocker_core_services_db[162] = malloc (9 + 1);
 
356
  strcpy (knocker_core_services_db[162], "snmp-trap");
 
357
 
 
358
  if (knocker_core_services_db[162] == NULL)
 
359
    return -1;
 
360
 
 
361
  knocker_core_services_db[163] = malloc (8 + 1);
 
362
  strcpy (knocker_core_services_db[163], "cmip-man");
 
363
 
 
364
  if (knocker_core_services_db[163] == NULL)
 
365
    return -1;
 
366
 
 
367
  knocker_core_services_db[164] = malloc (10 + 1);
 
368
  strcpy (knocker_core_services_db[164], "cmip-agent");
 
369
 
 
370
  if (knocker_core_services_db[164] == NULL)
 
371
    return -1;
 
372
 
 
373
  knocker_core_services_db[174] = malloc (5 + 1);
 
374
  strcpy (knocker_core_services_db[174], "mailq");
 
375
 
 
376
  if (knocker_core_services_db[174] == NULL)
 
377
    return -1;
 
378
 
 
379
  knocker_core_services_db[177] = malloc (5 + 1);
 
380
  strcpy (knocker_core_services_db[177], "xdmcp");
 
381
 
 
382
  if (knocker_core_services_db[177] == NULL)
 
383
    return -1;
 
384
 
 
385
  knocker_core_services_db[178] = malloc (8 + 1);
 
386
  strcpy (knocker_core_services_db[178], "nextstep");
 
387
 
 
388
  if (knocker_core_services_db[178] == NULL)
 
389
    return -1;
 
390
 
 
391
  knocker_core_services_db[179] = malloc (3 + 1);
 
392
  strcpy (knocker_core_services_db[179], "bgp");
 
393
 
 
394
  if (knocker_core_services_db[179] == NULL)
 
395
    return -1;
 
396
 
 
397
  knocker_core_services_db[191] = malloc (8 + 1);
 
398
  strcpy (knocker_core_services_db[191], "prospero");
 
399
 
 
400
  if (knocker_core_services_db[191] == NULL)
 
401
    return -1;
 
402
 
 
403
  knocker_core_services_db[194] = malloc (3 + 1);
 
404
  strcpy (knocker_core_services_db[194], "irc");
 
405
 
 
406
  if (knocker_core_services_db[194] == NULL)
 
407
    return -1;
 
408
 
 
409
  knocker_core_services_db[199] = malloc (4 + 1);
 
410
  strcpy (knocker_core_services_db[199], "smux");
 
411
 
 
412
  if (knocker_core_services_db[199] == NULL)
 
413
    return -1;
 
414
 
 
415
  knocker_core_services_db[201] = malloc (7 + 1);
 
416
  strcpy (knocker_core_services_db[201], "at-rtmp");
 
417
 
 
418
  if (knocker_core_services_db[201] == NULL)
 
419
    return -1;
 
420
 
 
421
  knocker_core_services_db[202] = malloc (6 + 1);
 
422
  strcpy (knocker_core_services_db[202], "at-nbp");
 
423
 
 
424
  if (knocker_core_services_db[202] == NULL)
 
425
    return -1;
 
426
 
 
427
  knocker_core_services_db[204] = malloc (7 + 1);
 
428
  strcpy (knocker_core_services_db[204], "at-echo");
 
429
 
 
430
  if (knocker_core_services_db[204] == NULL)
 
431
    return -1;
 
432
 
 
433
  knocker_core_services_db[206] = malloc (6 + 1);
 
434
  strcpy (knocker_core_services_db[206], "at-zis");
 
435
 
 
436
  if (knocker_core_services_db[206] == NULL)
 
437
    return -1;
 
438
 
 
439
  knocker_core_services_db[209] = malloc (4 + 1);
 
440
  strcpy (knocker_core_services_db[209], "qmtp");
 
441
 
 
442
  if (knocker_core_services_db[209] == NULL)
 
443
    return -1;
 
444
 
 
445
  knocker_core_services_db[210] = malloc (5 + 1);
 
446
  strcpy (knocker_core_services_db[210], "z3950");
 
447
 
 
448
  if (knocker_core_services_db[210] == NULL)
 
449
    return -1;
 
450
 
 
451
  knocker_core_services_db[213] = malloc (3 + 1);
 
452
  strcpy (knocker_core_services_db[213], "ipx");
 
453
 
 
454
  if (knocker_core_services_db[213] == NULL)
 
455
    return -1;
 
456
 
 
457
  knocker_core_services_db[220] = malloc (5 + 1);
 
458
  strcpy (knocker_core_services_db[220], "imap3");
 
459
 
 
460
  if (knocker_core_services_db[220] == NULL)
 
461
    return -1;
 
462
 
 
463
  knocker_core_services_db[369] = malloc (11 + 1);
 
464
  strcpy (knocker_core_services_db[369], "rpc2portmap");
 
465
 
 
466
  if (knocker_core_services_db[369] == NULL)
 
467
    return -1;
 
468
 
 
469
  knocker_core_services_db[370] = malloc (9 + 1);
 
470
  strcpy (knocker_core_services_db[370], "codaauth2");
 
471
 
 
472
  if (knocker_core_services_db[370] == NULL)
 
473
    return -1;
 
474
 
 
475
  knocker_core_services_db[372] = malloc (9 + 1);
 
476
  strcpy (knocker_core_services_db[372], "ulistserv");
 
477
 
 
478
  if (knocker_core_services_db[372] == NULL)
 
479
    return -1;
 
480
 
 
481
  knocker_core_services_db[389] = malloc (4 + 1);
 
482
  strcpy (knocker_core_services_db[389], "ldap");
 
483
 
 
484
  if (knocker_core_services_db[389] == NULL)
 
485
    return -1;
 
486
 
 
487
  knocker_core_services_db[443] = malloc (5 + 1);
 
488
  strcpy (knocker_core_services_db[443], "https");
 
489
 
 
490
  if (knocker_core_services_db[443] == NULL)
 
491
    return -1;
 
492
 
 
493
  knocker_core_services_db[444] = malloc (4 + 1);
 
494
  strcpy (knocker_core_services_db[444], "snpp");
 
495
 
 
496
  if (knocker_core_services_db[444] == NULL)
 
497
    return -1;
 
498
 
 
499
  knocker_core_services_db[487] = malloc (4 + 1);
 
500
  strcpy (knocker_core_services_db[487], "saft");
 
501
 
 
502
  if (knocker_core_services_db[487] == NULL)
 
503
    return -1;
 
504
 
 
505
  knocker_core_services_db[610] = malloc (10 + 1);
 
506
  strcpy (knocker_core_services_db[610], "npmp-local");
 
507
 
 
508
  if (knocker_core_services_db[610] == NULL)
 
509
    return -1;
 
510
 
 
511
  knocker_core_services_db[611] = malloc (8 + 1);
 
512
  strcpy (knocker_core_services_db[611], "npmp-gui");
 
513
 
 
514
  if (knocker_core_services_db[611] == NULL)
 
515
    return -1;
 
516
 
 
517
  knocker_core_services_db[612] = malloc (8 + 1);
 
518
  strcpy (knocker_core_services_db[612], "hmmp-ind");
 
519
 
 
520
  if (knocker_core_services_db[612] == NULL)
 
521
    return -1;
 
522
 
 
523
  knocker_core_services_db[631] = malloc (3 + 1);
 
524
  strcpy (knocker_core_services_db[631], "ipp");
 
525
 
 
526
  if (knocker_core_services_db[631] == NULL)
 
527
    return -1;
 
528
 
 
529
  knocker_core_services_db[512] = malloc (4 + 1);
 
530
  strcpy (knocker_core_services_db[512], "exec");
 
531
 
 
532
  if (knocker_core_services_db[512] == NULL)
 
533
    return -1;
 
534
 
 
535
  knocker_core_services_db[513] = malloc (5 + 1);
 
536
  strcpy (knocker_core_services_db[513], "login");
 
537
 
 
538
  if (knocker_core_services_db[513] == NULL)
 
539
    return -1;
 
540
 
 
541
  knocker_core_services_db[514] = malloc (5 + 1);
 
542
  strcpy (knocker_core_services_db[514], "shell");
 
543
 
 
544
  if (knocker_core_services_db[514] == NULL)
 
545
    return -1;
 
546
 
 
547
  knocker_core_services_db[515] = malloc (7 + 1);
 
548
  strcpy (knocker_core_services_db[515], "printer");
 
549
 
 
550
  if (knocker_core_services_db[515] == NULL)
 
551
    return -1;
 
552
 
 
553
  knocker_core_services_db[517] = malloc (4 + 1);
 
554
  strcpy (knocker_core_services_db[517], "talk");
 
555
 
 
556
  if (knocker_core_services_db[517] == NULL)
 
557
    return -1;
 
558
 
 
559
  knocker_core_services_db[518] = malloc (5 + 1);
 
560
  strcpy (knocker_core_services_db[518], "ntalk");
 
561
 
 
562
  if (knocker_core_services_db[518] == NULL)
 
563
    return -1;
 
564
 
 
565
  knocker_core_services_db[520] = malloc (5 + 1);
 
566
  strcpy (knocker_core_services_db[520], "route");
 
567
 
 
568
  if (knocker_core_services_db[520] == NULL)
 
569
    return -1;
 
570
 
 
571
  knocker_core_services_db[525] = malloc (5 + 1);
 
572
  strcpy (knocker_core_services_db[525], "timed");
 
573
 
 
574
  if (knocker_core_services_db[525] == NULL)
 
575
    return -1;
 
576
 
 
577
  knocker_core_services_db[526] = malloc (5 + 1);
 
578
  strcpy (knocker_core_services_db[526], "tempo");
 
579
 
 
580
  if (knocker_core_services_db[526] == NULL)
 
581
    return -1;
 
582
 
 
583
  knocker_core_services_db[530] = malloc (7 + 1);
 
584
  strcpy (knocker_core_services_db[530], "courier");
 
585
 
 
586
  if (knocker_core_services_db[530] == NULL)
 
587
    return -1;
 
588
 
 
589
  knocker_core_services_db[531] = malloc (10 + 1);
 
590
  strcpy (knocker_core_services_db[531], "conference");
 
591
 
 
592
  if (knocker_core_services_db[531] == NULL)
 
593
    return -1;
 
594
 
 
595
  knocker_core_services_db[532] = malloc (7 + 1);
 
596
  strcpy (knocker_core_services_db[532], "netnews");
 
597
 
 
598
  if (knocker_core_services_db[532] == NULL)
 
599
    return -1;
 
600
 
 
601
  knocker_core_services_db[533] = malloc (7 + 1);
 
602
  strcpy (knocker_core_services_db[533], "netwall");
 
603
 
 
604
  if (knocker_core_services_db[533] == NULL)
 
605
    return -1;
 
606
 
 
607
  knocker_core_services_db[538] = malloc (6 + 1);
 
608
  strcpy (knocker_core_services_db[538], "gdomap");
 
609
 
 
610
  if (knocker_core_services_db[538] == NULL)
 
611
    return -1;
 
612
 
 
613
  knocker_core_services_db[540] = malloc (4 + 1);
 
614
  strcpy (knocker_core_services_db[540], "uucp");
 
615
 
 
616
  if (knocker_core_services_db[540] == NULL)
 
617
    return -1;
 
618
 
 
619
  knocker_core_services_db[548] = malloc (10 + 1);
 
620
  strcpy (knocker_core_services_db[548], "afpovertcp");
 
621
 
 
622
  if (knocker_core_services_db[548] == NULL)
 
623
    return -1;
 
624
 
 
625
  knocker_core_services_db[556] = malloc (8 + 1);
 
626
  strcpy (knocker_core_services_db[556], "remotefs");
 
627
 
 
628
  if (knocker_core_services_db[556] == NULL)
 
629
    return -1;
 
630
 
 
631
  knocker_core_services_db[543] = malloc (6 + 1);
 
632
  strcpy (knocker_core_services_db[543], "klogin");
 
633
 
 
634
  if (knocker_core_services_db[543] == NULL)
 
635
    return -1;
 
636
 
 
637
  knocker_core_services_db[544] = malloc (6 + 1);
 
638
  strcpy (knocker_core_services_db[544], "kshell");
 
639
 
 
640
  if (knocker_core_services_db[544] == NULL)
 
641
    return -1;
 
642
 
 
643
  knocker_core_services_db[563] = malloc (5 + 1);
 
644
  strcpy (knocker_core_services_db[563], "nntps");
 
645
 
 
646
  if (knocker_core_services_db[563] == NULL)
 
647
    return -1;
 
648
 
 
649
  knocker_core_services_db[636] = malloc (5 + 1);
 
650
  strcpy (knocker_core_services_db[636], "ldaps");
 
651
 
 
652
  if (knocker_core_services_db[636] == NULL)
 
653
    return -1;
 
654
 
 
655
  knocker_core_services_db[655] = malloc (4 + 1);
 
656
  strcpy (knocker_core_services_db[655], "tinc");
 
657
 
 
658
  if (knocker_core_services_db[655] == NULL)
 
659
    return -1;
 
660
 
 
661
  knocker_core_services_db[749] = malloc (12 + 1);
 
662
  strcpy (knocker_core_services_db[749], "kerberos-adm");
 
663
 
 
664
  if (knocker_core_services_db[749] == NULL)
 
665
    return -1;
 
666
 
 
667
  knocker_core_services_db[765] = malloc (7 + 1);
 
668
  strcpy (knocker_core_services_db[765], "webster");
 
669
 
 
670
  if (knocker_core_services_db[765] == NULL)
 
671
    return -1;
 
672
 
 
673
  knocker_core_services_db[873] = malloc (5 + 1);
 
674
  strcpy (knocker_core_services_db[873], "rsync");
 
675
 
 
676
  if (knocker_core_services_db[873] == NULL)
 
677
    return -1;
 
678
 
 
679
  knocker_core_services_db[989] = malloc (9 + 1);
 
680
  strcpy (knocker_core_services_db[989], "ftps-data");
 
681
 
 
682
  if (knocker_core_services_db[989] == NULL)
 
683
    return -1;
 
684
 
 
685
  knocker_core_services_db[990] = malloc (4 + 1);
 
686
  strcpy (knocker_core_services_db[990], "ftps");
 
687
 
 
688
  if (knocker_core_services_db[990] == NULL)
 
689
    return -1;
 
690
 
 
691
  knocker_core_services_db[992] = malloc (7 + 1);
 
692
  strcpy (knocker_core_services_db[992], "telnets");
 
693
 
 
694
  if (knocker_core_services_db[992] == NULL)
 
695
    return -1;
 
696
 
 
697
  knocker_core_services_db[993] = malloc (5 + 1);
 
698
  strcpy (knocker_core_services_db[993], "imaps");
 
699
 
 
700
  if (knocker_core_services_db[993] == NULL)
 
701
    return -1;
 
702
 
 
703
  knocker_core_services_db[994] = malloc (4 + 1);
 
704
  strcpy (knocker_core_services_db[994], "ircs");
 
705
 
 
706
  if (knocker_core_services_db[994] == NULL)
 
707
    return -1;
 
708
 
 
709
  knocker_core_services_db[995] = malloc (5 + 1);
 
710
  strcpy (knocker_core_services_db[995], "pop3s");
 
711
 
 
712
  if (knocker_core_services_db[995] == NULL)
 
713
    return -1;
 
714
 
 
715
  knocker_core_services_db[1080] = malloc (5 + 1);
 
716
  strcpy (knocker_core_services_db[1080], "socks");
 
717
 
 
718
  if (knocker_core_services_db[1080] == NULL)
 
719
    return -1;
 
720
 
 
721
  knocker_core_services_db[1352] = malloc (9 + 1);
 
722
  strcpy (knocker_core_services_db[1352], "lotusnote");
 
723
 
 
724
  if (knocker_core_services_db[1352] == NULL)
 
725
    return -1;
 
726
 
 
727
  knocker_core_services_db[1524] = malloc (10 + 1);
 
728
  strcpy (knocker_core_services_db[1524], "ingreslock");
 
729
 
 
730
  if (knocker_core_services_db[1524] == NULL)
 
731
    return -1;
 
732
 
 
733
  knocker_core_services_db[1525] = malloc (11 + 1);
 
734
  strcpy (knocker_core_services_db[1525], "prospero-np");
 
735
 
 
736
  if (knocker_core_services_db[1525] == NULL)
 
737
    return -1;
 
738
 
 
739
  knocker_core_services_db[1645] = malloc (11 + 1);
 
740
  strcpy (knocker_core_services_db[1645], "datametrics");
 
741
 
 
742
  if (knocker_core_services_db[1645] == NULL)
 
743
    return -1;
 
744
 
 
745
  knocker_core_services_db[1646] = malloc (11 + 1);
 
746
  strcpy (knocker_core_services_db[1646], "sa-msg-port");
 
747
 
 
748
  if (knocker_core_services_db[1646] == NULL)
 
749
    return -1;
 
750
 
 
751
  knocker_core_services_db[1812] = malloc (6 + 1);
 
752
  strcpy (knocker_core_services_db[1812], "radius");
 
753
 
 
754
  if (knocker_core_services_db[1812] == NULL)
 
755
    return -1;
 
756
 
 
757
  knocker_core_services_db[1813] = malloc (11 + 1);
 
758
  strcpy (knocker_core_services_db[1813], "radius-acct");
 
759
 
 
760
  if (knocker_core_services_db[1813] == NULL)
 
761
    return -1;
 
762
 
 
763
  knocker_core_services_db[2101] = malloc (10 + 1);
 
764
  strcpy (knocker_core_services_db[2101], "rtcm-sc104");
 
765
 
 
766
  if (knocker_core_services_db[2101] == NULL)
 
767
    return -1;
 
768
 
 
769
  knocker_core_services_db[2401] = malloc (10 + 1);
 
770
  strcpy (knocker_core_services_db[2401], "cvspserver");
 
771
 
 
772
  if (knocker_core_services_db[2401] == NULL)
 
773
    return -1;
 
774
 
 
775
  knocker_core_services_db[2430] = malloc (5 + 1);
 
776
  strcpy (knocker_core_services_db[2430], "venus");
 
777
 
 
778
  if (knocker_core_services_db[2430] == NULL)
 
779
    return -1;
 
780
 
 
781
  knocker_core_services_db[2431] = malloc (8 + 1);
 
782
  strcpy (knocker_core_services_db[2431], "venus-se");
 
783
 
 
784
  if (knocker_core_services_db[2431] == NULL)
 
785
    return -1;
 
786
 
 
787
  knocker_core_services_db[2432] = malloc (7 + 1);
 
788
  strcpy (knocker_core_services_db[2432], "codasrv");
 
789
 
 
790
  if (knocker_core_services_db[2432] == NULL)
 
791
    return -1;
 
792
 
 
793
  knocker_core_services_db[2433] = malloc (10 + 1);
 
794
  strcpy (knocker_core_services_db[2433], "codasrv-se");
 
795
 
 
796
  if (knocker_core_services_db[2433] == NULL)
 
797
    return -1;
 
798
 
 
799
  knocker_core_services_db[2583] = malloc (3 + 1);
 
800
  strcpy (knocker_core_services_db[2583], "mon");
 
801
 
 
802
  if (knocker_core_services_db[2583] == NULL)
 
803
    return -1;
 
804
 
 
805
  knocker_core_services_db[2628] = malloc (4 + 1);
 
806
  strcpy (knocker_core_services_db[2628], "dict");
 
807
 
 
808
  if (knocker_core_services_db[2628] == NULL)
 
809
    return -1;
 
810
 
 
811
  knocker_core_services_db[3050] = malloc (6 + 1);
 
812
  strcpy (knocker_core_services_db[3050], "gds_db");
 
813
 
 
814
  if (knocker_core_services_db[3050] == NULL)
 
815
    return -1;
 
816
 
 
817
  knocker_core_services_db[3130] = malloc (5 + 1);
 
818
  strcpy (knocker_core_services_db[3130], "icpv2");
 
819
 
 
820
  if (knocker_core_services_db[3130] == NULL)
 
821
    return -1;
 
822
 
 
823
  knocker_core_services_db[3306] = malloc (5 + 1);
 
824
  strcpy (knocker_core_services_db[3306], "mysql");
 
825
 
 
826
  if (knocker_core_services_db[3306] == NULL)
 
827
    return -1;
 
828
 
 
829
  knocker_core_services_db[5002] = malloc (3 + 1);
 
830
  strcpy (knocker_core_services_db[5002], "rfe");
 
831
 
 
832
  if (knocker_core_services_db[5002] == NULL)
 
833
    return -1;
 
834
 
 
835
  knocker_core_services_db[5308] = malloc (8 + 1);
 
836
  strcpy (knocker_core_services_db[5308], "cfengine");
 
837
 
 
838
  if (knocker_core_services_db[5308] == NULL)
 
839
    return -1;
 
840
 
 
841
  knocker_core_services_db[6000] = malloc (3 + 1);
 
842
  strcpy (knocker_core_services_db[6000], "x11");
 
843
 
 
844
  if (knocker_core_services_db[6000] == NULL)
 
845
    return -1;
 
846
 
 
847
  knocker_core_services_db[6001] = malloc (5 + 1);
 
848
  strcpy (knocker_core_services_db[6001], "x11-1");
 
849
 
 
850
  if (knocker_core_services_db[6001] == NULL)
 
851
    return -1;
 
852
 
 
853
  knocker_core_services_db[6002] = malloc (5 + 1);
 
854
  strcpy (knocker_core_services_db[6002], "x11-2");
 
855
 
 
856
  if (knocker_core_services_db[6002] == NULL)
 
857
    return -1;
 
858
 
 
859
  knocker_core_services_db[6003] = malloc (5 + 1);
 
860
  strcpy (knocker_core_services_db[6003], "x11-3");
 
861
 
 
862
  if (knocker_core_services_db[6003] == NULL)
 
863
    return -1;
 
864
 
 
865
  knocker_core_services_db[6004] = malloc (5 + 1);
 
866
  strcpy (knocker_core_services_db[6004], "x11-4");
 
867
 
 
868
  if (knocker_core_services_db[6004] == NULL)
 
869
    return -1;
 
870
 
 
871
  knocker_core_services_db[6005] = malloc (5 + 1);
 
872
  strcpy (knocker_core_services_db[6005], "x11-5");
 
873
 
 
874
  if (knocker_core_services_db[6005] == NULL)
 
875
    return -1;
 
876
 
 
877
  knocker_core_services_db[6006] = malloc (5 + 1);
 
878
  strcpy (knocker_core_services_db[6006], "x11-6");
 
879
 
 
880
  if (knocker_core_services_db[6006] == NULL)
 
881
    return -1;
 
882
 
 
883
  knocker_core_services_db[6007] = malloc (5 + 1);
 
884
  strcpy (knocker_core_services_db[6007], "x11-7");
 
885
 
 
886
  if (knocker_core_services_db[6007] == NULL)
 
887
    return -1;
 
888
 
 
889
  knocker_core_services_db[7000] = malloc (15 + 1);
 
890
  strcpy (knocker_core_services_db[7000], "afs3-fileserver");
 
891
 
 
892
  if (knocker_core_services_db[7000] == NULL)
 
893
    return -1;
 
894
 
 
895
  knocker_core_services_db[7001] = malloc (13 + 1);
 
896
  strcpy (knocker_core_services_db[7001], "afs3-callback");
 
897
 
 
898
  if (knocker_core_services_db[7001] == NULL)
 
899
    return -1;
 
900
 
 
901
  knocker_core_services_db[7002] = malloc (13 + 1);
 
902
  strcpy (knocker_core_services_db[7002], "afs3-prserver");
 
903
 
 
904
  if (knocker_core_services_db[7002] == NULL)
 
905
    return -1;
 
906
 
 
907
  knocker_core_services_db[7003] = malloc (13 + 1);
 
908
  strcpy (knocker_core_services_db[7003], "afs3-vlserver");
 
909
 
 
910
  if (knocker_core_services_db[7003] == NULL)
 
911
    return -1;
 
912
 
 
913
  knocker_core_services_db[7004] = malloc (13 + 1);
 
914
  strcpy (knocker_core_services_db[7004], "afs3-kaserver");
 
915
 
 
916
  if (knocker_core_services_db[7004] == NULL)
 
917
    return -1;
 
918
 
 
919
  knocker_core_services_db[7005] = malloc (11 + 1);
 
920
  strcpy (knocker_core_services_db[7005], "afs3-volser");
 
921
 
 
922
  if (knocker_core_services_db[7005] == NULL)
 
923
    return -1;
 
924
 
 
925
  knocker_core_services_db[7006] = malloc (11 + 1);
 
926
  strcpy (knocker_core_services_db[7006], "afs3-errors");
 
927
 
 
928
  if (knocker_core_services_db[7006] == NULL)
 
929
    return -1;
 
930
 
 
931
  knocker_core_services_db[7007] = malloc (8 + 1);
 
932
  strcpy (knocker_core_services_db[7007], "afs3-bos");
 
933
 
 
934
  if (knocker_core_services_db[7007] == NULL)
 
935
    return -1;
 
936
 
 
937
  knocker_core_services_db[7008] = malloc (11 + 1);
 
938
  strcpy (knocker_core_services_db[7008], "afs3-update");
 
939
 
 
940
  if (knocker_core_services_db[7008] == NULL)
 
941
    return -1;
 
942
 
 
943
  knocker_core_services_db[7009] = malloc (11 + 1);
 
944
  strcpy (knocker_core_services_db[7009], "afs3-rmtsys");
 
945
 
 
946
  if (knocker_core_services_db[7009] == NULL)
 
947
    return -1;
 
948
 
 
949
  knocker_core_services_db[7100] = malloc (12 + 1);
 
950
  strcpy (knocker_core_services_db[7100], "font-service");
 
951
 
 
952
  if (knocker_core_services_db[7100] == NULL)
 
953
    return -1;
 
954
 
 
955
  knocker_core_services_db[22273] = malloc (4 + 1);
 
956
  strcpy (knocker_core_services_db[22273], "wnn6");
 
957
 
 
958
  if (knocker_core_services_db[22273] == NULL)
 
959
    return -1;
 
960
 
 
961
  knocker_core_services_db_init = 1;    /* Initialization complete */
 
962
 
 
963
#ifdef DEBUG
 
964
  fprintf (stderr, "done.\n");
 
965
#endif
 
966
 
 
967
 
 
968
#ifdef DEBUG
 
969
  for (i = 0; i < SERVICES_DB_TOTAL_SERVICES; i++)
 
970
    {
 
971
      if (knocker_core_services_db[i] != NULL)
 
972
        n_of_services++;
 
973
    }
 
974
  fprintf (stderr, "debug: succesfully stored %d service strings.\n", n_of_services);
 
975
#endif
 
976
 
 
977
  return 0;
 
978
}
 
979
 
 
980
 
 
981
void free_knocker_core_services_db (void)
 
982
{
 
983
  int i;
 
984
 
 
985
  /* if it hasn't been initialized yet we don't free anything */
 
986
  if (!knocker_core_services_db_init)
 
987
    return;
 
988
 
 
989
  for (i = 0; i < SERVICES_DB_TOTAL_SERVICES; i++)
 
990
    {
 
991
      if (knocker_core_services_db[i] != NULL)
 
992
        free (knocker_core_services_db[i]);
 
993
    }
 
994
 
 
995
  knocker_core_services_db_init = 0;    /* deinitialized state */
 
996
}
 
997
 
 
998
 
 
999
 
 
1000
/*
 
1001
   ============================================================================
 
1002
   ============================================================================
 
1003
*/
 
1004
char *knocker_core_services_db_get_service (unsigned int port, int protocol)
 
1005
{
 
1006
  int slenght;                  /* string lenght */
 
1007
 
 
1008
  if (!knocker_core_services_db_init)
 
1009
    {
 
1010
      /* if the services string list is not initialized */
 
1011
      return NULL;
 
1012
    }
 
1013
 
 
1014
  if (protocol != PROTO_TCP)
 
1015
    {
 
1016
 
 
1017
      if (protocol != PROTO_UDP)
 
1018
        {
 
1019
          return NULL;
 
1020
        }
 
1021
    }
 
1022
 
 
1023
  /* this functions returns the number of copied chars in tmpstr, if it is
 
1024
     successfull, else -1 */
 
1025
  if (knocker_core_services_db[port] != NULL)
 
1026
    slenght = strlen (knocker_core_services_db[port]);
 
1027
  else
 
1028
    slenght = -1;
 
1029
 
 
1030
  if (slenght == -1)
 
1031
    {
 
1032
      if (knocker_core_last_service == NULL)
 
1033
        {
 
1034
          knocker_core_last_service = malloc (strlen ("unknown") + 1);
 
1035
          strcpy (knocker_core_last_service, "unknown");
 
1036
        }
 
1037
      else
 
1038
        {
 
1039
          knocker_core_last_service = realloc (knocker_core_last_service, strlen ("unknown") + 1);
 
1040
          strcpy (knocker_core_last_service, "unknown");
 
1041
        }
 
1042
      return NULL;
 
1043
    }
 
1044
 
 
1045
 
 
1046
  if (knocker_core_last_service == NULL)
 
1047
    {
 
1048
      knocker_core_last_service = malloc (slenght + 1);
 
1049
    }
 
1050
  else
 
1051
    {
 
1052
      knocker_core_last_service = realloc (knocker_core_last_service, slenght + 1);
 
1053
 
 
1054
    }
 
1055
 
 
1056
  return (strcpy (knocker_core_last_service, knocker_core_services_db[port]));
 
1057
}