| [361] | 1 | #!/usr/bin/env python | 
|---|
 | 2 |  | 
|---|
 | 3 |  | 
|---|
 | 4 | import dhcp_constants | 
|---|
 | 5 | import dhcp_packet | 
|---|
 | 6 | import dhcp_network | 
|---|
 | 7 |  | 
|---|
 | 8 | import type_hw_addr | 
|---|
 | 9 | import type_ipv4 | 
|---|
 | 10 | import type_strlist | 
|---|
 | 11 |  | 
|---|
 | 12 | import sys | 
|---|
 | 13 |  | 
|---|
 | 14 | from optparse import OptionParser | 
|---|
 | 15 |  | 
|---|
 | 16 |  | 
|---|
 | 17 | parser = OptionParser() | 
|---|
 | 18 |  | 
|---|
 | 19 | """ Action options """ | 
|---|
 | 20 | parser.add_option("-L", "--listen", action="store_true",dest="listen", help="",default="False") | 
|---|
 | 21 | parser.add_option("-E", "--emit",  action="store_true",dest="emit", help="",  default="False") | 
|---|
 | 22 | parser.add_option("-R", "--readable-conversion",  action="store_true",dest="readable", help="", default="False") | 
|---|
 | 23 | parser.add_option("-B", "--binary-conversion",  action="store_true",dest="binary", help="", default="False") | 
|---|
 | 24 |  | 
|---|
 | 25 |  | 
|---|
 | 26 | parser.add_option("-s", "--source-file", action="store",dest="source", help="", default="False", type="string") | 
|---|
 | 27 | parser.add_option("-d", "--destination-file", action="store",dest="destination", help="", default="False", type="string") | 
|---|
 | 28 |  | 
|---|
 | 29 |  | 
|---|
 | 30 |  | 
|---|
 | 31 | (options, args) = parser.parse_args() | 
|---|
 | 32 |  | 
|---|
 | 33 | print options | 
|---|
 | 34 |  | 
|---|
 | 35 |  | 
|---|
 | 36 |  | 
|---|
 | 37 | def 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 |  | 
|---|
 | 49 | def listen(port) : | 
|---|
 | 50 |     pass | 
|---|
 | 51 |  | 
|---|
 | 52 | def emit(address,port) : | 
|---|
 | 53 |     pass | 
|---|
 | 54 |  | 
|---|
 | 55 | def 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 |  | 
|---|
 | 64 | def b_conversion() : | 
|---|
 | 65 |     pass | 
|---|
 | 66 |  | 
|---|
 | 67 | main() | 
|---|