File: mk-constants.py

package info (click to toggle)
python-libpcap 0.6.1%2Bcvs.2007.07.28-2
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 128 kB
  • ctags: 116
  • sloc: ansic: 616; python: 375; makefile: 34
file content (119 lines) | stat: -rw-r--r-- 2,586 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
# $Id: mk-constants.py,v 1.6 2007/07/25 07:25:41 wiml Exp $
#
# Python libpcap
# Copyright (C) 2004,2007 Wim Lewis
# Based on:
#   PY-libpcap (C) 1998, Aaron L. Rhodes
#   constants.i (C) 2001,2002, David Margrave
# 
# This program is free software; you can redistribute it and/or
# modify it under the terms of the BSD Licence. See the file COPYING
# for details.
# 
# 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.

linktypes = (
'DLT_NULL',
'DLT_EN10MB',
'DLT_EN3MB',
'DLT_AX25',
'DLT_PRONET',
'DLT_CHAOS',
'DLT_ARCNET',
'DLT_ARCNET_LINUX',
'DLT_SLIP',
'DLT_SLIP_BSDOS',
'DLT_FDDI',
'DLT_HIPPI',
'DLT_ATM_RFC1483',
'DLT_RAW',
'DLT_PPP',
'DLT_PPP_BSDOS',
'DLT_PPP_SERIAL',
'DLT_PPP_ETHER',
'DLT_C_HDLC',
# 'DLT_CHDLC',   # CHDLC is a compatibility alias for C_HDLC
'DLT_HDLC',
'DLT_ATM_CLIP',
'DLT_IEEE802',
'DLT_IEEE802_11',
'DLT_IEEE802_11_RADIO',
'DLT_IEEE802_11_RADIO_AVS',
'DLT_LOOP',
'DLT_LINUX_SLL',
'DLT_LTALK',
'DLT_ECONET',
'DLT_IPFILTER',
'DLT_PFLOG',
'DLT_PFSYNC',
'DLT_CISCO_IOS',
'DLT_PRISM_HEADER',
'DLT_AIRONET_HEADER',
'DLT_ENC',
'DLT_APPLE_IP_OVER_IEEE1394',
'DLT_AURORA',
'DLT_DOCSIS',
'DLT_FRELAY',
'DLT_IP_OVER_FC',
'DLT_JUNIPER_ATM1',
'DLT_JUNIPER_ATM2',
'DLT_JUNIPER_ES',
'DLT_JUNIPER_GGSN',
'DLT_JUNIPER_MFR',
'DLT_JUNIPER_MLFR',
'DLT_JUNIPER_MLPPP',
'DLT_JUNIPER_MONITOR',
'DLT_JUNIPER_SERVICES',
'DLT_LINUX_IRDA',
'DLT_RIO',
'DLT_SUNATM',
'DLT_SYMANTEC_FIREWALL',
'DLT_TZSP',
'DLT_REDBACK_SMARTEDGE',
'DLT_OLD_PFLOG',
'DLT_HHDLC',
'DLT_PCI_EXP',
'DLT_MTP2_WITH_PHDR',
'DLT_MTP2',
'DLT_MTP3',
'DLT_SCCP',
'DLT_IBM_SP',
'DLT_IBM_SN',
'DLT_BACNET_MS_TP',
'DLT_LINUX_PPP_WITHDIRECTION',
'DLT_JUNIPER_PPPOE',
'DLT_JUNIPER_PPPOE_ATM',
'DLT_GPRS_LLC',
'DLT_GPF_T',
'DLT_GPF_F',
'DLT_GCOM_T1E1',
'DLT_GCOM_SERIAL',
'DLT_JUNIPER_PIC_PEER',
'DLT_ERF_ETH',
'DLT_ERF_POS',
'DLT_LINUX_LAPD',
'DLT_JUNIPER_ETHER',
'DLT_JUNIPER_PPP',
'DLT_JUNIPER_FRELAY',
'DLT_JUNIPER_CHDLC',
)


import string
fp = open('constants.c', 'w')
fp.write('/* Automatically generated from\n')
rcs = '   $Id: mk-constants.py,v 1.6 2007/07/25 07:25:41 wiml Exp $\n'
fp.write(string.replace(rcs, '$', ''))
fp.write('   Do not edit this file directly, it will be overwritten \n*/\n\n')
fp.write('static struct { const char *name; long value; } ')
fp.write(' const pcapmodule_DLT[] = {\n')
for dlt in linktypes:
    fp.write('#ifdef %s\n' % (dlt,))
    fp.write('{ "%s", (%s) },\n' % (dlt,dlt))
    fp.write('#endif\n')
fp.write('{ NULL, 0 }\n};\n')

fp.close()