Raw socket creation error (IPPROTO_IP not supported)
hi all,
I tried creating a raw socket in Redhat Advanced server 3.0 . Problem is socket creation fails if the protocol family is IPPROTO_IP or IPPROTO_RAW. I checked out the values for these macros in the header file . They are IPPROTO_IP ---> 0 IPPROTO_IP ---> 255 I am interested in creating a RAW SOCKET (SOCK_RAW) only . Socket creation succeeds for other protocol family like IPPROTO_TCP of IPPROTO_ICMP .. etc. The following is the code snippet . ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Code Starts here ^^^^^^^^^^^^^^^^^^^^^^^^ #include <sys/socket.h> #include <sys/types.h> #include <netinet/in.h> #include <netdb.h> #include <stdio.h> #include <string.h> #include <stdlib.h> #include <arpa/inet.h> #include <unistd.h> #include <errno.h> #include <iostream.h> int main() { int fd; struct sockaddr_in serv_sock,cli_sock; if ((fd = socket(AF_INET,SOCK_RAW,0)) < 0) { cout<<"error "<<errno<<endl; } //raw sockets dont require binding .. do they ?? listen(fd,5); fd_set fdset; while(1) { FD_ZERO(&fdset); FD_SET(fd,&fdset); int ret = select(fd+1,&fdset,NULL,NULL,NULL); if (FD_ISSET(fd,&fdset)) { cout<<"hello"<<endl; break; } } printf("program terminates"); return 0; } ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Code Ends here ^^^^^^^^^^^^^^^^^^^^^^^^ My problem is only with socket creation using IPPROTO_IP or IPPROTO_RAW ... the value of errno after the call is 94 which is # defined in <asm/errno.h> as #define ESOCKTNOSUPPORT 94 /* Socket type not supported */ Does redhat AS 3.0 not allow creation of IPPROTO_IP or IPPROTO_RAW type sockets. or do i have to enable the support in kernel. Thanks a ton in advance !!! Warm Regards N.Harris ur rahman |
u need to use _TCP/_UDP/_ICMP , those others won't work. but u can do everything that u need with the above mentioned. if u want to see outgoing packets, u need to do:
Code:
struct sockaddr_ll sa; |
All times are GMT -5. The time now is 07:47 AM. |