From owner-freebsd-hackers Thu Sep 20 15:48: 6 2001 Delivered-To: freebsd-hackers@freebsd.org Received: from elvis.mu.org (elvis.mu.org [216.33.66.196]) by hub.freebsd.org (Postfix) with ESMTP id 645A137B410 for ; Thu, 20 Sep 2001 15:48:04 -0700 (PDT) Received: by elvis.mu.org (Postfix, from userid 1192) id 45CED81D05; Thu, 20 Sep 2001 17:47:59 -0500 (CDT) Date: Thu, 20 Sep 2001 17:47:59 -0500 From: Alfred Perlstein To: David Preece Cc: hackers@freebsd.org Subject: Re: sendto not sending what I asked... Message-ID: <20010920174759.B61456@elvis.mu.org> References: <01092110333803.36513@development.wgtn.csg.co.nz> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5i In-Reply-To: <01092110333803.36513@development.wgtn.csg.co.nz>; from davep@afterswish.com on Fri, Sep 21, 2001 at 10:33:38AM +1200 Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG * David Preece [010920 17:35] wrote: > Hi, > > I'm trying to write a raw (SYN) packet with sendto. I've opened the socket > with socket(AF_INET, SOCK_RAW, IPPROTO_RAW), the result is checked and it is > unbound. A buffer and a sockaddr_in are formed then sent down the socket with > sendto(sck,pBuffer,40,0,(struct sockaddr *)&sin,sizeof(sin)) and the packet > captured using ethereal. While the packet does send, with the correct source > and destination addresses, the buffer I pass is appended as data on the end > of an IP packet with unknown protocol, rather than replacing the IP and TCP > headers (i.e. appending the ethernet header) as I had hoped. > > Has anyone seen this before? Is there a socket option I have missed? I've > R'dTFM till I'm blue in the face, and all the examples I can find seem to be > for Linux on big endian machines :( It would help if you'd provided what you think you're sending and what the other end is actually seeing. Without that I can't help much except to suggest that you make sure you're using htons/htonl in the right spot and on the right size types. I used htons instead of htonl on a 32 bit datum and it took me a good half a day to figure out what i had done wrong. > PS. No, not a packet kiddie. none of us are... really. >;) -- -Alfred Perlstein [alfred@freebsd.org] 'Instead of asking why a piece of software is using "1970s technology," start asking why software is ignoring 30 years of accumulated wisdom.' To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message