From: Matthew X. Economou
Subject: Pretty printing IP addresses
Date: 
Message-ID: <w4olm5sefv7.fsf@eco-fs1.irtnog.org>
I'm writing some code that manipulates IP addresses.  I would like to
give the IP address object a pretty-printable and readable
representation.  Currently, I'm using a DEFTYPE declaration of
(SIMPLE-BIT-VECTOR 32) as my IP address object, and the only way I can
think of making something that would be usable with PPRINT-DISPATCH
and friends is to create a DEFCLASS or DEFSTRUCT wrapper around the
actual bit array.

This sucks and I'd really prefer not to be in the boxing-and-unboxing
objects business.  Is there a better way?


-- 
Matthew X. Economou <········@irtnog.org> - Unsafe at any clock speed!
I'm proud of my Northern Tibetian heritage! (http://www.subgenius.com)

From: Tim Bradshaw
Subject: Re: Pretty printing IP addresses
Date: 
Message-ID: <ey3ofao4k3h.fsf@cley.com>
* Matthew X Economou wrote:

> This sucks and I'd really prefer not to be in the boxing-and-unboxing
> objects business.  Is there a better way?

I don't see that there can be.  In order to print some object
specially the system needs some indication that it is a special
object.  The type of the object is pretty much it, I think.

--tim
From: Vassil Nikolov
Subject: Re: Pretty printing IP addresses
Date: 
Message-ID: <f34a0f4f.0209231910.3e74dffb@posting.google.com>
"Matthew X. Economou" <···············@irtnog.org> wrote in message news:<···············@eco-fs1.irtnog.org>...
> I'm writing some code that manipulates IP addresses.  I would like to
> give the IP address object a pretty-printable and readable
> representation.  Currently, I'm using a DEFTYPE declaration of
> (SIMPLE-BIT-VECTOR 32) as my IP address object, and the only way I can
> think of making something that would be usable with PPRINT-DISPATCH
> and friends is to create a DEFCLASS or DEFSTRUCT wrapper around the
> actual bit array.
> 
> This sucks and I'd really prefer not to be in the boxing-and-unboxing
> objects business.  Is there a better way?

Defining a class may suck less when you go beyond IPv4.

---Vassil.
From: Erik Naggum
Subject: Re: Pretty printing IP addresses
Date: 
Message-ID: <3241801326332982@naggum.no>
* Matthew X. Economou
| I'm writing some code that manipulates IP addresses.

  A class wrapper around a one-element vector specialized to contain 32-bit
  integers seems like a good choice.  Provide readers and setters that return
  and accept (respectively) a string, an integer, and four bytes.

| I would like to give the IP address object a pretty-printable and readable
| representation.

  Simple and easy with a class wrapper.

| Currently, I'm using a DEFTYPE declaration of (SIMPLE-BIT-VECTOR 32)

  Why on earth?  The overhead of constructing and deconstructing it bit by bit
  must be enormous.

| Is there a better way?

  See `print-object�.  Specialize methods on it for your wrapper class.

-- 
Erik Naggum, Oslo, Norway

Act from reason, and failure makes you rethink and study harder.
Act from faith, and failure makes you blame someone and push harder.
From: Matthew X. Economou
Subject: Re: Pretty printing IP addresses
Date: 
Message-ID: <w4ohegge51p.fsf@eco-fs1.irtnog.org>
>>>>> "Erik" == Erik Naggum <····@naggum.no> writes:

    Erik> Why on earth [(SIMPLE-BIT-VECTOR 32)]?  The overhead of
    Erik> constructing and deconstructing it bit by bit must be
    Erik> enormous.

The C mindset on my part.  I figured it would make parsing packet
traces easier if I used the on-the-wire formats in memory.

-- 
Matthew X. Economou <········@irtnog.org> - Unsafe at any clock speed!
I'm proud of my Northern Tibetian heritage! (http://www.subgenius.com)
From: Thomas F. Burdick
Subject: Re: Pretty printing IP addresses
Date: 
Message-ID: <xcvit0wuwmq.fsf@famine.OCF.Berkeley.EDU>
"Matthew X. Economou" <···············@irtnog.org> writes:

> >>>>> "Erik" == Erik Naggum <····@naggum.no> writes:
> 
>     Erik> Why on earth [(SIMPLE-BIT-VECTOR 32)]?  The overhead of
>     Erik> constructing and deconstructing it bit by bit must be
>     Erik> enormous.
> 
> The C mindset on my part.  I figured it would make parsing packet
> traces easier if I used the on-the-wire formats in memory.

??? Wouldn't the C-mindset version be to use an (unsigned-byte 32)?
FWIW, that's not a bad representation, either[*], since CL has much
better bit-bashing abilities than C does.

[*] Of course, a thin class wrapper around it is better, because then
you have type information attached to the number about what it means.

-- 
           /|_     .-----------------------.                        
         ,'  .\  / | No to Imperialist war |                        
     ,--'    _,'   | Wage class war!       |                        
    /       /      `-----------------------'                        
   (   -.  |                               
   |     ) |                               
  (`-.  '--.)                              
   `. )----'                               
From: Matthew X. Economou
Subject: Re: Pretty printing IP addresses
Date: 
Message-ID: <w4od6r4e0wd.fsf@eco-fs1.irtnog.org>
>>>>> "Thomas" == Thomas F Burdick <···@famine.OCF.Berkeley.EDU> writes:

    Thomas> ??? Wouldn't the C-mindset version be to use an
    Thomas> (unsigned-byte 32)? FWIW, that's not a bad representation,
    Thomas> either[*], since CL has much better bit-bashing abilities
    Thomas> than C does.

Aren't (SIMPLE-BIT-VECTOR 32) and (UNSIGNED-BYTE 32) the same thing?

In any case, I was attempting to build an interface that was "zero
copy", where the in-memory and on-the-wire (or on-the-filesystem)
formats were identical.  This is probably an example of premature
optimization on my part.

-- 
Matthew X. Economou <········@irtnog.org> - Unsafe at any clock speed!
I'm proud of my Northern Tibetian heritage! (http://www.subgenius.com)
From: Barry Margolin
Subject: Re: Pretty printing IP addresses
Date: 
Message-ID: <TWNj9.23$Wn3.3061@paloalto-snr1.gtei.net>
In article <···············@eco-fs1.irtnog.org>,
Matthew X. Economou <···············@irtnog.org> wrote:
>>>>>> "Thomas" == Thomas F Burdick <···@famine.OCF.Berkeley.EDU> writes:
>
>    Thomas> ??? Wouldn't the C-mindset version be to use an
>    Thomas> (unsigned-byte 32)? FWIW, that's not a bad representation,
>    Thomas> either[*], since CL has much better bit-bashing abilities
>    Thomas> than C does.
>
>Aren't (SIMPLE-BIT-VECTOR 32) and (UNSIGNED-BYTE 32) the same thing?

No.  SIMPLE-BIT-VECTOR is a type of array, and will have all the usual
array overhead (typically a dope vector containing the dimensions and type
info).  Also, you can only access it a bit at a time.  The elements of the
array will most likely be packed into a single, 32-bit word, though.

>In any case, I was attempting to build an interface that was "zero
>copy", where the in-memory and on-the-wire (or on-the-filesystem)
>formats were identical.  This is probably an example of premature
>optimization on my part.

I'm not sure how you were planning on doing that with the bit vector.
Doesn't your input routine need a loop that calls SETF for each bit?

-- 
Barry Margolin, ······@genuity.net
Genuity, Woburn, MA
*** DON'T SEND TECHNICAL QUESTIONS DIRECTLY TO ME, post them to newsgroups.
Please DON'T copy followups to me -- I'll assume it wasn't posted to the group.
From: Marco Antoniotti
Subject: Re: Pretty printing IP addresses
Date: 
Message-ID: <y6c7khbjwh9.fsf@octagon.valis.nyu.edu>
Off Topic....

Barry Margolin <······@genuity.net> writes:

> In article <···············@eco-fs1.irtnog.org>,
> Matthew X. Economou <···············@irtnog.org> wrote:
> >>>>>> "Thomas" == Thomas F Burdick <···@famine.OCF.Berkeley.EDU> writes:
> >
> >    Thomas> ??? Wouldn't the C-mindset version be to use an
> >    Thomas> (unsigned-byte 32)? FWIW, that's not a bad representation,
> >    Thomas> either[*], since CL has much better bit-bashing abilities
> >    Thomas> than C does.
> >
> >Aren't (SIMPLE-BIT-VECTOR 32) and (UNSIGNED-BYTE 32) the same thing?
> 
> No.  SIMPLE-BIT-VECTOR is a type of array, and will have all the usual
> array overhead (typically a dope vector containing the dimensions and type
                              ^^^^^^^^^^^

It has been a very long time since I heard this expression :)

Cheers

-- 
Marco Antoniotti ========================================================
NYU Courant Bioinformatics Group        tel. +1 - 212 - 998 3488
715 Broadway 10th Floor                 fax  +1 - 212 - 995 4122
New York, NY 10003, USA                 http://bioinformatics.cat.nyu.edu
                    "Hello New York! We'll do what we can!"
                           Bill Murray in `Ghostbusters'.
From: Greg Menke
Subject: Re: Pretty printing IP addresses
Date: 
Message-ID: <m33crzxee0.fsf@europa.pienet>
Marco Antoniotti <·······@cs.nyu.edu> writes:

> Off Topic....
> 
> Barry Margolin <······@genuity.net> writes:
> 
> > >
> > >Aren't (SIMPLE-BIT-VECTOR 32) and (UNSIGNED-BYTE 32) the same thing?
> > 
> > No.  SIMPLE-BIT-VECTOR is a type of array, and will have all the usual
> > array overhead (typically a dope vector containing the dimensions and type
>                               ^^^^^^^^^^^
> 
> It has been a very long time since I heard this expression :)
> 

Does this dope in that context mean drugs, dumb or airplane fabric
treatment?  The Jargon File doesn't have list the term.


Gregm
From: Barry Margolin
Subject: Re: Pretty printing IP addresses
Date: 
Message-ID: <i%4k9.28$y77.3538@paloalto-snr1.gtei.net>
In article <··············@europa.pienet>,
Greg Menke  <··········@toadmail.com> wrote:
>Marco Antoniotti <·······@cs.nyu.edu> writes:
>
>> Off Topic....
>> 
>> Barry Margolin <······@genuity.net> writes:
>> 
>> > >
>> > >Aren't (SIMPLE-BIT-VECTOR 32) and (UNSIGNED-BYTE 32) the same thing?
>> > 
>> > No.  SIMPLE-BIT-VECTOR is a type of array, and will have all the usual
>> > array overhead (typically a dope vector containing the dimensions and type
>> 
>> It has been a very long time since I heard this expression :)
>
>Does this dope in that context mean drugs, dumb or airplane fabric
>treatment?  The Jargon File doesn't have list the term.

I'm not sure of the etymology, but I suspect it may be similar to the word
"doping" when used in the context of semiconductors, which refers to adding
extra stuff to material.

In CS, a dope vector is an internal data structure containing information
about a user-visible data structure.  For an array it contains the type and
dimension information; for a CLOS instance the class object and any caches
used by the implementation would serve this purpose.

-- 
Barry Margolin, ······@genuity.net
Genuity, Woburn, MA
*** DON'T SEND TECHNICAL QUESTIONS DIRECTLY TO ME, post them to newsgroups.
Please DON'T copy followups to me -- I'll assume it wasn't posted to the group.
From: Tim Bradshaw
Subject: Re: Pretty printing IP addresses
Date: 
Message-ID: <ey3vg4u1kre.fsf@cley.com>
* Barry Margolin wrote:

> I'm not sure of the etymology, but I suspect it may be similar to the word
> "doping" when used in the context of semiconductors, which refers to adding
> extra stuff to material.

Isn't there a term in some US slang `the straight dope'?  I'm not sure
what it means (or if it is a term in fact), but I think it's something
to do with getting information about something, which would explain te
`dope vector' usage.

--tim
From: Joseph Dale
Subject: Re: Pretty printing IP addresses
Date: 
Message-ID: <S9gk9.805$t24.55629954@newssvr13.news.prodigy.com>
Tim Bradshaw wrote:
> * Barry Margolin wrote:
> 
> 
>>I'm not sure of the etymology, but I suspect it may be similar to the word
>>"doping" when used in the context of semiconductors, which refers to adding
>>extra stuff to material.
> 
> 
> Isn't there a term in some US slang `the straight dope'?  I'm not sure
> what it means (or if it is a term in fact), but I think it's something
> to do with getting information about something, which would explain te
> `dope vector' usage.
> 
> --tim

"The straight dope" is a term, and I understand it to mean "the real 
information, without any lies or BS". This is likely to be derived from 
the drug context, where "straight dope" would refer to pure, unadultered 
material. Which could be rephrased, mixing in the semiconductor 
metaphor, as "dope with no dope".

;)


Joe
From: Rob Warnock
Subject: Re: Pretty printing IP addresses
Date: 
Message-ID: <up34vd6ta48c7d@corp.supernews.com>
Joseph Dale  <·········@sbcglobal.net> wrote:
+---------------
| "The straight dope" is a term, and I understand it to mean "the real 
| information, without any lies or BS".
+---------------

Something like that.

+---------------
| This is likely to be derived from the drug context, where
| "straight dope" would refer to pure, unadultered material.
+---------------

Sorry, "dope" as "(reliable) information" long pre-dates the
current drug sub-culture. Check out any WW2-era movie for some
then-current usage, e.g., "Hey, Joe, did you talk to Sarge?
What's the dope on our mission?

+---------------
| Which could be rephrased, mixing in the semiconductor metaphor,
| as "dope with no dope".
+---------------

Probably not. The semiconductor metaphor indeed probably derives
from the *medical* [though not originally "druggie"] slang for
medication (e.g., "Has he been doped yet?"), but "dope vectors"
comes from the earlier, pure meaning of "information".


-Rob

-----
Rob Warnock, PP-ASEL-IA		<····@rpw3.org>
627 26th Avenue			<URL:http://www.rpw3.org/>
San Mateo, CA 94403		(650)572-2607
From: Joseph Dale
Subject: OT: Dope (was Re: Pretty printing IP addresses)
Date: 
Message-ID: <B4ik9.807$Mk4.56627323@newssvr13.news.prodigy.com>
Rob Warnock wrote:
> Joseph Dale  <·········@sbcglobal.net> wrote:
> +---------------
> | This is likely to be derived from the drug context, where
> | "straight dope" would refer to pure, unadultered material.
> +---------------
> 
> Sorry, "dope" as "(reliable) information" long pre-dates the
> current drug sub-culture. Check out any WW2-era movie for some
> then-current usage, e.g., "Hey, Joe, did you talk to Sarge?
> What's the dope on our mission?
> 

Actually, OED dates the drug/medical usage of "dope" back to the 
1870s/80s -- for example, in the context of opium, whose drug subculture 
probably has an even longer history than that just in America, let alone 
in other English-speaking nations and colonies. On the other hand, no 
references for the "information" usage appear before the 1900s.

Joe
From: Duane Rettig
Subject: Re: OT: Dope (was Re: Pretty printing IP addresses)
Date: 
Message-ID: <44rcd24cw.fsf@beta.franz.com>
Joseph Dale <·········@sbcglobal.net> writes:

> Rob Warnock wrote:
> > Joseph Dale  <·········@sbcglobal.net> wrote:
> > +---------------
> > | This is likely to be derived from the drug context, where
> > | "straight dope" would refer to pure, unadultered material.
> > +---------------
> > Sorry, "dope" as "(reliable) information" long pre-dates the
> 
> > current drug sub-culture. Check out any WW2-era movie for some
> > then-current usage, e.g., "Hey, Joe, did you talk to Sarge?
> > What's the dope on our mission?
> >
> 
> 
> Actually, OED dates the drug/medical usage of "dope" back to the
> 1870s/80s -- for example, in the context of opium, whose drug
> subculture probably has an even longer history than that just in
> America, let alone in other English-speaking nations and colonies. On
> the other hand, no references for the "information" usage appear
> before the 1900s.

Perhaps all of these definitions are related to or derived from
(or derive) the 4th definition my own dictionary gives for "dope":

  "oil, grease, or fuel additive, used to make machinery run
  smoothly"

To get somewhat back on-topic, I view (without authority) this above
definition as being the more likely derivation for a "dope vector".


-- 
Duane Rettig    ·····@franz.com    Franz Inc.  http://www.franz.com/
555 12th St., Suite 1450               http://www.555citycenter.com/
Oakland, Ca. 94607        Phone: (510) 452-2000; Fax: (510) 452-0182   
From: Rob Warnock
Subject: Re: Pretty printing IP addresses
Date: 
Message-ID: <up34ki5fo6vc07@corp.supernews.com>
Tim Bradshaw  <···@cley.com> wrote:
+---------------
| * Barry Margolin wrote:
| 
| > I'm not sure of the etymology, but I suspect it may be similar to the word
| > "doping" when used in the context of semiconductors, which refers to adding
| > extra stuff to material.
| 
| Isn't there a term in some US slang `the straight dope'?
+---------------

One of the dictionary definitions of "dope" is "information,
especially from a reliable source" (as in "the inside dope").
The dictionary says it dates back to 1807, and comes from the
Dutch word for "sauce" (as in "dip").

+---------------
| ...I think it's something to do with getting information about
| something, which would explain the `dope vector' usage.
+---------------

Exactly. Typical usage: "Did you get the new dope on the weather?"

By the way, a special case of "dope vectors" are "Iliffe vectors",
which are one implementation of multi-dimensional arrays. (See
<URL:http://www.cs.man.ac.uk/~pjj/cs2111/ho/node17.html> for more
discussion of both of these.)

The ALGOl-60 compiler on the DEC PDP-10 used  Iliffe vectors, since
that made array addressing almost trivial given the PDP-10's multi-level
index+indirect modes in memory-reference instructions. If a, b, & c
were already in the proper registers, "foo[a,b,c] := foo[a,b,c] + 1"
could be done in *one* instruction!! (No joke.)


-Rob

-----
Rob Warnock, PP-ASEL-IA		<····@rpw3.org>
627 26th Avenue			<URL:http://www.rpw3.org/>
San Mateo, CA 94403		(650)572-2607
From: Daniel Barlow
Subject: Re: Pretty printing IP addresses
Date: 
Message-ID: <87u1kes4j3.fsf@noetbook.telent.net>
Tim Bradshaw <···@cley.com> writes:

> Isn't there a term in some US slang `the straight dope'?  I'm not sure
> what it means (or if it is a term in fact), but I think it's something
> to do with getting information about something, which would explain te
> `dope vector' usage.

It's also the name of Cecil Adam's syndicated column and website, 
on approximately that subject: http://www.straightdope.com/

This is, strictly speaking, off-topic for cll, but it's hard not to
feel some kind of sympathetic resonance with a web site describing
itself as "Fighting ignorance since 1973 (it's taking longer than we
thought)"


-dan

-- 

  http://ww.telent.net/cliki/ - Link farm for free CL-on-Unix resources 
From: Erik Naggum
Subject: Re: Pretty printing IP addresses
Date: 
Message-ID: <3241815338491081@naggum.no>
* Matthew X. Economou
| Aren't (SIMPLE-BIT-VECTOR 32) and (UNSIGNED-BYTE 32) the same thing?

  Not even remotely comparable.

| In any case, I was attempting to build an interface that was "zero copy",
| where the in-memory and on-the-wire (or on-the-filesystem) formats were
| identical.

  You cannot write any integers into bit-vectors other than 0 and 1.  You
  address each individual bit.  It is slow and expensive to turn an integer
  into a bit-vector or vice versa unless you get at the implementation details.

  Something tells me you have no running code at this point.

-- 
Erik Naggum, Oslo, Norway

Act from reason, and failure makes you rethink and study harder.
Act from faith, and failure makes you blame someone and push harder.
From: Bulent Murtezaoglu
Subject: Re: Pretty printing IP addresses
Date: 
Message-ID: <87znu8i5ga.fsf@acm.org>
>>>>> "EN" == Erik Naggum <····@naggum.no> writes:
[...]
    EN>   Something tells me you have no running code at this point.

I have the same hunch.  Maybe we ought to point out that looking up 
dpb ldb etc. might be helpful at this point.

cheers,

BM
From: Matthew X. Economou
Subject: Re: Pretty printing IP addresses
Date: 
Message-ID: <w4owupcc8fd.fsf@eco-fs1.irtnog.org>
>>>>> "Bulent" == Bulent Murtezaoglu <··@acm.org> writes:

>>>>> "EN" == Erik Naggum <····@naggum.no> writes:

    EN> Something tells me you have no running code at this point.

    Bulent> I have the same hunch.  Maybe we ought to point out that
    Bulent> looking up dpb ldb etc. might be helpful at this point.

Unfortunately, you are both correct.  I'll try LDB/DPB and friends,
and go from there.  I was trying to create an FFI for WinPcap in
Corman Lisp, but for now, I think it will be easier if I just try to
read in the sniffer traces off the disk.

Thanks for all your help with the bit-bashing.

-- 
Matthew X. Economou <········@irtnog.org> - Unsafe at any clock speed!
I'm proud of my Northern Tibetian heritage! (http://www.subgenius.com)
From: Ng Pheng Siong
Subject: Re: Pretty printing IP addresses
Date: 
Message-ID: <amrfpq$tkd$1@reader01.singnet.com.sg>
According to Bulent Murtezaoglu  <··@acm.org>:
> >>>>> "EN" == Erik Naggum <····@naggum.no> writes:
>     EN>   Something tells me you have no running code at this point.
> I have the same hunch.  Maybe we ought to point out that looking up 
> dpb ldb etc. might be helpful at this point.

OP can also check out CLOCC which has ipaddr-to-dotted and
dotted-to-ipaddr; these may already do what he wants.


-- 
Ng Pheng Siong <····@netmemetic.com> * http://www.netmemetic.com
From: Frode Vatvedt Fjeld
Subject: Re: Pretty printing IP addresses
Date: 
Message-ID: <2h1y7kbflo.fsf@vserver.cs.uit.no>
"Matthew X. Economou" <···············@irtnog.org> writes:

> This sucks and I'd really prefer not to be in the
> boxing-and-unboxing objects business.  Is there a better way?

I don't see how you can specialize on the semantic meaning of an
object.. But if what you are really conserned with is printing these
IP addresses for human consumption, you can use the tilde-slash format
directive:

  (defun pprint-ip-address (stream object &optional colon-p at-p)
     ...)

  (format t "IP address: ~/pprint-ip-address/." <ip-address>)

You could even make the output of pprint-ip-address readable by means
of an appropriate reader macro.

-- 
Frode Vatvedt Fjeld
From: Michael J. Ferrador
Subject: Reading (Pretty printed) IP addresses
Date: 
Message-ID: <mwRj9.44114$7J2.1139474@news4.srv.hcvlny.cv.net>
How do you decide that a structure is around enough to warrant
being able to read back in it's printed representation?

Will we have to worry about read dispatch character collisions?

What else is useful to bundle with IP addrs? :netmask :vlsm-bits :wildcard
(Is Cisco the only one who uses wildcards?) :gateway :route :dns ?
:dhcp - to make it a dynamic variable

Matthew X. Economou <···············@irtnog.org> wrote in message
····················@eco-fs1.irtnog.org...
> I'm writing some code that manipulates IP addresses.  I would like to
> give the IP address object a pretty-printable and readable
> representation.

---

remove my First- and -Last name, from around my call sign