viriptables.h 8.3 KB
Newer Older
1
/*
2 3
 * viriptables.h: helper APIs for managing iptables
 *
J
Jim Meyering 已提交
4
 * Copyright (C) 2007, 2008 Red Hat, Inc.
5 6 7 8 9 10 11 12 13 14 15 16
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library 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
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
17
 * License along with this library.  If not, see
O
Osier Yang 已提交
18
 * <http://www.gnu.org/licenses/>.
19 20
 */

21
#pragma once
22

23 24
#include "virsocketaddr.h"
#include "virfirewall.h"
25

26
int              iptablesSetupPrivateChains      (virFirewallLayer layer);
27

28 29
void             iptablesSetDeletePrivate        (bool pvt);

30 31
void             iptablesAddTcpInput             (virFirewallPtr fw,
                                                  virFirewallLayer layer,
32 33
                                                  const char *iface,
                                                  int port);
34 35
void             iptablesRemoveTcpInput          (virFirewallPtr fw,
                                                  virFirewallLayer layer,
36 37 38
                                                  const char *iface,
                                                  int port);

39 40
void             iptablesAddUdpInput             (virFirewallPtr fw,
                                                  virFirewallLayer layer,
41 42
                                                  const char *iface,
                                                  int port);
43 44
void             iptablesRemoveUdpInput          (virFirewallPtr fw,
                                                  virFirewallLayer layer,
45 46 47
                                                  const char *iface,
                                                  int port);

48 49
void             iptablesAddUdpOutput            (virFirewallPtr fw,
                                                  virFirewallLayer layer,
50 51
                                                  const char *iface,
                                                  int port);
52 53
void             iptablesRemoveUdpOutput         (virFirewallPtr fw,
                                                  virFirewallLayer layer,
54 55 56
                                                  const char *iface,
                                                  int port);

57 58
int              iptablesAddForwardAllowOut      (virFirewallPtr fw,
                                                  virSocketAddr *netaddr,
59
                                                  unsigned int prefix,
60
                                                  const char *iface,
61
                                                  const char *physdev)
62
    G_GNUC_WARN_UNUSED_RESULT;
63 64
int              iptablesRemoveForwardAllowOut   (virFirewallPtr fw,
                                                  virSocketAddr *netaddr,
65
                                                  unsigned int prefix,
66
                                                  const char *iface,
67
                                                  const char *physdev)
68
    G_GNUC_WARN_UNUSED_RESULT;
69 70
int              iptablesAddForwardAllowRelatedIn(virFirewallPtr fw,
                                                  virSocketAddr *netaddr,
71
                                                  unsigned int prefix,
72
                                                  const char *iface,
73
                                                  const char *physdev)
74
    G_GNUC_WARN_UNUSED_RESULT;
75 76 77 78 79
int              iptablesRemoveForwardAllowRelatedIn(virFirewallPtr fw,
                                                     virSocketAddr *netaddr,
                                                     unsigned int prefix,
                                                     const char *iface,
                                                     const char *physdev)
80
    G_GNUC_WARN_UNUSED_RESULT;
81

82 83
int              iptablesAddForwardAllowIn       (virFirewallPtr fw,
                                                  virSocketAddr *netaddr,
84
                                                  unsigned int prefix,
85
                                                  const char *iface,
86
                                                  const char *physdev)
87
    G_GNUC_WARN_UNUSED_RESULT;
88 89
int              iptablesRemoveForwardAllowIn    (virFirewallPtr fw,
                                                  virSocketAddr *netaddr,
90
                                                  unsigned int prefix,
91
                                                  const char *iface,
92
                                                  const char *physdev)
93
    G_GNUC_WARN_UNUSED_RESULT;
94

95 96
void             iptablesAddForwardAllowCross    (virFirewallPtr fw,
                                                  virFirewallLayer layer,
97
                                                  const char *iface);
98 99
void             iptablesRemoveForwardAllowCross (virFirewallPtr fw,
                                                  virFirewallLayer layer,
100 101
                                                  const char *iface);

102 103
void             iptablesAddForwardRejectOut     (virFirewallPtr fw,
                                                  virFirewallLayer layer,
104
                                                  const char *iface);
105 106
void             iptablesRemoveForwardRejectOut  (virFirewallPtr fw,
                                                  virFirewallLayer layer,
107 108
                                                  const char *iface);

109 110
void             iptablesAddForwardRejectIn      (virFirewallPtr fw,
                                                  virFirewallLayer layer,
111
                                                  const char *iface);
112 113
void             iptablesRemoveForwardRejectIn   (virFirewallPtr fw,
                                                  virFirewallLayer layery,
114
                                                  const char *iface);
115

116 117
int              iptablesAddForwardMasquerade    (virFirewallPtr fw,
                                                  virSocketAddr *netaddr,
118
                                                  unsigned int prefix,
119
                                                  const char *physdev,
120 121
                                                  virSocketAddrRangePtr addr,
                                                  virPortRangePtr port,
122
                                                  const char *protocol)
123
    G_GNUC_WARN_UNUSED_RESULT;
124 125
int              iptablesRemoveForwardMasquerade (virFirewallPtr fw,
                                                  virSocketAddr *netaddr,
126
                                                  unsigned int prefix,
127
                                                  const char *physdev,
128 129
                                                  virSocketAddrRangePtr addr,
                                                  virPortRangePtr port,
130
                                                  const char *protocol)
131
    G_GNUC_WARN_UNUSED_RESULT;
132 133
int              iptablesAddDontMasquerade       (virFirewallPtr fw,
                                                  virSocketAddr *netaddr,
134 135
                                                  unsigned int prefix,
                                                  const char *physdev,
136
                                                  const char *destaddr)
137
    G_GNUC_WARN_UNUSED_RESULT;
138 139
int              iptablesRemoveDontMasquerade    (virFirewallPtr fw,
                                                  virSocketAddr *netaddr,
140 141
                                                  unsigned int prefix,
                                                  const char *physdev,
142
                                                  const char *destaddr)
143
    G_GNUC_WARN_UNUSED_RESULT;
144 145
void             iptablesAddOutputFixUdpChecksum (virFirewallPtr fw,
                                                  const char *iface,
146
                                                  int port);
147 148
void             iptablesRemoveOutputFixUdpChecksum (virFirewallPtr fw,
                                                     const char *iface,
149
                                                     int port);