Deleted Added
full compact
ip_fw_sockopt.c (299136) ip_fw_sockopt.c (299152)
1/*-
2 * Copyright (c) 2002-2009 Luigi Rizzo, Universita` di Pisa
3 * Copyright (c) 2014 Yandex LLC
4 * Copyright (c) 2014 Alexander V. Chernikov
5 *
6 * Supported by: Valeria Paoli
7 *
8 * Redistribution and use in source and binary forms, with or without

--- 14 unchanged lines hidden (view full) ---

23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * SUCH DAMAGE.
28 */
29
30#include <sys/cdefs.h>
1/*-
2 * Copyright (c) 2002-2009 Luigi Rizzo, Universita` di Pisa
3 * Copyright (c) 2014 Yandex LLC
4 * Copyright (c) 2014 Alexander V. Chernikov
5 *
6 * Supported by: Valeria Paoli
7 *
8 * Redistribution and use in source and binary forms, with or without

--- 14 unchanged lines hidden (view full) ---

23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * SUCH DAMAGE.
28 */
29
30#include <sys/cdefs.h>
31__FBSDID("$FreeBSD: head/sys/netpfil/ipfw/ip_fw_sockopt.c 299136 2016-05-05 20:15:46Z ae $");
31__FBSDID("$FreeBSD: head/sys/netpfil/ipfw/ip_fw_sockopt.c 299152 2016-05-06 03:18:51Z ae $");
32
33/*
34 * Control socket and rule management routines for ipfw.
35 * Control is currently implemented via IP_FW3 setsockopt() code.
36 */
37
38#include "opt_ipfw.h"
39#include "opt_inet.h"

--- 2964 unchanged lines hidden (view full) ---

3004 ctl3_rewriters = NULL;
3005 }
3006
3007 CTL3_UNLOCK();
3008
3009 return (0);
3010}
3011
32
33/*
34 * Control socket and rule management routines for ipfw.
35 * Control is currently implemented via IP_FW3 setsockopt() code.
36 */
37
38#include "opt_ipfw.h"
39#include "opt_inet.h"

--- 2964 unchanged lines hidden (view full) ---

3004 ctl3_rewriters = NULL;
3005 }
3006
3007 CTL3_UNLOCK();
3008
3009 return (0);
3010}
3011
3012static void
3012static int
3013export_objhash_ntlv_internal(struct namedobj_instance *ni,
3014 struct named_object *no, void *arg)
3015{
3016 struct sockopt_data *sd;
3017 ipfw_obj_ntlv *ntlv;
3018
3019 sd = (struct sockopt_data *)arg;
3020 ntlv = (ipfw_obj_ntlv *)ipfw_get_sopt_space(sd, sizeof(*ntlv));
3021 if (ntlv == NULL)
3013export_objhash_ntlv_internal(struct namedobj_instance *ni,
3014 struct named_object *no, void *arg)
3015{
3016 struct sockopt_data *sd;
3017 ipfw_obj_ntlv *ntlv;
3018
3019 sd = (struct sockopt_data *)arg;
3020 ntlv = (ipfw_obj_ntlv *)ipfw_get_sopt_space(sd, sizeof(*ntlv));
3021 if (ntlv == NULL)
3022 return;
3022 return (ENOMEM);
3023 ipfw_export_obj_ntlv(no, ntlv);
3023 ipfw_export_obj_ntlv(no, ntlv);
3024 return (0);
3024}
3025
3026/*
3027 * Lists all service objects.
3028 * Data layout (v0)(current):
3029 * Request: [ ipfw_obj_lheader ] size = ipfw_obj_lheader.size
3030 * Reply: [ ipfw_obj_lheader [ ipfw_obj_ntlv x N ] (optional) ]
3031 * Returns 0 on success

--- 1212 unchanged lines hidden (view full) ---

4244
4245 return (ni->count);
4246}
4247
4248/*
4249 * Runs @func for each found named object.
4250 * It is safe to delete objects from callback
4251 */
3025}
3026
3027/*
3028 * Lists all service objects.
3029 * Data layout (v0)(current):
3030 * Request: [ ipfw_obj_lheader ] size = ipfw_obj_lheader.size
3031 * Reply: [ ipfw_obj_lheader [ ipfw_obj_ntlv x N ] (optional) ]
3032 * Returns 0 on success

--- 1212 unchanged lines hidden (view full) ---

4245
4246 return (ni->count);
4247}
4248
4249/*
4250 * Runs @func for each found named object.
4251 * It is safe to delete objects from callback
4252 */
4252void
4253int
4253ipfw_objhash_foreach(struct namedobj_instance *ni, objhash_cb_t *f, void *arg)
4254{
4255 struct named_object *no, *no_tmp;
4254ipfw_objhash_foreach(struct namedobj_instance *ni, objhash_cb_t *f, void *arg)
4255{
4256 struct named_object *no, *no_tmp;
4256 int i;
4257 int i, ret;
4257
4258 for (i = 0; i < ni->nn_size; i++) {
4258
4259 for (i = 0; i < ni->nn_size; i++) {
4259 TAILQ_FOREACH_SAFE(no, &ni->names[i], nn_next, no_tmp)
4260 f(ni, no, arg);
4260 TAILQ_FOREACH_SAFE(no, &ni->names[i], nn_next, no_tmp) {
4261 ret = f(ni, no, arg);
4262 if (ret != 0)
4263 return (ret);
4264 }
4261 }
4265 }
4266 return (0);
4262}
4263
4264/*
4265 * Removes index from given set.
4266 * Returns 0 on success.
4267 */
4268int
4269ipfw_objhash_free_idx(struct namedobj_instance *ni, uint16_t idx)

--- 60 unchanged lines hidden ---
4267}
4268
4269/*
4270 * Removes index from given set.
4271 * Returns 0 on success.
4272 */
4273int
4274ipfw_objhash_free_idx(struct namedobj_instance *ni, uint16_t idx)

--- 60 unchanged lines hidden ---