#include <stdio.h>
#include <netinet/in.h>
#include <netdb.h>
#include <linux/if_ether.h>
#include <linux/if_packet.h>
#include <linux/if.h>
#include <fcntl.h>
#include <sys/ioctl.h>
#include <sys/types.h>
#include <sys/socket.h>
Include dependency graph for bridge.c:
Go to the source code of this file.
Functions | |
int | main (int argc, char **argv) |
|
Definition at line 16 of file bridge.c. References fd, printf(), and sprintf(). 00017 { 00018 struct sockaddr_ll sll; 00019 int sin_len = sizeof(sll); 00020 char fd_str[10]; 00021 int fd; 00022 struct ifreq ifr; 00023 00024 if (argc != 2) { 00025 printf("You must specify network interface name\n"); 00026 return -1; 00027 } 00028 00029 if ((fd = socket(AF_PACKET, SOCK_RAW, htons(ETH_P_ALL))) < 0) { 00030 printf("Can create AF_PACKET RAW socket\n"); 00031 return -1; 00032 } 00033 00034 strcpy(ifr.ifr_name, argv[1]); 00035 ioctl (fd, SIOCGIFINDEX, &ifr); 00036 00037 sll.sll_family = AF_PACKET; 00038 sll.sll_ifindex = ifr.ifr_ifindex; 00039 sll.sll_protocol = htons(ETH_P_ALL); 00040 00041 printf("Binding to %s\n", argv[1]); 00042 bind(fd, (struct sockaddr *)&sll, sin_len); 00043 00044 sprintf(fd_str, "%d", fd); 00045 printf("%d\n", execl("/bin/bash", "bash", "/mnt/hdc5/src/agnix-sf/emulators/qemu/start.sh", fd_str, NULL)); 00046 }
Here is the call graph for this function: |