[Search for users]
[Overall Top Noters]
[List of all Conferences]
[Download this site]
Title: | "ASK THE WIZARDS" |
|
Moderator: | QUARK::LIONEL |
|
Created: | Mon Oct 30 1995 |
Last Modified: | Mon May 12 1997 |
Last Successful Update: | Fri Jun 06 1997 |
Number of topics: | 1857 |
Total number of notes: | 3728 |
1694.0. "Open: why the problem with RAW socket?" by STAR::JKEENAN () Mon Mar 24 1997 13:12
Return-Path: "VMS001::WWW"@vms001.das-x.dec.com
Received: by vmsmkt.zko.dec.com (UCX V4.1-12, OpenVMS V6.2 VAX);
Mon, 24 Mar 1997 11:54:37 -0500
Received: from vms001 by mail12.digital.com (8.7.5/UNX 1.5/1.0/WV)
id LAA05509; Mon, 24 Mar 1997 11:43:51 -0500 (EST)
Date: Mon, 24 Mar 1997 11:46:21 -0500
Message-Id: <[email protected]>
From: "VMS001::WWW"@vms001.das-x.dec.com (24-Mar-1997 1146)
To: [email protected], [email protected], [email protected]
Subject: Ask the Wizard: '[email protected]'
X-VMS-To: [email protected]
Remote Host: (null)
Browser Type: Mozilla/3.0Gold (WinNT; I)
Remote Info: <null>
Name: Ruslan R. Laishev
Email Address: [email protected]
CPU Architecture: VAX
Version: v 6.1
Questions:
Dear Wizard !
I'm have write small programm with RAW socket, and when she/he
running I see (with TCPIPTRACE utility) what is IP packet's
outgoing and incoming to my HOST.
But I seen also that several fields in IP/TCP packet = -1.
And size of of PACKET realy transmited 60 byte, but I send
40 byte.
Why ?
I'm need more information or any source of C program that
demonstrate using RAW_IP/SOCK_RAW style socket.
But non-ICMP.
This is as fragment from my programm:
int SendTCP_SYN ( struct sockaddr_in *sin,
int s,
u_long baddr,
u_short sport,
u_long seq
)
{
struct pkt {
struct ip ip_pkt;
struct tcphdr tcp;
} pkt;
struct stuff {
u_long src;
u_long dst;
char mbz;
u_char proto;
u_short len;
struct tcphdr tcp;
} stuff;
memset(&pkt,0,sizeof(pkt));
pkt.ip_pkt.ip_v = 4;
pkt.ip_pkt.ip_hl = 5;
pkt.ip_pkt.ip_tos = 0;
pkt.ip_pkt.ip_len = htons(sizeof(pkt));
pkt.ip_pkt.ip_id = htons (rand() % 2600);
pkt.ip_pkt.ip_off = 0;
pkt.ip_pkt.ip_ttl = 55;
pkt.ip_pkt.ip_p = IPPROTO_TCP;
pkt.ip_pkt.ip_src.S_un.S_addr = baddr;
pkt.ip_pkt.ip_dst.S_un.S_addr = sin->sin_addr.S_un.S_addr;
pkt.ip_pkt.ip_sum = 0;
pkt.ip_pkt.ip_sum = in_cksum(&pkt.ip_pkt, sizeof(pkt.ip_pkt));
pkt.ip_pkt.ip_sum = in_cksum(&pkt.ip_pkt, sizeof(pkt.ip_pkt));
pkt.tcp.th_sport = htons (sport);
pkt.tcp.th_dport = sin->sin_port;
pkt.tcp.th_seq = htonl (seq);
pkt.tcp.th_ack = 0;
pkt.tcp.th_x2 = 0;
pkt.tcp.th_off = 5;
pkt.tcp.th_flags = TH_SYN;
pkt.tcp.th_win = htons(10052);
pkt.tcp.th_sum = 0;
pkt.tcp.th_urp = 0;
pkt.tcp.th_sum = 0;
memset (&stuff,0,sizeof(stuff));
stuff.src = pkt.ip_pkt.ip_src.S_un.S_addr;
stuff.dst = pkt.ip_pkt.ip_dst.S_un.S_addr;
stuff.proto = pkt.ip_pkt.ip_p;
stuff.len = sizeof(pkt.tcp);
memcpy (&stuff.tcp,&pkt.tcp,sizeof(pkt.tcp));
pkt.tcp.th_sum = in_cksum(&stuff, sizeof(stuff));
if (0 > sendto (s,&pkt,sizeof(pkt),0,(struct sockaddr *)sin,
sizeof(struct sockaddr_in)) )
perror("sendto");
}
T.R | Title | User | Personal Name | Date | Lines |
---|
1694.1 | Headers Take Space, Too... | XDELTA::HOFFMAN | Steve, OpenVMS Engineering | Mon Mar 24 1997 18:21 | 7 |
|
If looking directly at low-level traffic, one must remember to account
for the space used for the IP header, and for the TCP or UDP header.
There are various texts and specifications that cover the low-level
operation of various IP protocols.
|