summaryrefslogtreecommitdiff
path: root/libsoup/soup-address.h
blob: 5de2b0919998d6a3a644d6bb83d6f4c5661963cd (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
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
 * Copyright (C) 2000-2003, Ximian, Inc.
 */

#ifndef SOUP_ADDRESS_H
#define SOUP_ADDRESS_H

#include <glib-object.h>
#include <sys/types.h>
#include <sys/socket.h>

#include <libsoup/soup-error.h>

#define SOUP_TYPE_ADDRESS            (soup_address_get_type ())
#define SOUP_ADDRESS(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), SOUP_TYPE_ADDRESS, SoupAddress))
#define SOUP_ADDRESS_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), SOUP_TYPE_ADDRESS, SoupAddressClass))
#define SOUP_IS_ADDRESS(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SOUP_TYPE_ADDRESS))
#define SOUP_IS_ADDRESS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), SOUP_TYPE_ADDRESS))
#define SOUP_ADDRESS_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS ((obj), SOUP_TYPE_ADDRESS, SoupAddressClass))

typedef struct SoupAddressPrivate SoupAddressPrivate;

typedef struct {
	GObject parent;

	SoupAddressPrivate *priv;
} SoupAddress;

typedef struct {
	GObjectClass parent_class;

	/* signals */
	void (*dns_result) (SoupAddress *addr, SoupKnownErrorCode);
} SoupAddressClass;

typedef enum {
	SOUP_ADDRESS_FAMILY_IPV4 = AF_INET,
#ifdef AF_INET6
	SOUP_ADDRESS_FAMILY_IPV6 = AF_INET6
#else
	SOUP_ADDRESS_FAMILY_IPV6 = -1
#endif
} SoupAddressFamily;

#define SOUP_ADDRESS_ANY_PORT 0

GType soup_address_get_type (void);

SoupAddress     *soup_address_new                (const char          *name,
						  guint                port);
SoupAddress     *soup_address_new_from_sockaddr  (struct sockaddr     *sa,
						  int                  len);
SoupAddress     *soup_address_new_any            (SoupAddressFamily    family,
						  guint                port);

typedef void   (*SoupAddressCallback)            (SoupAddress         *addr,
						  SoupKnownErrorCode   status,
						  gpointer             data);
void             soup_address_resolve            (SoupAddress         *addr,
						  SoupAddressCallback  cb,
						  gpointer             data);

const char      *soup_address_get_name           (SoupAddress         *addr);
struct sockaddr *soup_address_get_sockaddr       (SoupAddress         *addr,
						  int                 *len);
const char      *soup_address_get_physical       (SoupAddress         *addr);
guint            soup_address_get_port           (SoupAddress         *addr);

#endif /* SOUP_ADDRESS_H */