Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 14 Aug 2000 15:01:06 +1200
From:      "MATTHEW JOHN,LUCKIE" <mjl12@waikato.ac.nz>
To:        freebsd-net@freebsd.org
Subject:   determing ip->ip_src
Message-ID:  <45E87454FFC2D211AD9800508B65009420F8E8@stu-ex1.waikato.ac.nz>

next in thread | raw e-mail | index | archive | help
Hi there

I am writing some code that records the source address of the packet in the
data segment of the ip packet.
This code is part of a kernel module loaded via syscall

How do i deduce what source address to record in the data area of the packet
as i want to before it is sent to ip_output?

I realise that ip_output will sort ip_src out for me, but i want to know
this value ahead of calling ip_output()

I have tried the following code, based on what happens in ip_output when a
packet with no source address is passed to it and the destination address is
not a multicast address, but it does not get me any further as the second
test for ro.ro_rt fails.  Even if it didnt fail, i dont think the following
fragment would be any good, given that i do not take any account of the
destination address.

What should I be doing?
Is there a higher level function available for me to all that will return
the value?

Thanks

Matthew
-------------

u_int32_t getoutif()
{
  struct in_addr   in_addr;
  struct in_ifaddr *ia;
  struct route     ro;

  bzero(&ro, sizeof ro);

  if(ro.ro_rt == 0)
    {
      rtalloc_ign(&ro, RTF_PRCLONING);
    }
  if(ro.ro_rt == 0)
    {
      printf("INADDR_ANY");
      return INADDR_ANY;
    }

  ia = ifatoia(ro.ro_rt->rt_ifa);
  ro.ro_rt->rt_use++;
  in_addr = IA_SIN(ia)->sin_addr;
  RTFREE(ro.ro_rt);

  print_ip(in_addr);
  return in_addr.s_addr;
}


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-net" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?45E87454FFC2D211AD9800508B65009420F8E8>