params.py (8460:3893d9d2c6c2) params.py (8579:ad3704c8a503)
1# Copyright (c) 2004-2006 The Regents of The University of Michigan
1# Copyright (c) 2004-2006 The Regents of The University of Michigan
2# Copyright (c) 2010 Advanced Micro Devices, Inc.
2# Copyright (c) 2010-2011 Advanced Micro Devices, Inc.
3# All rights reserved.
4#
5# Redistribution and use in source and binary forms, with or without
6# modification, are permitted provided that the following conditions are
7# met: redistributions of source code must retain the above copyright
8# notice, this list of conditions and the following disclaimer;
9# redistributions in binary form must reproduce the above copyright
10# notice, this list of conditions and the following disclaimer in the

--- 682 unchanged lines hidden (view full) ---

693 self.ip = value.ip
694 else:
695 try:
696 self.ip = convert.toIpAddress(value)
697 except TypeError:
698 self.ip = long(value)
699 self.verifyIp()
700
3# All rights reserved.
4#
5# Redistribution and use in source and binary forms, with or without
6# modification, are permitted provided that the following conditions are
7# met: redistributions of source code must retain the above copyright
8# notice, this list of conditions and the following disclaimer;
9# redistributions in binary form must reproduce the above copyright
10# notice, this list of conditions and the following disclaimer in the

--- 682 unchanged lines hidden (view full) ---

693 self.ip = value.ip
694 else:
695 try:
696 self.ip = convert.toIpAddress(value)
697 except TypeError:
698 self.ip = long(value)
699 self.verifyIp()
700
701 def __str__(self):
702 tup = [(self.ip >> i) & 0xff for i in (24, 16, 8, 0)]
703 return '%d.%d.%d.%d' % tuple(tup)
704
705 def __eq__(self, other):
706 if isinstance(other, IpAddress):
707 return self.ip == other.ip
708 elif isinstance(other, str):
709 try:
710 return self.ip == convert.toIpAddress(other)
711 except:
712 return False
713 else:
714 return self.ip == other
715
716 def __ne__(self, other):
717 return not (self == other)
718
701 def verifyIp(self):
702 if self.ip < 0 or self.ip >= (1 << 32):
703 raise TypeError, "invalid ip address %#08x" % self.ip
704
705 def getValue(self):
706 from m5.internal.params import IpAddress
707 return IpAddress(self.ip)
708
719 def verifyIp(self):
720 if self.ip < 0 or self.ip >= (1 << 32):
721 raise TypeError, "invalid ip address %#08x" % self.ip
722
723 def getValue(self):
724 from m5.internal.params import IpAddress
725 return IpAddress(self.ip)
726
709 def ini_str(self):
710 return self.ip
711
712# When initializing an IpNetmask, pass in an existing IpNetmask, a string of
713# the form "a.b.c.d/n" or "a.b.c.d/e.f.g.h", or an ip and netmask as
714# positional or keyword arguments.
715class IpNetmask(IpAddress):
716 cxx_type = 'Net::IpNetmask'
717
718 @classmethod
719 def cxx_predecls(cls, code):

--- 34 unchanged lines hidden (view full) ---

754 else:
755 raise TypeError, "Too many arguments specified"
756
757 if kwargs:
758 raise TypeError, "Too many keywords: %s" % kwargs.keys()
759
760 self.verify()
761
727# When initializing an IpNetmask, pass in an existing IpNetmask, a string of
728# the form "a.b.c.d/n" or "a.b.c.d/e.f.g.h", or an ip and netmask as
729# positional or keyword arguments.
730class IpNetmask(IpAddress):
731 cxx_type = 'Net::IpNetmask'
732
733 @classmethod
734 def cxx_predecls(cls, code):

--- 34 unchanged lines hidden (view full) ---

769 else:
770 raise TypeError, "Too many arguments specified"
771
772 if kwargs:
773 raise TypeError, "Too many keywords: %s" % kwargs.keys()
774
775 self.verify()
776
777 def __str__(self):
778 return "%s/%d" % (super(IpNetmask, self).__str__(), self.netmask)
779
780 def __eq__(self, other):
781 if isinstance(other, IpNetmask):
782 return self.ip == other.ip and self.netmask == other.netmask
783 elif isinstance(other, str):
784 try:
785 return (self.ip, self.netmask) == convert.toIpNetmask(other)
786 except:
787 return False
788 else:
789 return False
790
762 def verify(self):
763 self.verifyIp()
764 if self.netmask < 0 or self.netmask > 32:
765 raise TypeError, "invalid netmask %d" % netmask
766
767 def getValue(self):
768 from m5.internal.params import IpNetmask
769 return IpNetmask(self.ip, self.netmask)
770
791 def verify(self):
792 self.verifyIp()
793 if self.netmask < 0 or self.netmask > 32:
794 raise TypeError, "invalid netmask %d" % netmask
795
796 def getValue(self):
797 from m5.internal.params import IpNetmask
798 return IpNetmask(self.ip, self.netmask)
799
771 def ini_str(self):
772 return "%08x/%d" % (self.ip, self.netmask)
773
774# When initializing an IpWithPort, pass in an existing IpWithPort, a string of
775# the form "a.b.c.d:p", or an ip and port as positional or keyword arguments.
776class IpWithPort(IpAddress):
777 cxx_type = 'Net::IpWithPort'
778
779 @classmethod
780 def cxx_predecls(cls, code):
781 code('#include "base/inet.hh"')

--- 33 unchanged lines hidden (view full) ---

815 else:
816 raise TypeError, "Too many arguments specified"
817
818 if kwargs:
819 raise TypeError, "Too many keywords: %s" % kwargs.keys()
820
821 self.verify()
822
800# When initializing an IpWithPort, pass in an existing IpWithPort, a string of
801# the form "a.b.c.d:p", or an ip and port as positional or keyword arguments.
802class IpWithPort(IpAddress):
803 cxx_type = 'Net::IpWithPort'
804
805 @classmethod
806 def cxx_predecls(cls, code):
807 code('#include "base/inet.hh"')

--- 33 unchanged lines hidden (view full) ---

841 else:
842 raise TypeError, "Too many arguments specified"
843
844 if kwargs:
845 raise TypeError, "Too many keywords: %s" % kwargs.keys()
846
847 self.verify()
848
849 def __str__(self):
850 return "%s:%d" % (super(IpWithPort, self).__str__(), self.port)
851
852 def __eq__(self, other):
853 if isinstance(other, IpWithPort):
854 return self.ip == other.ip and self.port == other.port
855 elif isinstance(other, str):
856 try:
857 return (self.ip, self.port) == convert.toIpWithPort(other)
858 except:
859 return False
860 else:
861 return False
862
823 def verify(self):
824 self.verifyIp()
825 if self.port < 0 or self.port > 0xffff:
826 raise TypeError, "invalid port %d" % self.port
827
828 def getValue(self):
829 from m5.internal.params import IpWithPort
830 return IpWithPort(self.ip, self.port)
831
863 def verify(self):
864 self.verifyIp()
865 if self.port < 0 or self.port > 0xffff:
866 raise TypeError, "invalid port %d" % self.port
867
868 def getValue(self):
869 from m5.internal.params import IpWithPort
870 return IpWithPort(self.ip, self.port)
871
832 def ini_str(self):
833 return "%08x:%d" % (self.ip, self.port)
834
835time_formats = [ "%a %b %d %H:%M:%S %Z %Y",
836 "%a %b %d %H:%M:%S %Z %Y",
837 "%Y/%m/%d %H:%M:%S",
838 "%Y/%m/%d %H:%M",
839 "%Y/%m/%d",
840 "%m/%d/%Y %H:%M:%S",
841 "%m/%d/%Y %H:%M",
842 "%m/%d/%Y",

--- 645 unchanged lines hidden ---
872time_formats = [ "%a %b %d %H:%M:%S %Z %Y",
873 "%a %b %d %H:%M:%S %Z %Y",
874 "%Y/%m/%d %H:%M:%S",
875 "%Y/%m/%d %H:%M",
876 "%Y/%m/%d",
877 "%m/%d/%Y %H:%M:%S",
878 "%m/%d/%Y %H:%M",
879 "%m/%d/%Y",

--- 645 unchanged lines hidden ---