[net.unix-wizards] Raw AF_INET ICMP sockets

andy@lasspvax.UUCP (Andy Pfiffer) (08/06/85)

I'm trying to get a public domain pinger (from Mike Muus, Army Ballistic
Research Lab.) to run.  Simply, why does:

	.
	.
	if ((s = socket(AF_INET, SOCK_RAW, IPPROTO_ICMP)) < 0) {
		perror("ping: socket");
		exit(5);
	}
	.
	.

generate:

	ping: socket: Protocol wrong type for socket

??  Can't I create a socket like this? It runs setuid root...
Frustrated. Help...
-- 
=========================================================
USENET:	{decvax,ihnp4,cmcl2,vax135}!cornell!devvax!andy
ARPA:	andy%devvax@Cornell.arpa
MAIL:	Theory Center/265 Olin Hall   "What do you mean
	Cornell University             I watch too much
	Ithaca, NY  14853              TV?"
PHONE:	(607) 256-8686
=========================================================

mike@BRL.ARPA (Mike Muuss) (08/12/85)

As the comment on the front of PING.C says, it depends on
your having installed various fixes to your kernel.
Most importantly, you have to change /sys/netinet/in_proto.c:

Remove:
< { 0,		PF_INET,	IPPROTO_ICMP,	0,
<   icmp_input,	0,		0,		0,
<   0,
<   0,		0,		0,		0,
< },

At the end of the protosw table, add:
> { SOCK_RAW,	PF_INET,	IPPROTO_ICMP,	PR_ATOMIC|PR_ADDR,
>   icmp_input,	rip_output,	0,		0,
>   raw_usrreq,
>   0,		0,		0,		0,
> },

This will be enough to get you started.  There are bugs in
ip_input.c as well;  contact me by electronic mail if you
need these changes too;  they are too numerous to post here.

Best,
 -Mike Muuss

(301)-278-6678
  AV  283-6678
  FTS 939-6678

ArpaNet:  Mike @ BRL
UUCP:     ...!{decvax,cbosgd}!brl-bmd!mike
Postal:
  Mike Muuss
  Leader, Advanced Computer Systems Team
  Computer Science and Mathematics Branch
  Systems Engineering and Concepts Analysis Division
  U.S. Army Ballistic Research Laboratory
  Attn: AMXBR-SECAD (Muuss)
  APG, MD  21005