1/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
2/*
3 * Copyright (C) 2000-2003, Ximian, Inc.
4 */
5
6#ifndef __SOUP_ADDRESS_H__
7#define __SOUP_ADDRESS_H__
8
9#include <sys/types.h>
10
11#include <libsoup/soup-types.h>
12
13G_BEGIN_DECLS
14
15#define SOUP_TYPE_ADDRESS (soup_address_get_type ())
16#define SOUP_ADDRESS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SOUP_TYPE_ADDRESS, SoupAddress))
17#define SOUP_ADDRESS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SOUP_TYPE_ADDRESS, SoupAddressClass))
18#define SOUP_IS_ADDRESS(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SOUP_TYPE_ADDRESS))
19#define SOUP_IS_ADDRESS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), SOUP_TYPE_ADDRESS))
20#define SOUP_ADDRESS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SOUP_TYPE_ADDRESS, SoupAddressClass))
21
22struct _SoupAddress {
23 GObject parent;
24
25};
26
27typedef struct {
28 GObjectClass parent_class;
29
30 /* Padding for future expansion */
31 void (*_libsoup_reserved1) (void);
32 void (*_libsoup_reserved2) (void);
33 void (*_libsoup_reserved3) (void);
34 void (*_libsoup_reserved4) (void);
35} SoupAddressClass;
36
37#define SOUP_ADDRESS_NAME "name"
38#define SOUP_ADDRESS_FAMILY "family"
39#define SOUP_ADDRESS_PORT "port"
40#define SOUP_ADDRESS_PROTOCOL "protocol"
41#define SOUP_ADDRESS_PHYSICAL "physical"
42#define SOUP_ADDRESS_SOCKADDR "sockaddr"
43
44typedef enum {
45 SOUP_ADDRESS_FAMILY_INVALID = -1,
46
47 SOUP_ADDRESS_FAMILY_IPV4 = G_SOCKET_FAMILY_IPV4,
48 SOUP_ADDRESS_FAMILY_IPV6 = G_SOCKET_FAMILY_IPV6
49} SoupAddressFamily;
50
51#define SOUP_ADDRESS_ANY_PORT 0
52
53struct sockaddr;
54
55typedef void (*SoupAddressCallback) (SoupAddress *addr,
56 guint status,
57 gpointer user_data);
58
59SOUP_AVAILABLE_IN_2_4
60GType soup_address_get_type (void);
61
62SOUP_AVAILABLE_IN_2_4
63SoupAddress *soup_address_new (const char *name,
64 guint port);
65SOUP_AVAILABLE_IN_2_4
66SoupAddress *soup_address_new_from_sockaddr (struct sockaddr *sa,
67 int len);
68SOUP_AVAILABLE_IN_2_4
69SoupAddress *soup_address_new_any (SoupAddressFamily family,
70 guint port);
71
72SOUP_AVAILABLE_IN_2_4
73void soup_address_resolve_async (SoupAddress *addr,
74 GMainContext *async_context,
75 GCancellable *cancellable,
76 SoupAddressCallback callback,
77 gpointer user_data);
78SOUP_AVAILABLE_IN_2_4
79guint soup_address_resolve_sync (SoupAddress *addr,
80 GCancellable *cancellable);
81
82SOUP_AVAILABLE_IN_2_4
83const char *soup_address_get_name (SoupAddress *addr);
84SOUP_AVAILABLE_IN_2_4
85const char *soup_address_get_physical (SoupAddress *addr);
86SOUP_AVAILABLE_IN_2_4
87guint soup_address_get_port (SoupAddress *addr);
88SOUP_AVAILABLE_IN_2_4
89struct sockaddr *soup_address_get_sockaddr (SoupAddress *addr,
90 int *len);
91SOUP_AVAILABLE_IN_2_32
92GSocketAddress *soup_address_get_gsockaddr (SoupAddress *addr);
93SOUP_AVAILABLE_IN_2_4
94gboolean soup_address_is_resolved (SoupAddress *addr);
95
96SOUP_AVAILABLE_IN_2_26
97guint soup_address_hash_by_name (gconstpointer addr);
98SOUP_AVAILABLE_IN_2_26
99gboolean soup_address_equal_by_name (gconstpointer addr1,
100 gconstpointer addr2);
101SOUP_AVAILABLE_IN_2_26
102guint soup_address_hash_by_ip (gconstpointer addr);
103SOUP_AVAILABLE_IN_2_26
104gboolean soup_address_equal_by_ip (gconstpointer addr1,
105 gconstpointer addr2);
106
107
108G_END_DECLS
109
110#endif /* __SOUP_ADDRESS_H__ */
111