Changeset 9502
- Timestamp:
- 09/05/08 03:10:47
- Files:
-
- usrp2/trunk/host/lib/Makefile.am (modified) (1 diff)
- usrp2/trunk/host/lib/ethernet.cc (modified) (2 diffs)
- usrp2/trunk/host/lib/open_usrp2_socket.cc (added)
- usrp2/trunk/host/lib/open_usrp2_socket.h (added)
- usrp2/trunk/host/lib/usrp2_socket_opener.cc (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
usrp2/trunk/host/lib/Makefile.am
r9501 r9502 35 35 ethernet.cc \ 36 36 find.cc \ 37 open_usrp2_socket.cc \ 37 38 pktfilter.cc \ 38 39 ring.cc \ usrp2/trunk/host/lib/ethernet.cc
r9409 r9502 23 23 #include "ethernet.h" 24 24 #include "pktfilter.h" 25 #include <open_usrp2_socket.h> 25 26 26 27 #include <iostream> … … 45 46 open_packet_socket (std::string ifname, int protocol) 46 47 { 48 #if 0 47 49 if (protocol == 0) 48 50 protocol = htons(ETH_P_ALL); 49 51 50 52 int fd = socket (PF_PACKET, SOCK_RAW, protocol); 53 #else 54 int fd = usrp2::open_usrp2_socket(); 55 #endif 56 51 57 if (fd == -1){ 52 58 fprintf (stderr, "%s: socket: %s\n", ifname.c_str(), strerror (errno)); usrp2/trunk/host/lib/usrp2_socket_opener.cc
r9501 r9502 79 79 80 80 bool 81 reset_eids ()81 reset_eids() 82 82 { 83 if (setgid (getgid()) < 0){84 perror ("setguid");83 if (setgid(getgid()) < 0){ 84 perror("setguid"); 85 85 return false; 86 86 } 87 87 88 if (setuid (getuid()) < 0){89 perror ("setuid");88 if (setuid(getuid()) < 0){ 89 perror("setuid"); 90 90 return false; 91 91 } … … 116 116 117 117 // open the raw socket 118 int socket_fd = socket (PF_PACKET, SOCK_RAW, htons(0xBEEF));118 int socket_fd = socket(PF_PACKET, SOCK_RAW, htons(0xBEEF)); 119 119 if (socket_fd == -1){ 120 120 perror("socket(PF_PACKET, SOCK_RAW, htons(0xBEEF))"); 121 121 // printf("errno = %d\n", errno); 122 122 if (errno == EACCES || errno == ESPIPE){ 123 fprintf (stderr, "usrp2_socket_opener must be setuid root to open the socket using SOCK_RAW.\n");124 fprintf (stderr, "Running as root, please execute: \n");125 fprintf (stderr, " # chown root usrp2_socket_opener\n");126 fprintf (stderr, " # chmod u+s usrp2_socket_opener\n");123 fprintf(stderr, "usrp2_socket_opener must be setuid root to open the socket using SOCK_RAW.\n"); 124 fprintf(stderr, "Running as root, please execute: \n"); 125 fprintf(stderr, " # chown root usrp2_socket_opener\n"); 126 fprintf(stderr, " # chmod u+s usrp2_socket_opener\n"); 127 127 } 128 128 exit(2);
