aboutsummaryrefslogtreecommitdiff
path: root/include/argot/sockaddr.h
blob: e5325c1610b3af46f158678323041887ac1cf2e0 (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
/* argot - Gray's Extensible Configuration System -*- c -*-
   Copyright (C) 2007-2016 Sergey Poznyakoff

   Grecs is free software; you can redistribute it and/or modify it
   under the terms of the GNU General Public License as published by the
   Free Software Foundation; either version 3 of the License, or (at your
   option) any later version.

   Grecs is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.

   You should have received a copy of the GNU General Public License along
   with Grecs. If not, see <http://www.gnu.org/licenses/>. */

#ifndef _ARGOT_SOCKADDR_H
#define _ARGOT_SOCKADDR_H

struct argot_sockaddr {
#if ARGOT_SOCKADDR_LIST
	struct argot_sockaddr *next;
#endif
	int len;
	struct sockaddr *sa;
};

#if ARGOT_SOCKADDR_LIST

#define ARGOT_AH_PASSIVE 0x01
#define ARGOT_HINT_SERVICE 0x02
#define ARGOT_HINT_PORT 0x04

struct argot_sockaddr_hints {
	int flags;
	char *service;
	unsigned short port;
};

extern struct argot_sockaddr_hints *argot_sockaddr_hints;

struct argot_sockaddr *argot_sockaddr_new(size_t s);
void argot_sockaddr_free(struct argot_sockaddr *p);

int argot_str_to_sockaddr(struct argot_sockaddr **sap,
			  const char *arg, struct argot_sockaddr_hints *gh,
			  argot_locus_t const *locus);
#endif

#define ARGOT_INADDR_BYTES 16

struct argot_cidr
{
    int family;
    int len;
    unsigned char address[ARGOT_INADDR_BYTES];
    unsigned char netmask[ARGOT_INADDR_BYTES];
};

int argot_str_to_cidr(struct argot_cidr *pcidr, const char *str,
		      argot_locus_t const *locus);

int argot_sockaddr_to_cidr(struct argot_cidr *cidr, const struct sockaddr *sa);
int argot_sockadd_cidr_match(struct sockaddr *sa, struct argot_cidr *cidr);

#endif

Return to:

Send suggestions and report system problems to the System administrator.