Rocco:

Um...

  IPv6??

  Is that 1st set backwards? (how can you compare ethAddressString if it's
ipless??)

  Don't forget, qsort requires a transitive compare function, that is if a<b
and b<c then a<c.  I'm not sure your function is...

Finally, aren't these still going to look wrong, because the display is the
host NAME, not the ip/mac address

-----Burton



> -----Original Message-----
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Behalf Of Rocco
> Carbone
> Sent: Wednesday, February 18, 2004 2:23 PM
> To: [EMAIL PROTECTED]
> Subject: RE: [Ntop] Sorting
>
>
> >>>>> "Mark" == Mark Gibbons <[EMAIL PROTECTED]> writes:
>
>     Mark> It is still the same now 70 mins later.  I have to say that
>     Mark> I have seen this problem ever since we started using ntop -
>     Mark> its not just today.  Understand about strcasecmp not being
>     Mark> numerically correct but as you can see this just defies
>     Mark> logic and is a COMMON problem for us on Linux and Win32.  I
>     Mark> will look at the dump for null entries as you have suggested
>     Mark> and report back.
>
>     Mark> Mark
>
> I have already coded the sort_by_ip(), sort_by_mac() and
> sort_by_hostname() function and I will submit these to Luca
> for commit into CVS.
>
> /rocco
>
> E.g.
>
> /* Sort by IP address or MAC address (for IP-less hosts). */
> int sort_by_ip (const void * _a, const void * _b)
> {
>   HostTraffic ** a = (HostTraffic **) _a;
>   HostTraffic ** b = (HostTraffic **) _b;
>
>   /* IP-less hosts first */
>
>   if (is_ipless (* a) && is_ipless (* b))
>     return (strcmp ((* a) -> ethAddressString, (* b) ->
> ethAddressString));
>   else if (is_ipless (* a))
>     return (-1);
>   else if (is_ipless (* b))
>     return (1);
>   else
>     {
>       int a1;
>       int b1;
>       int c1;
>       int d1;
>       char ip1 [18];
>
>       int a2;
>       int b2;
>       int c2;
>       int d2;
>       char ip2 [18];
>
>       sscanf (intoa ((* a) -> hostIpAddress.addr._hostIp4Address),
>               "%d.%d.%d.%d", & a1, & b1, & c1, & d1);
>       sprintf (ip1, "%03d%03d%03d%03d", a1, b1, c1, d1);
>
>       sscanf (intoa ((* b) -> hostIpAddress.addr._hostIp4Address),
>               "%d.%d.%d.%d", & a2, & b2, & c2, & d2);
>       sprintf (ip2, "%03d%03d%03d%03d", a2, b2, c2, d2);
>
>       return (strcmp (ip1, ip2));
>     }
> }
>
>
> --
> Rocco Carbone <[EMAIL PROTECTED]> Pisa Italy
>
> "It's simple to make things. It's hard to make things simple."
> _______________________________________________
> Ntop mailing list
> [EMAIL PROTECTED]
> http://listgateway.unipi.it/mailman/listinfo/ntop
>

_______________________________________________
Ntop mailing list
[EMAIL PROTECTED]
http://listgateway.unipi.it/mailman/listinfo/ntop

Reply via email to