def get_net_from_cidr(self): if self.subnet.network_address != '': self.clear_and_reset() else: self.subnet.cidr_address = self.cidr_entry.get() if self.subnet.verify_variables(): self.subnet.calculate_network_address_from_cidr() step1 = Label(self.learning_steps, text='Step 1:') cidr_address = Label(self.learning_steps, text='CIDR Address: {}'.format( self.subnet.cidr_address)) step2 = Label(self.learning_steps, text='Step 2:') network = Label(self.learning_steps, text='Network Address: {}'.format( self.subnet.network_address)) step1.grid(row=0, column=0, sticky='W') cidr_address.grid(row=0, column=1, sticky='W') step2.grid(row=1, column=0, sticky='W') network.grid(row=1, column=1, sticky='W') else: self.clear_and_reset() HelpGUI()
def get_net_from_ip_range(self): if self.subnet.network_address != '': self.clear_and_reset() else: self.subnet.ip_range = self.ip_range_entry.get() if self.subnet.verify_variables(): self.subnet.calculate_network_address_from_ip_range() steps = self.subnet.network_address_steps step1 = Label(self.learning_steps, text='Step 1:') ip_range = Label(self.learning_steps, text='Assignable IP Range: {}'.format( self.subnet.ip_range)) step2 = Label(self.learning_steps, text='Step 2:') front = Label(self.learning_steps, text='(Front - 1): {}'.format( steps[0]['Front - 1'])) step3 = Label(self.learning_steps, text='Step 3:') network = Label(self.learning_steps, text='Network Address: {}'.format( self.subnet.network_address)) step1.grid(row=0, column=0, sticky='W') ip_range.grid(row=0, column=1, sticky='W') step2.grid(row=1, column=0, sticky='W') front.grid(row=1, column=1, sticky='W') step3.grid(row=2, column=0, sticky='W') network.grid(row=2, column=1, sticky='W') else: self.clear_and_reset() HelpGUI()
def get_entries(self): if self.subnet.cidr_address != '': self.clear_entries() self.subnet.reset_variables() else: self.subnet.cidr_address = self.cidr_entry.get() self.subnet.network_address = self.network_entry.get() self.subnet.netmask = self.netmask_entry.get() self.subnet.broadcast_address = self.broadcast_entry.get() self.subnet.ip_range = self.ip_range_entry.get() self.subnet.total_host_count = self.total_host_entry.get() self.subnet.assignable_host_count = self.assignable_host_entry.get( ) self.clear_entries() if self.subnet.verify_variables(): self.subnet.general_calculation() self.cidr_entry.insert(0, self.subnet.cidr_address) self.network_entry.insert(0, self.subnet.network_address) self.netmask_entry.insert(0, self.subnet.netmask) self.broadcast_entry.insert(0, self.subnet.broadcast_address) self.ip_range_entry.insert(0, self.subnet.ip_range) self.total_host_entry.insert(0, str(self.subnet.total_host_count)) self.assignable_host_entry.insert( 0, str(self.subnet.assignable_host_count)) else: self.clear_entries() self.subnet.reset_variables() HelpGUI()
def get_broadcast_from_ip_range(self): if self.subnet.broadcast_address != '': self.clear_and_reset() else: self.subnet.ip_range = self.ip_range_entry.get() if self.subnet.verify_variables(): self.subnet.calculate_broadcast_address_from_ip_range() steps = self.subnet.broadcast_address_steps step1 = Label(self.learning_steps, text='Step 1:') ip_range = Label(self.learning_steps, text='Assignable IP Range: {}'.format( self.subnet.ip_range)) step2 = Label(self.learning_steps, text='Step 2:') back = Label(self.learning_steps, text='(Back + 1): {}'.format( steps[0]['Back + 1'])) step3 = Label(self.learning_steps, text='Step 3:') broadcast = Label(self.learning_steps, text='Broadcast Address: {}'.format( self.subnet.broadcast_address)) step1.grid(row=0, column=0, sticky='W') ip_range.grid(row=0, column=1, sticky='W') step2.grid(row=1, column=0, sticky='W') back.grid(row=1, column=1, sticky='W') step3.grid(row=2, column=0, sticky='W') broadcast.grid(row=2, column=1, sticky='W') else: self.clear_and_reset() HelpGUI()
def get_broadcast_from_cidr(self): if self.subnet.broadcast_address != '': self.clear_and_reset() else: self.subnet.cidr_address = self.cidr_entry.get() if self.subnet.verify_variables(): self.subnet.calculate_broadcast_address_from_cidr() steps = self.subnet.broadcast_address_steps step1 = Label(self.learning_steps, text='Step 1:') cidr_address = Label(self.learning_steps, text='CIDR Address: {}'.format( self.subnet.cidr_address)) step2 = Label(self.learning_steps, text='Step 2:') cidr = Label(self.learning_steps, text='CIDR: {}'.format(steps[0]['CIDR'])) host = Label(self.learning_steps, text='Host Bits: 32 - {} = {}'.format( steps[0]['CIDR'], (32 - int(steps[0]['CIDR'])))) step3 = Label(self.learning_steps, text='Step 3:') net_binary = Label(self.learning_steps, text='Network Binary: {}'.format( steps[0]['Network Binary'])) step4 = Label(self.learning_steps, text='Step 4:') broadcast_binary = Label(self.learning_steps, text='Broadcast Binary: {}'.format( steps[1]['Broadcast Binary'])) step5 = Label(self.learning_steps, text='Step 5:') broadcast = Label(self.learning_steps, text='Broadcast Address: {}'.format( self.subnet.broadcast_address)) step1.grid(row=0, column=0, sticky='W') cidr_address.grid(row=0, column=1, columnspan=2, sticky='W') step2.grid(row=1, column=0, sticky='W') cidr.grid(row=1, column=1, sticky='W') host.grid(row=1, column=2, sticky='W') step3.grid(row=2, column=0, sticky='W') net_binary.grid(row=2, column=1, columnspan=2, sticky='W') step4.grid(row=3, column=0, sticky='W') broadcast_binary.grid(row=3, column=1, columnspan=2, sticky='W') step5.grid(row=4, column=0, sticky='W') broadcast.grid(row=4, column=1, columnspan=2, sticky='W') else: self.clear_and_reset() HelpGUI()
def get_cidr_from_ip_range(self): if self.subnet.cidr_address != '': self.clear_and_reset() else: self.subnet.network_address = self.net_address_entry2.get() self.subnet.ip_range = self.ip_range_entry.get() if self.subnet.network_address != '' and self.subnet.ip_range != '' and self.subnet.verify_variables( ): self.subnet.calculate_cidr_from_ip_range() steps = self.subnet.cidr_address_steps step1 = Label(self.learning_steps, text='Step 1:') network = Label(self.learning_steps, text='Network Address: {}'.format( self.subnet.network_address)) ip_range = Label(self.learning_steps, text='Assignable IP Range: {}'.format( self.subnet.ip_range)) step2 = Label(self.learning_steps, text='Step 2:') front = Label(self.learning_steps, text='Front: {}'.format(steps[0]['Front'])) back = Label(self.learning_steps, text=' Back: {}'.format(steps[0]['Back'])) step3 = Label(self.learning_steps, text='Step 3:') comparison = Label(self.learning_steps, text='Comparison: {}'.format( steps[1]['Comparison'])) step4 = Label(self.learning_steps, text='Step 4:') cidr = Label(self.learning_steps, text='CIDR: {}'.format(steps[2]['CIDR'])) step5 = Label(self.learning_steps, text='Step 5:') cidr_address = Label(self.learning_steps, text='CIDR Address: {}'.format( self.subnet.cidr_address)) step1.grid(row=0, column=0, sticky='W') network.grid(row=0, column=1, sticky='W') ip_range.grid(row=1, column=1, sticky='W') step2.grid(row=2, column=0, sticky='W') front.grid(row=2, column=1, sticky='W') back.grid(row=3, column=1, sticky='W') step3.grid(row=4, column=0, sticky='W') comparison.grid(row=4, column=1, columnspan=2, sticky='W') step4.grid(row=5, column=0, sticky='W') cidr.grid(row=5, column=1, sticky='W') step5.grid(row=6, column=0, sticky='W') cidr_address.grid(row=6, column=1, sticky='W') else: self.clear_and_reset() HelpGUI()
def get_count_from_ip_range(self): if self.subnet.assignable_host_count != '': self.clear_and_reset() else: self.subnet.ip_range = self.ip_range_entry.get() if self.subnet.verify_variables(): self.subnet.calculate_assignable_host_count_from_ip_range() steps = self.subnet.assignable_host_count_steps step1 = Label(self.learning_steps, text='Step 1:') ip_range = Label(self.learning_steps, text='Assignable IP Range: {}'.format( self.subnet.ip_range)) step2 = Label(self.learning_steps, text='Step 2:') front = Label(self.learning_steps, text='Front: {}'.format(steps[0]['Front'])) back = Label(self.learning_steps, text=' Back: {}'.format(steps[0]['Back'])) step3 = Label(self.learning_steps, text='Step 3:') comparison = Label(self.learning_steps, text='Comparison: {}'.format( steps[1]['Comparison'])) step4 = Label(self.learning_steps, text='Step 4:') host = Label(self.learning_steps, text='Host Bits: {}'.format( steps[2]['Host Bits'])) step5 = Label(self.learning_steps, text='Step 5:') count = Label( self.learning_steps, text='Assignable Host Count: ( 2{} ) - 2 = {}'.format( exponent(str(steps[2]['Host Bits'])), self.subnet.assignable_host_count)) step1.grid(row=0, column=0, sticky='W') ip_range.grid(row=0, column=1, sticky='W') step2.grid(row=1, column=0, sticky='W') front.grid(row=1, column=1, sticky='W') back.grid(row=2, column=1, sticky='W') step3.grid(row=3, column=0, sticky='W') comparison.grid(row=3, column=1, sticky='W') step4.grid(row=4, column=0, sticky='W') host.grid(row=4, column=1, sticky='W') step5.grid(row=5, column=0, sticky='W') count.grid(row=5, column=1, sticky='W') else: self.clear_and_reset() HelpGUI()
def get_cidr_from_netmask(self): if self.subnet.cidr_address != '': self.clear_and_reset() else: self.subnet.network_address = self.net_address_entry.get() self.subnet.netmask = self.netmask_entry.get() if self.subnet.network_address != '' and self.subnet.netmask != '' and self.subnet.verify_variables( ): self.subnet.calculate_cidr_from_netmask() steps = self.subnet.cidr_address_steps step1 = Label(self.learning_steps, text='Step 1:') network = Label(self.learning_steps, text='Network Address: {}'.format( self.subnet.network_address)) netmask = Label(self.learning_steps, text='NetMask: {}'.format(self.subnet.netmask)) step2 = Label(self.learning_steps, text='Step 2:') binary = Label(self.learning_steps, text='Netmask Binary: {}'.format( steps[0]['Netmask Binary'])) step3 = Label(self.learning_steps, text='Step 3:') count = Label(self.learning_steps, text="(Count 0's from Step 2)") cidr = Label(self.learning_steps, text='CIDR: {}'.format(steps[1]['CIDR'])) step4 = Label(self.learning_steps, text='Step 4:') cidr_address = Label(self.learning_steps, text='CIDR Address: {}'.format( self.subnet.cidr_address)) step1.grid(row=0, column=0, sticky='W') network.grid(row=0, column=1, sticky='W') netmask.grid(row=0, column=2, sticky='W') step2.grid(row=1, column=0, sticky='W') binary.grid(row=1, column=1, columnspan=2, sticky='W') step3.grid(row=2, column=0, sticky='W') count.grid(row=2, column=1, sticky='W') cidr.grid(row=2, column=2, sticky='W') step4.grid(row=3, column=0, sticky='W') cidr_address.grid(row=3, column=1, sticky='W') else: self.clear_and_reset() HelpGUI()
def get_count_from_total(self): if self.subnet.assignable_host_count != '': self.clear_and_reset() else: self.subnet.total_host_count = self.total_entry.get() if self.subnet.verify_variables(): self.subnet.calculate_assignable_host_count() step1 = Label(self.learning_steps, text='Step 1:') count = Label(self.learning_steps, text='Assignable Host Count: {} - 2 = {}'.format( self.subnet.total_host_count, self.subnet.assignable_host_count)) step1.grid(row=0, column=0, sticky='W') count.grid(row=0, column=1, sticky='W') else: self.clear_and_reset() HelpGUI()
def get_ip_range_from_cidr(self): if self.subnet.ip_range != '': self.clear_and_reset() else: self.subnet.cidr_address = self.cidr_entry.get() if self.subnet.verify_variables(): self.subnet.calculate_ip_range_from_cidr() steps = self.subnet.ip_range_steps step1 = Label(self.learning_steps, text='Step 1:') cidr_address = Label(self.learning_steps, text='CIDR Address: {}'.format(self.subnet.cidr_address)) step2 = Label(self.learning_steps, text='Step 2:') front = Label(self.learning_steps, text='Front: {}'.format(steps[0]['Front'])) step3 = Label(self.learning_steps, text='Step 3:') cidr = Label(self.learning_steps, text='CIDR: {}'.format(steps[1]['CIDR'])) host = Label(self.learning_steps, text='Host Bits: 32 - {} = {}'.format(steps[1]['CIDR'], (32 - int(steps[1]['CIDR'])))) step4 = Label(self.learning_steps, text='Step 4:') net_binary = Label(self.learning_steps, text='Network Binary: {}'.format(steps[1]['Network Binary'])) step5 = Label(self.learning_steps, text='Step 5:') back_binary = Label(self.learning_steps, text='Back Binary (Broadcast - 1): {}'.format(steps[2]['Back Binary'])) step6 = Label(self.learning_steps, text='Step 6:') ip_range = Label(self.learning_steps, text='Assignable IP Range: {}'.format(self.subnet.ip_range)) step1.grid(row=0, column=0, sticky='W') cidr_address.grid(row=0, column=1, columnspan=2, sticky='W') step2.grid(row=1, column=0, sticky='W') front.grid(row=1, column=1, columnspan=2, sticky='W') step3.grid(row=2, column=0, sticky='W') cidr.grid(row=2, column=1, sticky='W') host.grid(row=2, column=2, sticky='W') step4.grid(row=3, column=0, sticky='W') net_binary.grid(row=3, column=1, columnspan=2, sticky='W') step5.grid(row=4, column=0, sticky='W') back_binary.grid(row=4, column=1, columnspan=2, sticky='W') step6.grid(row=5, column=0, sticky='W') ip_range.grid(row=5, column=1, columnspan=2, sticky='W') else: self.clear_and_reset() HelpGUI()
def get_net_from_cidr(self): if self.subnet.netmask != '': self.clear_and_reset() else: self.subnet.cidr_address = self.cidr_entry.get() if self.subnet.verify_variables(): self.subnet.calculate_netmask_from_cidr() steps = self.subnet.netmask_steps step1 = Label(self.learning_steps, text='Step 1:') cidr_address = Label(self.learning_steps, text='CIDR Address: {}'.format( self.subnet.cidr_address)) step2 = Label(self.learning_steps, text='Step 2:') net_bits = Label(self.learning_steps, text='Network Bits: {}'.format( steps[0]['Network Bits'])) host_bits = Label(self.learning_steps, text='Host Bits: {}'.format( steps[0]['Host Bits'])) step3 = Label(self.learning_steps, text='Step 3:') mask_binary = Label(self.learning_steps, text='Netmask Binary: {}'.format( steps[1]['Netmask Binary'])) step4 = Label(self.learning_steps, text='Step 4:') netmask = Label(self.learning_steps, text='Netmask: {}'.format(self.subnet.netmask)) step1.grid(row=0, column=0, sticky='W') cidr_address.grid(row=0, column=1, sticky='W') step2.grid(row=1, column=0, sticky='W') net_bits.grid(row=1, column=1, sticky='W') host_bits.grid(row=1, column=2, sticky='W') step3.grid(row=2, column=0, sticky='W') mask_binary.grid(row=2, column=1, columnspan=2, sticky='W') step4.grid(row=3, column=0, sticky='W') netmask.grid(row=3, column=1, sticky='W') else: self.clear_and_reset() HelpGUI()
def get_net_from_ip_range(self): if self.subnet.netmask != '': self.clear_and_reset() else: self.subnet.ip_range = self.ip_range_entry.get() if self.subnet.verify_variables(): self.subnet.calculate_netmask_from_ip_range() steps = self.subnet.netmask_steps step1 = Label(self.learning_steps, text='Step 1:') ip_range = Label(self.learning_steps, text='Assignable IP Range: {}'.format( self.subnet.ip_range)) step2 = Label(self.learning_steps, text='Step 2:') front = Label(self.learning_steps, text='Front: {}'.format(steps[0]['Front'])) back = Label(self.learning_steps, text=' Back: {}'.format(steps[0]['Back'])) step3 = Label(self.learning_steps, text='Step 3:') comparison = Label(self.learning_steps, text='Comparison: {}'.format( steps[1]['Comparison'])) step4 = Label(self.learning_steps, text='Step 4:') netmask = Label(self.learning_steps, text='Netmask: {}'.format(self.subnet.netmask)) step1.grid(row=0, column=0, sticky='W') ip_range.grid(row=0, column=1, sticky='W') step2.grid(row=1, column=0, sticky='W') front.grid(row=1, column=1, sticky='W') back.grid(row=2, column=1, sticky='W') step3.grid(row=3, column=0, sticky='W') comparison.grid(row=3, column=1, sticky='W') step4.grid(row=4, column=0, sticky='W') netmask.grid(row=4, column=1, sticky='W') else: self.clear_and_reset() HelpGUI()
def get_count_from_cidr(self): if self.subnet.total_host_count != '': self.clear_and_reset() else: self.subnet.cidr_address = self.cidr_entry.get() if self.subnet.verify_variables(): self.subnet.calculate_total_host_count_from_cidr() steps = self.subnet.total_host_count_steps step1 = Label(self.learning_steps, text='Step 1:') cidr_address = Label(self.learning_steps, text='CIDR Address: {}'.format( self.subnet.cidr_address)) step2 = Label(self.learning_steps, text='Step 2:') cidr = Label(self.learning_steps, text='CIDR: {}'.format(steps[0]['CIDR'])) step3 = Label(self.learning_steps, text='Step 3:') host = Label(self.learning_steps, text='Host Bits: {}'.format( steps[1]['Host Bits'])) step4 = Label(self.learning_steps, text='Step 4:') count = Label(self.learning_steps, text='Total Host Count: 2{} = {}'.format( exponent( steps[1]['Host Bits'].split(' ')[-1]), self.subnet.total_host_count)) step1.grid(row=0, column=0, sticky='W') cidr_address.grid(row=0, column=1, sticky='W') step2.grid(row=1, column=0, sticky='W') cidr.grid(row=1, column=1, sticky='W') step3.grid(row=2, column=0, sticky='W') host.grid(row=2, column=1, sticky='W') step4.grid(row=3, column=0, sticky='W') count.grid(row=3, column=1, sticky='W') else: self.clear_and_reset() HelpGUI()
def get_count_from_netmask(self): if self.subnet.assignable_host_count != '': self.clear_and_reset() else: self.subnet.netmask = self.netmask_entry.get() if self.subnet.verify_variables(): self.subnet.calculate_assignable_host_count_from_netmask() steps = self.subnet.assignable_host_count_steps step1 = Label(self.learning_steps, text='Step 1:') netmask = Label(self.learning_steps, text='Netmask: {}'.format(self.subnet.netmask)) step2 = Label(self.learning_steps, text='Step 2:') netmask_binary = Label(self.learning_steps, text='Netmask Binary: {}'.format( steps[0]['Netmask Binary'])) step3 = Label(self.learning_steps, text='Step 3:') host = Label(self.learning_steps, text='Host Bits: {}'.format( steps[1]['Host Bits'])) step4 = Label(self.learning_steps, text='Step 4:') count = Label( self.learning_steps, text='Assignable Host Count: ( 2{} ) - 2 = {}'.format( exponent(str(steps[1]['Host Bits'])), self.subnet.assignable_host_count)) step1.grid(row=0, column=0, sticky='W') netmask.grid(row=0, column=1, sticky='W') step2.grid(row=1, column=0, sticky='W') netmask_binary.grid(row=1, column=1, sticky='W') step3.grid(row=2, column=0, sticky='W') host.grid(row=2, column=1, sticky='W') step4.grid(row=3, column=0, sticky='W') count.grid(row=3, column=1, sticky='W') else: self.clear_and_reset() HelpGUI()
def get_ip_range_from_network_broadcast(self): if self.subnet.ip_range != '': self.clear_and_reset() else: self.subnet.network_address = self.network_entry.get() self.subnet.broadcast_address = self.broadcast_entry.get() if self.subnet.network_address != '' and self.subnet.broadcast_address != '' \ and self.subnet.verify_variables() \ and (ipaddress.IPv4Address(self.subnet.network_address) + 2) \ < ipaddress.IPv4Address(self.subnet.broadcast_address): self.subnet.calculate_ip_range_from_network_broadcast() steps = self.subnet.ip_range_steps step1 = Label(self.learning_steps, text='Step 1:') network = Label(self.learning_steps, text='Network Address: {}'.format(self.subnet.network_address)) broadcast = Label(self.learning_steps, text='Broadcast Address: {}'.format(self.subnet.broadcast_address)) step2 = Label(self.learning_steps, text='Step 2:') front = Label(self.learning_steps, text='Front: {}'.format(steps[0]['Front'])) step3 = Label(self.learning_steps, text='Step 3:') back = Label(self.learning_steps, text='Back: {}'.format(steps[1]['Back'])) step4 = Label(self.learning_steps, text='Step 4:') ip_range = Label(self.learning_steps, text='Assignable IP Range: {}'.format(self.subnet.ip_range)) step1.grid(row=0, column=0, sticky='W') network.grid(row=0, column=1, sticky='W') broadcast.grid(row=0, column=2, sticky='W') step2.grid(row=1, column=0, sticky='W') front.grid(row=1, column=1, sticky='W') step3.grid(row=2, column=0, sticky='W') back.grid(row=2, column=1, sticky='W') step4.grid(row=3, column=0, sticky='W') ip_range.grid(row=3, column=1, columnspan=2, sticky='W') else: self.clear_and_reset() HelpGUI()