From: Hajimu UMEMOTO Date: 2003-04-25T03:43:11+09:00 Subject: Re: IPaddr design Hi, Since I was not on the list, knu-san notified me of your mail. So, I've just subscribed the list. >>>>> On Thu, 24 Apr 2003 19:34:14 +0200 >>>>> "Stephane D'Alu" said: Stephane> - having sub classes IPv4, IPv6 (and IPv6::Compatible) instead Stephane> of one class doing it all (fall better in the object oriented design) When I made ipaddr, I thought whether IPv4 and IPv6 should be implemented as separate class or not. If IPv4 and IPv6 are separate classes, a user of the classes has to care which address family is using. I prefer address family independent programing which means we don't care address family as possible. So, I decide to implement it as one class. Stephane> - when creating an address from a string, being able to select Stephane> how the string should be interpreted (ipv4 or ipv4 mapped) Stephane> (OrderStrict, OrderCompatibility, OrderIPv6Only, OrderIPv4Only) Stephane> This will give finer control on the type of addresses that Stephane> should be created (and could allow to easily swap to IPv6 only Stephane> or remover IPv4 mapped addresses (there are already some talk about it)) It's a good idea. Someone may want to traet an address strictly. Stephane> - keeping some regular expression to test if a string match an ip address Stephane> (IPv6StrictRegex, IPv6Regex, IPv6LooseRegex, ...) How do you use these regular expressions? I think it can be tested by whether a string can be converted to an address or not. Stephane> - having some commonly used constant defined (Loopback) It's good idea having constant. However, once we decide to have some constants, we need more constants than only Loopback. This is why I didn't add constants, yet. Stephane> - the method name 'reverse' for ipaddr seems confusing when compared Stephane> to class string or array Yup, I think so. Do you have any idea about the name? Stephane> - scope_id or prefixlen are not directly part of an ip address Stephane> and so should not be included in the class, if someone want/need Stephane> them a new class should be created, this could be in the Stephane> case of scope_id a class called SockAddr. I implemented ipaddr as you say at the begining. But, it was somewhat diffuse. So, I merged these into one class. Stephane> - the | or & operator has some usefullness when dealing with netmask, Stephane> but netmask and IPv4 classes (A, B, C, ..) have been depretiated in Stephane> favor of prefixlen. now for the operators '<<' '>>' and '~', I should Stephane> say that I have difficulties to find a real use for them. It is useful when getting some part of the address or makeing IP address. Especially, IPv6 address is structured. Sincerly, -- Hajimu UMEMOTO @ Internet Mutual Aid Society Yokohama, Japan ume@mahoroba.org ume@bisd.hitachi.co.jp ume@{,jp.}FreeBSD.org http://www.imasy.org/~ume/