[Click] Please help. TCP and UDP Headers problems.
Josh Butler
tuna_armadillo at hotmail.com
Thu Nov 22 07:40:38 EST 2007
On Thu, 2007-11-22 at 14:28 +0200, Beyers Cronje wrote:
> Did you include the tcp and udp header files?
>
> #include <clicknet/udp.h>
> #include <clicknet/tcp.h>
HAHAHA! Schoolboy error. Problem solved. You guys definitely get an
acknowledgement in my write up.
On Thu, 2007-11-22 at 14:28 +0200, Beyers Cronje wrote:
> Did you include the tcp and udp header files?
>
> #include <clicknet/udp.h>
> #include <clicknet/tcp.h>
>
>
>
> On Nov 22, 2007 2:13 PM, Josh Butler <tuna_armadillo at hotmail.com> 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
> >
> >
> > _______________________________________________
> > click mailing list
> > click at amsterdam.lcs.mit.edu
> > https://amsterdam.lcs.mit.edu/mailman/listinfo/click
> >
>
More information about the click
mailing list