~ubuntu-branches/ubuntu/wily/dhcpcd5/wily-proposed

« back to all changes in this revision

Viewing changes to if.h

  • Committer: Package Import Robot
  • Author(s): Daniel Echeverry
  • Date: 2015-06-03 10:43:23 UTC
  • mfrom: (7.1.3 sid)
  • Revision ID: package-import@ubuntu.com-20150603104323-74htea00somdput9
Tags: 6.9.0-1
* QA Upload
* New upstream release. Closes: #786772, #758713, #782085, #788693
* debian/control
  + Use Replaces instead Conflicts field
  + Bump Standards-Version 3.9.6
    + Update to DEP5 copyright format 1.0
* debian/rules
  + Add DEB_HOST_GNU_TYPE and DEB_BUILD_GNU_TYPE
* debian/patches
  + Add fix_ftbfs_kfreebsd.diff patch
    + Fix ftbfs on kfreebsd Closes: #770464
  + Add fix_manpage.diff patch
    * Fix lintian warning
  + Remove CVE-2014-6060.patch patch
    + Merge with upstream
  + Remove kfreebsd.diff patch
    * Upstream removed platform-bsd.c file in new version
* debian/prerm
  + Replace bashim with set -e
* debian/postint
  + Replace bashim with set -e
* debian/postrm
  + Replace bashim with set -e

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * dhcpcd - DHCP client daemon
 
3
 * Copyright (c) 2006-2015 Roy Marples <roy@marples.name>
 
4
 * All rights reserved
 
5
 
 
6
 * Redistribution and use in source and binary forms, with or without
 
7
 * modification, are permitted provided that the following conditions
 
8
 * are met:
 
9
 * 1. Redistributions of source code must retain the above copyright
 
10
 *    notice, this list of conditions and the following disclaimer.
 
11
 * 2. Redistributions in binary form must reproduce the above copyright
 
12
 *    notice, this list of conditions and the following disclaimer in the
 
13
 *    documentation and/or other materials provided with the distribution.
 
14
 *
 
15
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
 
16
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 
17
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 
18
 * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
 
19
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 
20
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
 
21
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 
22
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 
23
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
 
24
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 
25
 * SUCH DAMAGE.
 
26
 */
 
27
 
 
28
#ifndef INTERFACE_H
 
29
#define INTERFACE_H
 
30
 
 
31
#include <net/if.h>
 
32
#ifdef __FreeBSD__
 
33
#include <net/if_var.h>
 
34
#endif
 
35
#include <net/route.h>          /* for RTM_ADD et all */
 
36
#include <netinet/in.h>
 
37
#ifdef BSD
 
38
#include <netinet/in_var.h>     /* for IN_IFF_TENTATIVE et all */
 
39
#endif
 
40
 
 
41
/* Some systems have route metrics.
 
42
 * OpenBSD route priority is not this. */
 
43
#ifndef HAVE_ROUTE_METRIC
 
44
# if defined(__linux__)
 
45
#  define HAVE_ROUTE_METRIC 1
 
46
# endif
 
47
#endif
 
48
 
 
49
/* Some systems have in-built IPv4 DAD.
 
50
 * However, we need them to do DAD at carrier up as well. */
 
51
#ifdef IN_IFF_TENTATIVE
 
52
#  ifdef __NetBSD__
 
53
#    define NOCARRIER_PRESERVE_IP
 
54
#  endif
 
55
#endif
 
56
 
 
57
#include "config.h"
 
58
#include "dhcpcd.h"
 
59
#include "ipv4.h"
 
60
#include "ipv6.h"
 
61
 
 
62
#define EUI64_ADDR_LEN                  8
 
63
#define INFINIBAND_ADDR_LEN             20
 
64
 
 
65
/* Linux 2.4 doesn't define this */
 
66
#ifndef ARPHRD_IEEE1394
 
67
#  define ARPHRD_IEEE1394               24
 
68
#endif
 
69
 
 
70
/* The BSD's don't define this yet */
 
71
#ifndef ARPHRD_INFINIBAND
 
72
#  define ARPHRD_INFINIBAND             32
 
73
#endif
 
74
 
 
75
/* Work out if we have a private address or not
 
76
 * 10/8
 
77
 * 172.16/12
 
78
 * 192.168/16
 
79
 */
 
80
#ifndef IN_PRIVATE
 
81
# define IN_PRIVATE(addr) (((addr & IN_CLASSA_NET) == 0x0a000000) ||          \
 
82
            ((addr & 0xfff00000)    == 0xac100000) ||                         \
 
83
            ((addr & IN_CLASSB_NET) == 0xc0a80000))
 
84
#endif
 
85
 
 
86
#define LINKLOCAL_ADDR  0xa9fe0000
 
87
#define LINKLOCAL_MASK  IN_CLASSB_NET
 
88
#define LINKLOCAL_BRDC  (LINKLOCAL_ADDR | ~LINKLOCAL_MASK)
 
89
 
 
90
#ifndef IN_LINKLOCAL
 
91
# define IN_LINKLOCAL(addr) ((addr & IN_CLASSB_NET) == LINKLOCAL_ADDR)
 
92
#endif
 
93
 
 
94
#define RAW_EOF                 1 << 0
 
95
#define RAW_PARTIALCSUM         2 << 0
 
96
 
 
97
int if_setflag(struct interface *ifp, short flag);
 
98
#define if_up(ifp) if_setflag((ifp), (IFF_UP | IFF_RUNNING))
 
99
struct if_head *if_discover(struct dhcpcd_ctx *, int, char * const *);
 
100
struct interface *if_find(struct if_head *, const char *);
 
101
struct interface *if_findindex(struct if_head *, unsigned int);
 
102
void if_sortinterfaces(struct dhcpcd_ctx *);
 
103
void if_free(struct interface *);
 
104
int if_domtu(const char *, short int);
 
105
#define if_getmtu(iface) if_domtu(iface, 0)
 
106
#define if_setmtu(iface, mtu) if_domtu(iface, mtu)
 
107
int if_carrier(struct interface *);
 
108
 
 
109
/* The below functions are provided by if-KERNEL.c */
 
110
int if_conf(struct interface *);
 
111
int if_init(struct interface *);
 
112
int if_getssid(struct interface *);
 
113
int if_vimaster(const char *);
 
114
int if_openlinksocket(void);
 
115
int if_managelink(struct dhcpcd_ctx *);
 
116
 
 
117
/* dhcpcd uses the same routing flags as BSD.
 
118
 * If the platform doesn't use these flags,
 
119
 * map them in the platform interace file. */
 
120
#ifndef RTM_ADD
 
121
#define RTM_ADD         0x1     /* Add Route */
 
122
#define RTM_DELETE      0x2     /* Delete Route */
 
123
#define RTM_CHANGE      0x3     /* Change Metrics or flags */
 
124
#define RTM_GET         0x4     /* Report Metrics */
 
125
#endif
 
126
 
 
127
#ifdef INET
 
128
extern const char *if_pfname;
 
129
int if_openrawsocket(struct interface *, uint16_t);
 
130
ssize_t if_sendrawpacket(const struct interface *,
 
131
    uint16_t, const void *, size_t);
 
132
ssize_t if_readrawpacket(struct interface *, uint16_t, void *, size_t, int *);
 
133
 
 
134
int if_address(const struct interface *,
 
135
    const struct in_addr *, const struct in_addr *,
 
136
    const struct in_addr *, int);
 
137
#define if_addaddress(ifp, addr, net, brd)      \
 
138
        if_address(ifp, addr, net, brd, 1)
 
139
#define if_deladdress(ifp, addr, net)           \
 
140
        if_address(ifp, addr, net, NULL, -1)
 
141
 
 
142
int if_addrflags(const struct in_addr *, const struct interface *);
 
143
 
 
144
int if_route(unsigned char, const struct rt *rt);
 
145
int if_initrt(struct interface *);
 
146
#endif
 
147
 
 
148
#ifdef INET6
 
149
int if_checkipv6(struct dhcpcd_ctx *ctx, const struct interface *, int);
 
150
#ifdef IPV6_MANAGETEMPADDR
 
151
int ip6_use_tempaddr(const char *ifname);
 
152
int ip6_temp_preferred_lifetime(const char *ifname);
 
153
int ip6_temp_valid_lifetime(const char *ifname);
 
154
#else
 
155
#define ip6_use_tempaddr(a) (0)
 
156
#endif
 
157
 
 
158
int if_address6(const struct ipv6_addr *, int);
 
159
#define if_addaddress6(a) if_address6(a, 1)
 
160
#define if_deladdress6(a) if_address6(a, -1)
 
161
 
 
162
int if_addrflags6(const struct in6_addr *, const struct interface *);
 
163
int if_getlifetime6(struct ipv6_addr *);
 
164
 
 
165
int if_route6(unsigned char, const struct rt6 *rt);
 
166
int if_initrt6(struct interface *);
 
167
#else
 
168
#define if_checkipv6(a, b, c) (-1)
 
169
#endif
 
170
 
 
171
int if_machinearch(char *, size_t);
 
172
#endif