~jan-kneschke/mysql-proxy/packet-tracking-assertions

« back to all changes in this revision

Viewing changes to src/network-address.h

  • Committer: Kay Roepke
  • Author(s): Jan Kneschke
  • Date: 2008-01-23 22:00:28 UTC
  • Revision ID: kay@mysql.com-20080123220028-hq2xqb69apa75fnx
first round on mysql-shell based on the proxy code

this is mostly a verification if the proxy-code is flexible enough to handle 
all three scenarios of: client, server and forwarding (proxy)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* $%BEGINLICENSE%$
2
 
 Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved.
3
 
 
4
 
 This program is free software; you can redistribute it and/or
5
 
 modify it under the terms of the GNU General Public License as
6
 
 published by the Free Software Foundation; version 2 of the
7
 
 License.
8
 
 
9
 
 This program is distributed in the hope that it will be useful,
10
 
 but WITHOUT ANY WARRANTY; without even the implied warranty of
11
 
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
 
 GNU General Public License for more details.
13
 
 
14
 
 You should have received a copy of the GNU General Public License
15
 
 along with this program; if not, write to the Free Software
16
 
 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
17
 
 02110-1301  USA
18
 
 
19
 
 $%ENDLICENSE%$ */
20
 
 
21
 
 
22
 
#ifndef _NETWORK_ADDRESS_H_
23
 
#define _NETWORK_ADDRESS_H_
24
 
 
25
 
#ifdef HAVE_CONFIG_H
26
 
#include "config.h"
27
 
#endif
28
 
 
29
 
#include <glib.h>
30
 
 
31
 
#ifndef _WIN32
32
 
#ifdef HAVE_NETINET_IN_H
33
 
#include <netinet/in.h>     /** struct sockaddr_in */
34
 
#endif
35
 
#include <netinet/tcp.h>
36
 
 
37
 
#ifdef HAVE_SYS_UN_H
38
 
#include <sys/un.h>         /** struct sockaddr_un */
39
 
#endif
40
 
#include <sys/socket.h>     /** struct sockaddr (freebsd and hp/ux need it) */
41
 
#else
42
 
#include <winsock2.h>
43
 
#include <Ws2tcpip.h>
44
 
#endif
45
 
 
46
 
#include "network-exports.h"
47
 
 
48
 
#ifdef __hpux
49
 
/* see http://curl.haxx.se/mail/lib-2009-04/0287.html */
50
 
typedef int network_socklen_t;
51
 
#else
52
 
typedef socklen_t network_socklen_t;
53
 
#endif
54
 
 
55
 
typedef struct {
56
 
        union {
57
 
                struct sockaddr_in ipv4;
58
 
                struct sockaddr_in6 ipv6;
59
 
#ifdef HAVE_SYS_UN_H
60
 
                struct sockaddr_un un;
61
 
#endif
62
 
                struct sockaddr common;
63
 
        } addr;
64
 
 
65
 
        GString *name; 
66
 
        network_socklen_t len;
67
 
        gboolean can_unlink_socket; /* set TRUE *only* after successful bind */
68
 
} network_address;
69
 
 
70
 
NETWORK_API network_address *network_address_new(void);
71
 
NETWORK_API void network_address_free(network_address *);
72
 
NETWORK_API void network_address_reset(network_address *addr);
73
 
NETWORK_API network_address *network_address_copy(network_address *dst, network_address *src);
74
 
NETWORK_API gint network_address_set_address(network_address *addr, const gchar *address);
75
 
NETWORK_API gint network_address_refresh_name(network_address *addr);
76
 
NETWORK_API gint network_address_is_local(network_address *dst_addr, network_address *src_addr);
77
 
 
78
 
#endif