> 
> In this day an age, can't handle an unaligned move?  Amazing.
> 
> Yes, please do send in the whole-enchilada patch.  Probably best would be to
> [EMAIL PROTECTED] so Luca looks at it.
Sent it there it bounced:) Here it is.
-Chris
Index: ntop/pbuf.c
===================================================================
RCS file: /export/home/ntop/ntop/pbuf.c,v
retrieving revision 2.136
diff -U3 -r2.136 pbuf.c
--- ntop/pbuf.c 25 Aug 2003 16:28:16 -0000      2.136
+++ ntop/pbuf.c 29 Aug 2003 21:53:50 -0000
@@ -956,21 +956,20 @@
        int WIN=0, MSS=-1, WS=-1, S=0, N=0, D=0, T=0;
        int ttl;
        char WSS[3], _MSS[5];
-       struct tcphdr *tcp = (struct tcphdr*)(bp+hlen);
-       u_char *tcp_opt = (u_char *)(tcp + 1);
-       u_char *tcp_data = (u_char *)((int)tcp + tcp->th_off * 4);
 
-       if (tcp->th_flags & TH_SYN)   /* only SYN or SYN-2ACK packets */
+       if (tp.th_flags & TH_SYN)   /* only SYN or SYN-2ACK packets */
          {
            if (tcpUdpLen > 0) {
 
              if(ntohs(ip.ip_off) & IP_DF) D = 1;   /* don't fragment bit is set */
 
-             WIN = ntohs(tcp->th_win);  /* TCP window size */
+             WIN = ntohs(tp.th_win);  /* TCP window size */
 
-             if (tcp_data != tcp_opt) /* there are some tcp_option to be parsed */
+             if ((tp.th_off * 4) >= sizeof(struct tcphdr)) /* there are some 
tcp_option to be parsed */
                {
-                 u_char *opt_ptr = tcp_opt;
+                 u_char *opt_ptr = (u_char *)((struct tcphdr*)&tp + 1);
+                 u_char *tcp_data = 
+                    (u_char *)((struct tcphdr*)&tp + tp.th_off * 4);
 
                  while(opt_ptr < tcp_data)
                    {
@@ -1019,7 +1018,7 @@
              snprintf(fingerprint, sizeof(fingerprint),
                       "%04X:%s:%02X:%s:%d:%d:%d:%d:%c:%02X",
                       WIN, _MSS, ttl = TTL_PREDICTOR(ip.ip_ttl), WSS , S, N, D, T,
-                      (tcp->th_flags & TH_ACK) ? 'A' : 'S', tcpUdpLen);
+                      (tp.th_flags & TH_ACK) ? 'A' : 'S', tcpUdpLen);
 
 #if 0
              traceEvent(CONST_TRACE_INFO, "[%s][%s]", srcHost->hostNumIpAddress, 
fingerprint);
> 
> -----Burton
> 
> -----Original Message-----
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Behalf
> Of Chris Turbeville
> Sent: Thursday, August 28, 2003 12:46 AM
> To: [EMAIL PROTECTED]
> Subject: Re: [Ntop-dev] (was Sparc Sol9 patches)
> 
> 
> >
> > Are you saying that the Sparc platform can't handle an unaligned move?
> >
> > E.g another case of this comment?
> >
> >    /* Need to copy this over in case bp isn't properly aligned.
> >     * This occurs on SunOS 4.x at least.
> >     * Paul D. Smith <[EMAIL PROTECTED]>
> >     */
> >
> > Or is it that this (@922)
> >
> >       memcpy(&tp, bp+hlen, sizeof(struct tcphdr));
> >
> > is duplicated by the lines in the fingerprint routine?  If that's the
> case,
> > then shouldn't ALL the code in that block, 954..1032, be changed to use tp
> > and drop tcp all together?
> Yea I can send that in as that is what I've done.  The problem is bp
> isn't aligned so when the tcpheader * tries to refer to th_off it is a
> nonaligned ref and bombs.  I have a patch converting all of the finger
> print stuff to tp based instead of the tcp pointers. I'll send that in
> instead.
> -Chris
> >
> > -----Burton
> >
> >
> > -----Original Message-----
> > From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Behalf
> > Of Chris Turbeville
> > Sent: Tuesday, August 26, 2003 9:31 PM
> > To: [EMAIL PROTECTED]
> > Subject: [Ntop-dev] Sparc Sol9 patches
> >
> >
> > Here's the summary of the work I've done to get NTOP running on Solaris:
> >
> > <snip/>
> >
> > This is the standard sparc alignment fix.
> > Index: ntop/pbuf.c
> > ===================================================================
> > RCS file: /export/home/ntop/ntop/pbuf.c,v
> > retrieving revision 2.135
> > diff -r2.135 pbuf.c
> > 963c963
> > <   u_char *tcp_data = (u_char *)((int)tcp + tcp->th_off * 4);
> > ---
> > >   u_char *tcp_data = (u_char *)((int)tcp + tp.th_off * 4);
> >
> > <snip/>
> >
> > --
> > [EMAIL PROTECTED]           Chris Turbeville
> > NTT/VERIO
> >        Send mail with subject "send PGP Key" for PGP 6.5.2 Public key
> >
> >
> > _______________________________________________
> > Ntop-dev mailing list
> > [EMAIL PROTECTED]
> > http://listgateway.unipi.it/mailman/listinfo/ntop-dev
> >
> 
> 
> --
> [EMAIL PROTECTED]           Chris Turbeville
> NTT/VERIO
>        Send mail with subject "send PGP Key" for PGP 6.5.2 Public key
> _______________________________________________
> Ntop-dev mailing list
> [EMAIL PROTECTED]
> http://listgateway.unipi.it/mailman/listinfo/ntop-dev
> 
> _______________________________________________
> Ntop-dev mailing list
> [EMAIL PROTECTED]
> http://listgateway.unipi.it/mailman/listinfo/ntop-dev
> 


-- 
[EMAIL PROTECTED]           Chris Turbeville                       NTT/VERIO
       Send mail with subject "send PGP Key" for PGP 6.5.2 Public key
_______________________________________________
Ntop-dev mailing list
[EMAIL PROTECTED]
http://listgateway.unipi.it/mailman/listinfo/ntop-dev

Reply via email to