Networking Forums

Networking Forums > Computer Networking > Linux Networking > outgoing packets with sendto()

Reply
Thread Tools Display Modes

outgoing packets with sendto()

 
 
Tom
Guest
Posts: n/a

 
      11-23-2006, 12:10 PM
Hi,

I am creating packets and sending with sockets to the network. But I am
unable to send packets to my own system. I want to be able to send form
my system some ICMP query to eth0 interface so that my own system will
send reply. For now I can tcpdump the query and it is visible in the net
but it seems to be outgoing only. Maybe I have to put in to network rx
buffer but I don't know how.

Thanks for any help.

Tom


Here is my actual sending procedure:

int send_ethernet_raw_lan(char *frame, int frame_length) {
int sendBytes;
static struct sockaddr_ll ll;

memset(&ll, 0, sizeof(struct sockaddr_ll));
ll.sll_family = AF_PACKET;
ll.sll_ifindex = config.lanindex;
ll.sll_protocol = htons(ETH_P_ALL);


sendBytes=sendto(lansock,frame,frame_length,0,(str uct sockaddr *)
&ll, sizeof(struct sockaddr_ll));

return sendBytes;
}

int initialize_socket_lan(void) {
struct ifreq ifr;
struct sockaddr_ll ll;
int dummy,ret;

lansock = socket(PF_PACKET, SOCK_RAW, htons(ETH_P_ALL));

memset(&ll, 0, sizeof(struct sockaddr_ll));
memset(&ifr,0,sizeof(ifr));
strncpy(ifr.ifr_name, config.devlan, sizeof (ifr.ifr_name));

dummy = socket(AF_INET, SOCK_DGRAM, 0);

ret = ioctl(dummy, SIOCGIFINDEX, &ifr);
config.lanindex=ifr.ifr_ifindex;

ll.sll_family = AF_PACKET;
ll.sll_ifindex = ifr.ifr_ifindex;
ll.sll_protocol = htons(ETH_P_ALL);
if (bind(lansock, (struct sockaddr *) &ll, sizeof(struct
sockaddr_ll)) < 0) {
perror("bind");
exit(1);
}

return 0;
}
 
Reply With Quote
 
 
 
 
Bill Marcum
Guest
Posts: n/a

 
      11-24-2006, 02:20 PM
On Thu, 23 Nov 2006 14:10:04 +0100, Tom
<(E-Mail Removed)> wrote:
> Hi,
>
> I am creating packets and sending with sockets to the network. But I am
> unable to send packets to my own system. I want to be able to send form
> my system some ICMP query to eth0 interface so that my own system will
> send reply. For now I can tcpdump the query and it is visible in the net
> but it seems to be outgoing only. Maybe I have to put in to network rx
> buffer but I don't know how.
>
> Thanks for any help.
>
> Tom
>

Is the loopback (lo) interface up? Can you ping it? Note that if you
ping an address on your own machine it will go through lo.


--
Committees have become so important nowadays that subcommittees have to
be appointed to do the work.
 
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Force an application to use the IP I want for outgoing packets Gdss Linux Networking 13 01-24-2008 12:05 PM
block outgoing packets with iptables Peter Lowrie Linux Networking 2 05-05-2006 03:31 AM
How to select IP address for outgoing packets? Graham Murray Linux Networking 3 04-28-2005 06:34 PM
forwarding outgoing packets Nicola Gatti Linux Networking 4 02-17-2004 06:56 AM
100 packets/sec outgoing traffic for each socket Ben B Linux Networking 0 01-23-2004 10:13 AM



1 2 3 4 5 6 7 8 9 10 11