Skip Menu |

This queue is for tickets about the Net-MAC CPAN distribution.

Report information
The Basics
Id: 16865
Status: resolved
Priority: 0/
Queue: Net-MAC

People
Owner: OLIVER [...] cpan.org
Requestors: oliver.gorwits [...] oucs.ox.ac.uk
Cc:
AdminCc:

Bug Information
Severity: Wishlist
Broken in: (no value)
Fixed in: (no value)



Subject: patches welcome?
Hi Karl, We were just working on a similar module to Net::MAC, but have dropped it as yours seems to have already made it further along the same lines. I was wondering whether you were patching those BUGS mentioned in the docs? the zero-padding would be helpful to us. A couple of other features were going to appear in our own module: * operator overloading to support direct assignment (=), stringification, and equality comparisons (== and eq) * shortcuts to particular formats (ISC DHCPd is another I was thinking of) as accessors, e.g. ->as_Cisco ->as_ISC etc I feel these may be best placed in something like a Net::MAC::Simple module, beause they're kind of messy and get in the way of your more direct handling of the MAC addresses. What do you think about that? Do you have a strong objection to a ::Simple module appearing, or would you prefer to have them in Net::MAC, or even not appear at all and kept privately to ourselves? Thanks for your work, regards, oliver. -- Oliver Gorwits Oxford University Computing Services
1. Zero padding I can implement this. I was waiting for someone to need it. 2. Operator overloading, stringification, etc. Again, I was considering doing this, but I felt it was overkill for my needs. It makes sense to implement it if someone else needs it. I'll definitely accept patches, but I'm pretty by-the-book (Damian Conway's Object Oriented Perl, mostly), so I might make modifications to your patches or reimplement things if I think Conway provides a cleaner implementation. Be aware that I have released this module under the GNU General Public License, so your contributions will become GPL licensed as well. 3. Shortcuts to particular formats I'm not averse to a Net::MAC::Simple, and it would be fine to put shortcuts into a separate module. But if there are only 4 or 5 shortcut accessors, maybe we should just put them into Net::MAC. I can think of a few that would be useful, like as_Microsoft, as_ISC, as_Sun. How many other shortcuts are you considering? Thanks for the feedback. -k
Subject: Progress on wishlist requests
Just a quick note on where I am with this request. Let me know if any of my assumptions or plans diverge from your needs. I have implemented stringification (double quotes only), and I found (and fixed) a bug in the process. I will also implement eq and == overloading shortly: eq - string equality, meaning that the result of the get_mac() method will return exactly the same string for both objects. Later this will have to take into account zero padding, and then maybe someday I'll implement case preservation as well. == - numerical equality, meaning that the internal MAC addresses of each object are identical (i.e. they are the same 48 bit number) After those are finished, I'll implement direct assignment. I assume that you want copy on assignment, so that the = operator will create an exact copy of the object on the right of the = sign, and then assign its reference to the variable on the left side of the = sign. After that, I'll implement configurable zero padding. -k
Hi Karl, On Fri Jan 13 19:31:00 2006, KARLWARD wrote: Show quoted text
> I have implemented stringification > I will also implement eq and == overloading shortly
That's great work, thanks :-) Your description of these seems aboslutely fine to me. Show quoted text
> After those are finished, I'll implement direct assignment. I assume > that you want copy on assignment
Yes, please, that is how I had imagined it. regards, oliver.
Karl, Yet again sorry for the silence this end - the new year has turned out to be busier than I expected. Everyone seems to be interested in wireless networking! Anyway, I have a proposal for the ->as_Foo feature I mentioned, and I've put together a small patch so you can see what I mean. Comments are welcome. I've gone with a lookup table via AUTOLOAD and re-use of the ->convert method, so that in the future you can add things like zero_padded to ->convert and this technique will be able to cope. (to be honest, I've not tested that this works, I just wanted your opinion on the method before I go away and also patch your test suite, etc) regards, oliver. -- Oliver Gorwits, Network Infrastructure Group, Oxford University Computing Services
Index: MAC.pm =================================================================== --- MAC.pm (revision 568) +++ MAC.pm (working copy) @@ -106,6 +106,13 @@ } } } # End closure + +# Preset formats we will accept for use by ->convert, via ->as_foo +my %_format_for = ( +# alias base bit_group delimiter + 'Cisco' => [ 16, 16, '.' ], + 'Microsoft' => [ 16, 8, '-' ], +); # Automatic accessor methods via AUTOLOAD # See Object Oriented Perl, 3.3, Damian Conway @@ -124,6 +131,12 @@ $self->{$1} = $value; return; } + if ($AUTOLOAD =~ /.*::as_(\w+)/ && exists $_format_for{$1}) { + my %format; + @format{qw(base bit_group delimiter)} = @{$_format_for{$1}}; + *{$AUTOLOAD} = sub { return $_[0]->convert(%format) }; + return($self->convert(%format)); + } croak "No such method: $AUTOLOAD"; }
On Mon Jan 30 10:00:14 2006, OLIVER wrote: Show quoted text
> Anyway, I have a proposal for the ->as_Foo feature I mentioned
Oh, I forgot to mention that this patch assumes the stringification of Net::MAC objects is in place, which is why it returns a Net::MAC object. regards, oliver.
I think these features (overloaded operators, and canned formats) are now in the distribution. Resolving.