File: mod_icmp.h

package info (click to toggle)
bing 1.3.5-5
  • links: PTS
  • area: main
  • in suites: bookworm, sid
  • size: 456 kB
  • sloc: ansic: 3,774; makefile: 51
file content (118 lines) | stat: -rw-r--r-- 2,997 bytes parent folder | download | duplicates (3)
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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
/*
 * This file provides a system independant interface to send and
 * receive ICMP messages.
 */

/* $Id: mod_icmp.h,v 1.3 1999/10/11 05:25:19 fgouget Exp $ */

#ifndef _mod_icmp_h_
#define _mod_icmp_h_

#if defined(__STDC__) || defined(__cplusplus)
#define PROTO(a,b) a b
#else
#define PROTO(a,b) a()
#endif
#ifdef __cplusplus
#define API "C"
#else
#define API
#endif

typedef void* icmp_handle;

/* initialize the ICMP module, return a pointer to it. */
extern icmp_handle PROTO(
   icmp_open,
   (
	void
   ));

/* set a socket option. Returns >= 0 if successful, -1 otherwise */
extern int PROTO(
   icmp_set_option,
   (
	icmp_handle handle,	/* module handle */
	int level,
	int optname,		/* option to be set */
	void *optval,		/* option value */
	int optlen		/* length of option value */
   ));

/* set the timeout for receives */
extern void PROTO(
   icmp_set_timeout,
   (
	icmp_handle handle,
	unsigned long timeout	/* timeout in microseconds */
   ));

/* get the ID used in packets */
extern unsigned short PROTO(
   icmp_get_id,
   (
	icmp_handle handle
   ));

/**
 * Sends an ICMP message.
 * (!!) this will have to be extended to support any kind of message (e.g. UDP)
 *
 * @param handle the icmp handle
 * @param msg points to a buffer containing the message
 *        (!!) what does this contain exactly? the ip options, the icmp header, just the data
 * @param msg_size the message size
 * @param to_addr the address of the host to which the message is to be sent
 * @param to_addr_size the size of the destination host address
 * @return >=0 if successful, -1 otherwise
 */
extern int PROTO(
   icmp_send,
   (
	icmp_handle handle,
	void *msg,
	int msg_size,
	struct sockaddr *to_addr,
	int to_addr_size
   ));

/**
 * Waits for an ICMP message.
 * (!!) in fact this should be any message since we might send UDP messages too
 *
 * @param handle the icmp handle
 * @param buffer must point to a buffer in which the message will be stored. If the 
 *        buffer is too small the function will fail
 *        (!!) what is stored ? just the datsa, the icmp header, the ip header too ?
 * @param buffer_size the size of the allocated buffer. This value is modified to 
 *        store the actual size of the message
 * @param from_addr must point to a buffer in which to store the address of the 
 *        host this message was received from
 * @param from_addr_size the size of the from_addr buffer. On return this contains the 
 *        actual size of the address stored in the buffer.
 * @return >0 if successful, 0 if the function timed out and -1 if it failed
 *         (!!) it said "-1: interrupted, should be called again"
 */
extern int PROTO(
   icmp_recv,
   (
	icmp_handle handle,
	char *buffer,
	int buffer_size,
	struct sockaddr *from_addr,
	int *from_addr_size,
	double *elapsed
   ));

/**
 * Closes the ICMP handle.
 *
 * @return >=0 if successful, -1 otherzise
 */
extern int PROTO(
   icmp_close,
   (
	icmp_handle handle
   ));

#endif	/* End of File */