[Click] Please help. TCP and UDP Headers problems.
Bart Braem
bart.braem at ua.ac.be
Thu Nov 22 07:34:05 EST 2007
Dear Josh,
Please reply to the list, that way everyone can learn and help.
I do not understand what's going on, if I include the following headers then
that code compiles at my system:
#include <clicknet/ip.h>
#include <clicknet/tcp.h>
#include <clicknet/udp.h>
Please check everything and make sure you did save files etc. Oh and you don't
want to return 0 in a void function, that's a certain way to problems.
Regards,
Bart
On Thursday 22 November 2007 13:09:56 Josh Butler wrote:
> Hi Bart,
>
> Many thanks for the reply. Modified the code, see below, but still
> getting exactly the same errors... Getting really desperate now. Please
> don't give up on me, I'm not usually this slow.
>
> void
> MyTee::push(int, Packet *p_in)
> {
>
> WritablePacket *p = p_in->uniqueify();
> if (!p) //kill if no memory available.
> return 0;
>
> click_ip *iph = p->ip_header(); // Get pointer to IP Header
>
> if (!iph) // Make sure it's a valid header
> {
> p->kill(); // Kill if invalid to avoid memory leaks
> return;
> }
>
> SrcIP = iph->ip_src;
> DstIP = iph->ip_dst;
> Protocol = iph->ip_p;
>
> if (Protocol == 6)
> {
> click_tcp *tcph = p->tcp_header();
> SrcPort = tcph->th_sport;
> DstPort = tcph->th_dport;
> }
>
> else if (Protocol == 17) {
> click_udp *udph = p->udp_header();
> SrcPort = udph->uh_sport;
> DstPort = udph->uh_dport;
> }
>
> On Thu, 2007-11-22 at 09:12 +0100, Bart Braem wrote:
> > On Thursday 22 November 2007 01:57:08 Josh Butler wrote:
> > > //CODE\\
> > >
> > > 66 const click_ip *iph = p->ip_header(); // Get pointer to IP Header
> > > 67
> > > 68 if (!iph) // Make sure it's a valid header
> > > 69 {
> > > 70 p->kill(); // Kill if invalid to avoid memory leaks
> > > 71 return;
> > > 72 }
> > > 73
> > > 74 SrcIP = iph->ip_src;
> > > 75 DstIP = iph->ip_dst;
> > > 76
> > > 77 if (iph->ip_p == 6) //Is packet tcp?
> > > 78 {
> > > 79 click_tcp *tcph = p->tcp_header(); //get pointer to tcp header.
> > > 80 SrcPort = tcph->th_sport;
> > > 81 DstPort = tcph->th_dport;
> > > 82 }
> > > 83
> > > 84 else if (iph->ip_p == 17){ //Is packet udp?
> > > 85 click_udp *udph = p->udp_header(); //get pointer to udp header.
> > > 86 SrcPort = udph->uh_sport;
> > > 87 DstPort = udph->uh_dport;
> > > 88 }
> > >
> > > //END CODE\\
> > >
> > > Terminal shows the following errors:
> > >
> > > ./elements/local/mytee.cc: In member function ‘virtual void
> > > MyTee::push(int, Packet*)’:
> > >
> > > ./elements/local/mytee.cc:80: error: invalid conversion from ‘const
> > > click_tcp*’ to ‘click_tcp*’
> >
> > Read the header file packet.hh in the include/click directory: in Packet
> > the function tcp_header(); returns a const pointer. So either use a
> > WriteablePacket or change the type of the tcp header.
> >
> > > ./elements/local/mytee.cc:81: error: invalid use of undefined type
> > > ‘struct click_tcp’
> > >
> > > ./include/click/packet.hh:17: error: forward declaration of ‘struct
> > > click_tcp’
> > >
> > > ./elements/local/mytee.cc:82: error: invalid use of undefined type
> > > ‘struct click_tcp’
> > >
> > > ./include/click/packet.hh:17: error: forward declaration of ‘struct
> > > click_tcp’
> >
> > All these errors result from the previous one.
> >
> > > ./elements/local/mytee.cc:86: error: invalid conversion from ‘const
> > > click_udp*’ to ‘click_udp*’
> >
> > This is the same problem of the return type of that function.
> >
> > > ./elements/local/mytee.cc:87: error: invalid use of undefined type
> > > ‘struct click_udp’
> > >
> > > ./include/click/packet.hh:18: error: forward declaration of ‘struct
> > > click_udp’
> > >
> > > ./elements/local/mytee.cc:88: error: invalid use of undefined type
> > > ‘struct click_udp’
> > >
> > > ./include/click/packet.hh:18: error: forward declaration of ‘struct
> > > click_udp’
> >
> > These errors also result from the previous ones.
> >
> > Regards,
> > Bart
> > _______________________________________________
> > click mailing list
> > click at amsterdam.lcs.mit.edu
> > https://amsterdam.lcs.mit.edu/mailman/listinfo/click
--
Bart Braem
PATS research group
Dept. of Mathematics and Computer Sciences
University of Antwerp
Campus Middelheim, G3.30
Middelheimlaan 1
B-2020 Antwerpen, Belgium
Phone: +32 (0)3 265.32.91
Fax: +32 (0)3 265.37.77
Web: www.pats.ua.ac.be/bart.braem
More information about the click
mailing list