File: netinet.h

package info (click to toggle)
oskit 0.97.20000202-1
  • links: PTS
  • area: main
  • in suites: potato
  • size: 58,008 kB
  • ctags: 172,612
  • sloc: ansic: 832,827; asm: 7,640; sh: 3,920; yacc: 3,664; perl: 1,457; lex: 427; makefile: 337; csh: 141; awk: 78
file content (100 lines) | stat: -rw-r--r-- 4,376 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
/* Struct defs hacked from netinet headers. */
/*
 * Copyright (c) 1982, 1986, 1993
 *      The Regents of the University of California.  All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 * 3. All advertising materials mentioning features or use of this software
 *    must display the following acknowledgement:
 *      This product includes software developed by the University of
 *      California, Berkeley and its contributors.
 * 4. Neither the name of the University nor the names of its contributors
 *    may be used to endorse or promote products derived from this software
 *    without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 * SUCH DAMAGE.
 */

#ifndef __NETINET_H_INCLUDED__
#define __NETINET_H_INCLUDED__

struct	arphdr {
	unsigned short	ar_hrd;		/* format of hardware address */
#define ARPHRD_ETHER 	1		/* ethernet hardware format */
	unsigned short	ar_pro;		/* format of protocol address */
	unsigned char	ar_hln;		/* length of hardware address */
	unsigned char	ar_pln;		/* length of protocol address */
	unsigned short	ar_op;		/* one of: */
#define	ARPOP_REQUEST	1		/* request to resolve address */
#define	ARPOP_REPLY	2		/* response to previous request */
	unsigned char	ar_sha[6];	/* sender hardware address (ethernet) */
	unsigned char	ar_spa[4];	/* sender protocol address (IP) */
	unsigned char	ar_tha[6];	/* target hardware address (ethernet) */
	unsigned char	ar_tpa[4];	/* target protocol address (IP) */
};

struct real_arphdr {
	unsigned short	ar_hrd;		/* format of hardware address */
	unsigned short	ar_pro;		/* format of protocol address */
	unsigned char	ar_hln;		/* length of hardware address */
	unsigned char	ar_pln;		/* length of protocol address */
	unsigned short	ar_op;		/* one of: */
};

struct ether_arp {
	struct real_arphdr ea_hdr;      /* fixed-size header */
	unsigned char      arp_sha[6];  /* sender hardware address (ethernet) */
	unsigned char      arp_spa[4];  /* sender protocol address (IP) */
	unsigned char      arp_tha[6];  /* target hardware address (ethernet) */
	unsigned char      arp_tpa[4];  /* target protocol address (IP) */
};

#define arp_hrd ea_hdr.ar_hrd
#define arp_pro ea_hdr.ar_pro
#define arp_hln ea_hdr.ar_hln
#define arp_pln ea_hdr.ar_pln
#define arp_op  ea_hdr.ar_op

struct ip {
	/* Little endian. */
        unsigned char	ip_hl:4,	/* header length */
			ip_v:4;		/* version */
        unsigned char	ip_tos;		/* type of service */
        short		ip_len;		/* total length */
        unsigned short	ip_id;		/* identification */
        short		ip_off;		/* fragment offset field */
        unsigned char	ip_ttl;		/* time to live */
        unsigned char	ip_p;		/* protocol */
#define IPPROTO_ICMP 1
        unsigned short	ip_sum;		/* checksum */
        struct	in_addr ip_src,ip_dst;  /* source and dest address */
};

struct icmp {
        unsigned char	icmp_type;	/* type of message, see below */
#define ICMP_ECHO 8
#define ICMP_ECHOREPLY 0
        unsigned char	icmp_code;	/* type sub code */
        unsigned short	icmp_cksum;	/* ones complement cksum of struct */
	unsigned short	icmp_id;
	unsigned short	icmp_seq;
};

#endif /* __NETINET_H_INCLUDED__ */