LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices



Reply
 
Search this Thread
Old 06-17-2004, 11:00 AM   #1
linfreak
LQ Newbie
 
Registered: Oct 2003
Posts: 14

Rep: Reputation: 0
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
 
Old 06-17-2004, 11:53 AM   #2
nukkel
Member
 
Registered: Mar 2003
Location: Belgium
Distribution: Hardened gentoo
Posts: 323

Rep: Reputation: 30
Don't know about the error you get, but I think you DO need to bind() a raw socket too, since you're still using the IP layer for addressing; it's only the transport layer protocol that is non-{udp|tcp}. So you still need to bind() to an IP address, I think.

Good luck fixing it!
nukkel

Last edited by nukkel; 06-17-2004 at 11:54 AM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
socket: Socket type not supported monindra Fedora - Installation 4 01-14-2008 08:25 AM
error: conflicting types for `IPPROTO_IP' Anastasia Linux - Software 0 07-14-2005 07:12 AM
Raw socket creation error (IPPROTO_IP not supported) linfreak Programming 1 06-17-2004 01:37 PM
Socket Raw linuxanswer Programming 1 04-01-2004 10:43 PM
raw ipv6 socket example Steave Programming 0 06-27-2003 04:55 PM


All times are GMT -5. The time now is 06:44 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration