1/** 2 * @brief 3 * net_filter.h 4 * Install filters (mostly HW) 5 */ 6 7/* 8 * Copyright (c) 2017, ETH Zurich. 9 * All rights reserved. 10 * 11 * This file is distributed under the terms in the attached LICENSE file. 12 * If you do not find this file, copies can be found by writing to: 13 * ETH Zurich D-INFK, Universitaetsstrasse 6, CH-8092 Zurich. Attn: Systems Group. 14 */ 15 16#ifndef LIB_NET_INCLUDE_NETWORKING_FILTER_H_ 17#define LIB_NET_INCLUDE_NETWORKING_FILTER_H_ 18 19#include <barrelfish/barrelfish.h> 20 21#define NET_FILTER_TCP 0 22#define NET_FILTER_UDP 1 23#define NET_FILTER_MAC 2 24 25struct net_filter_ip { 26 uint64_t qid; 27 uint32_t ip_src; 28 uint32_t ip_dst; 29 uint16_t port_src; 30 uint16_t port_dst; 31 uint8_t type; 32}; 33 34struct net_filter_mac { 35 uint8_t type; 36 uint64_t vlan_id; 37 uint64_t mac; 38}; 39 40 41struct net_filter_ele { 42 union { 43 struct net_filter_ip ip; 44 struct net_filter_mac mac; 45 } filter; 46 uint64_t filter_id; 47 struct net_filter_ele* next; 48 struct net_filter_ele* prev; 49}; 50 51struct filter_list { 52 struct net_filter_ele* start; 53 uint64_t num_ele; 54}; 55 56struct net_filter_state { 57 struct filter_list filters_ip; 58 struct filter_list filters_mac; 59 struct net_filter_binding* b; 60 volatile bool bound; 61}; 62 63errval_t net_filter_init(struct net_filter_state** st, 64 const char* cardname); 65 66errval_t net_filter_init_with_ep(struct net_filter_state** st, 67 struct capref ep); 68 69errval_t net_filter_ip_install(struct net_filter_state* st, 70 struct net_filter_ip* filt); 71 72errval_t net_filter_mac_install(struct net_filter_state* st, 73 struct net_filter_mac* filt); 74 75errval_t net_filter_ip_remove(struct net_filter_state* st, 76 struct net_filter_ip* filt); 77 78errval_t net_filter_mac_remove(struct net_filter_state* st, 79 struct net_filter_mac* filt); 80 81#endif /* LIB_NET_INCLUDE_NETWORKING_FILTER_H_ */ 82