source: trunk/packages/sipb-xen-python-pydhcplib/scripts/pydhcp.py @ 1138

Last change on this file since 1138 was 361, checked in by broder, 17 years ago

Splitting pydhcplib off into its own package

Hold onto your hats, folks - this could get messy

File size: 1.6 KB
Line 
1#!/usr/bin/env python
2
3
4import dhcp_constants
5import dhcp_packet
6import dhcp_network
7
8import type_hw_addr
9import type_ipv4
10import type_strlist
11
12import sys
13
14from optparse import OptionParser
15
16
17parser = OptionParser()
18
19""" Action options """
20parser.add_option("-L", "--listen", action="store_true",dest="listen", help="",default="False")
21parser.add_option("-E", "--emit",  action="store_true",dest="emit", help="",  default="False")
22parser.add_option("-R", "--readable-conversion",  action="store_true",dest="readable", help="", default="False")
23parser.add_option("-B", "--binary-conversion",  action="store_true",dest="binary", help="", default="False")
24
25
26parser.add_option("-s", "--source-file", action="store",dest="source", help="", default="False", type="string")
27parser.add_option("-d", "--destination-file", action="store",dest="destination", help="", default="False", type="string")
28
29
30
31(options, args) = parser.parse_args()
32
33print options
34
35
36
37def main() :
38    ActionSum = 0
39    for Action in (options.listen,options.emit,options.readable,options.binary) :
40        if Action == True : ActionSum += 1
41    if ActionSum > 1 :
42        print "Command line error : [-L -E -R -B] Only one of these actions can be taken."
43        sys.exit(0)
44
45    if options.readable == True : r_conversion()
46
47
48
49def listen(port) :
50    pass
51
52def emit(address,port) :
53    pass
54
55def r_conversion() :
56    rawdata = rawdata = sys.stdin.read()
57    while ( len(rawdata)>0 ) :
58        readdata = dhcp_packet.DhcpPacket()
59        readdata.DecodePacket(rawdata)
60        readdata.PrintHeaders()
61        readdata.PrintOptions()
62        rawdata = rawdata = sys.stdin.read()
63
64def b_conversion() :
65    pass
66
67main()
Note: See TracBrowser for help on using the repository browser.