summaryrefslogtreecommitdiff
path: root/support/dktools/dk3nettp.h
blob: 90867028fd83f6c003883f0cfb07322a549ef4e8 (plain)
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

#ifndef	DK3NETTP_H_INCLUDED
#define	DK3NETTP_H_INCLUDED 1


#include <dk3all.h>



#if DK3_ON_WINDOWS || DK3_HAVE_SOCKET



/**	IPv4 address.
*/
typedef struct {

  /**	IP address in net representation.
  */
  struct sockaddr_in	soin;

  /**	Minimum port number to use for local ip address.
  */
  unsigned short	portmin;

  /**	Maximum port number. When binding a local address we can specify
  	a port range portno-portmax.
  */
  unsigned short	portmax;

} dk3_ip_addr_t;




/**	Socket address.
*/
typedef struct sockaddr		DK3_SOA;

/**	Internet socket address.
*/
typedef struct sockaddr_in	DK3_SOAIN;

/**	Size of internet socket address.
*/
#define	DK3_SZ_SOAIN		sizeof(DK3_SOAIN)



/**	Network socket.
*/
typedef struct {

  /**	Local IP address.
  */
  dk3_ip_addr_t		 local;

  /**	Remote IP address wished.
	This address is used when sending UDP packets.
  */
  dk3_ip_addr_t		 remote_wished;

  /**	Remote IP address found.
	When receiving UDP packets, the sender address is stored here.
  */
  dk3_ip_addr_t		 remote_found;

  /**	Application structure for diagnostics and preferences.
  */
  dk3_app_t		*app;

#if DK3_ON_WINDOWS
  /**	File descriptor, the real socket.
  */
  SOCKET		fd;
#else
  /**	File descriptor, the real socket.
  */
  int			fd;
#endif

  /**	Socket state, DK3_SOCKET_STATE_xxx.
  */
  int			st;

  /**	Flag: End of input data found (0 bytes read).
  */
  int			eod_found;

  /**	Flag: Write shutdown was sent to peer during close operation.
  */
  int			shutdown_done;

} dk3_socket_t;


#endif
/* if DK3_ON_WINDOWS || DK3_HAVE_SOCKET */


#endif
/* if DK3NETTP_H_INCLUDED */