Hi,

I'm making setsockopt() call in my program to set the socket options. But I have been getting the following error.
Protocol not available

I need my system to work in RAW socket, and for RAW socket I need to use the IPPROTO_IP level, which seems to be creating the problem.

Can anyone help me solve this problem?
Code attached below.
Code:
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
#include <string.h>
#include <sys/socket.h>
#include <unistd.h>
#include <arpa/inet.h>
#include <sys/poll.h>
#include <netdb.h>
#include <popt.h>
#include <sys/types.h>
#include <errno.h>
#include <netinet/in.h>
#include <stdlib.h>
#include <string.h>
#include <netdb.h>
#include <linux/if_ether.h>
#include <netinet/in.h>
#include "tcpsp.h"
 
int main()
{
	int sockfd, len, err;
	int optval;
	char protoname[10];
	char *protoname1 = NULL;
	struct sockaddr_in addr;
	struct protoent *proto = NULL;
	sockfd = socket(PF_PACKET, SOCK_RAW, IPPROTO_RAW);
	if(sockfd == -1)
	{
		perror("creation error");
		exit(4);
	}
	//	err = setsockopt(sockfd,IPPROTO_RAW,5,(void*) optval, sizeof(optval));
	err = setsockopt(sockfd,IPPROTO_IPV6,IP_TOS,(void*) optval, sizeof(optval));
	if(-1 == err)
	{
		perror("socket options error");
		exit(3);
	}
	
/*	addr.sin_family = PF_PACKET;
	addr.sin_addr.s_addr = inet_addr("127.0.0.1");
	addr.sin_port = htons(8120);
	len = sizeof(addr);

	do{
	proto = getprotobyname("TCP");
	printf("%c\n",proto->p_name);
	strcpy(protoname, proto->p_name);
	}while((*protoname != "TCP") || (*protoname != "tcp"));*/

	return 0;
}
another query?
Does the setsockopt call map to (*set) function in the nf_sock_ops structure?