source: mainline/uspace/lib/nic/include/nic_rx_control.h@ acac2ef

lfn serial ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since acac2ef was 00d7e1b, checked in by Martin Decky <martin@…>, 14 years ago

networking improvements

  • start the networking stack from init
  • add loopback network interface driver (cherrypicked and sanitized from lp:~helenos-nicf/helenos/nicf)
  • add libnic and various small pieces from lp:~helenos-nicf/helenos/nicf
  • fix client side of NIC_GET_ADDRESS
  • net binary overhaul

Note: "ping 127.0.0.1" works, but the first three pings timeout for some reason

  • Property mode set to 100644
File size: 5.0 KB
Line 
1/*
2 * Copyright (c) 2011 Radim Vansa
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 *
9 * - Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * - 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 * - The name of the author may not be used to endorse or promote products
15 * derived from this software without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */
28
29/**
30 * @addtogroup libnic
31 * @{
32 */
33/**
34 * @file
35 * @brief Incoming packets (frames) filtering control structures
36 */
37
38#ifndef __NIC_FILTERS_H__
39#define __NIC_FILTERS_H__
40
41#ifndef LIBNIC_INTERNAL
42#error "This is internal libnic's header, please do not include it"
43#endif
44
45#include <adt/hash_table.h>
46#include <fibril_synch.h>
47#include <net/device.h>
48#include <net/packet_header.h>
49
50#include "nic_addr_db.h"
51
52/**
53 * General structure describing receive control.
54 * The structure is not synchronized inside, the nic_driver should provide
55 * a synchronized facade.
56 */
57typedef struct nic_rxc {
58 /**
59 * Allowed unicast destination MAC addresses
60 */
61 nic_addr_db_t unicast_addrs;
62 /**
63 * Allowed unicast destination MAC addresses
64 */
65 nic_addr_db_t multicast_addrs;
66 /**
67 * Single flag if any source is blocked
68 */
69 int block_sources;
70 /**
71 * Blocked source MAC addresses
72 */
73 nic_addr_db_t blocked_sources;
74 /**
75 * Selected mode for unicast frames
76 */
77 nic_unicast_mode_t unicast_mode;
78 /**
79 * Selected mode for multicast frames
80 */
81 nic_multicast_mode_t multicast_mode;
82 /**
83 * Selected mode for broadcast frames
84 */
85 nic_broadcast_mode_t broadcast_mode;
86 /**
87 * Mask for VLAN tags. This vector must be at least 512 bytes long.
88 */
89 nic_vlan_mask_t *vlan_mask;
90 /**
91 * If true, the NIC is receiving only unicast frames which we really want to
92 * receive (the filtering is perfect).
93 */
94 int unicast_exact;
95 /**
96 * If true, the NIC is receiving only multicast frames which we really want
97 * to receive (the filtering is perfect).
98 */
99 int multicast_exact;
100 /**
101 * If true, the NIC is receiving only frames with VLAN tags which we really
102 * want to receive (the filtering is perfect).
103 */
104 int vlan_exact;
105} nic_rxc_t;
106
107#define VLAN_TPID_UPPER 0x81
108#define VLAN_TPID_LOWER 0x00
109
110typedef struct vlan_header {
111 uint8_t tpid_upper;
112 uint8_t tpid_lower;
113 uint8_t vid_upper;
114 uint8_t vid_lower;
115} __attribute__ ((packed)) vlan_header_t;
116
117extern int nic_rxc_init(nic_rxc_t *rxc);
118extern int nic_rxc_clear(nic_rxc_t *rxc);
119extern int nic_rxc_set_addr(nic_rxc_t *rxc,
120 const nic_address_t *prev_addr, const nic_address_t *curr_addr);
121extern int nic_rxc_check(const nic_rxc_t *rxc,
122 const packet_t *packet, nic_frame_type_t *frame_type);
123extern void nic_rxc_hw_filtering(nic_rxc_t *rxc,
124 int unicast_exact, int multicast_exact, int vlan_exact);
125extern uint64_t nic_rxc_mcast_hash(const nic_address_t *list, size_t count);
126extern uint64_t nic_rxc_multicast_get_hash(const nic_rxc_t *rxc);
127extern void nic_rxc_unicast_get_mode(const nic_rxc_t *, nic_unicast_mode_t *,
128 size_t max_count, nic_address_t *address_list, size_t *address_count);
129extern int nic_rxc_unicast_set_mode(nic_rxc_t *rxc, nic_unicast_mode_t mode,
130 const nic_address_t *address_list, size_t address_count);
131extern void nic_rxc_multicast_get_mode(const nic_rxc_t *,
132 nic_multicast_mode_t *, size_t, nic_address_t *, size_t *);
133extern int nic_rxc_multicast_set_mode(nic_rxc_t *, nic_multicast_mode_t mode,
134 const nic_address_t *address_list, size_t address_count);
135extern void nic_rxc_broadcast_get_mode(const nic_rxc_t *,
136 nic_broadcast_mode_t *mode);
137extern int nic_rxc_broadcast_set_mode(nic_rxc_t *,
138 nic_broadcast_mode_t mode);
139extern void nic_rxc_blocked_sources_get(const nic_rxc_t *,
140 size_t max_count, nic_address_t *address_list, size_t *address_count);
141extern int nic_rxc_blocked_sources_set(nic_rxc_t *,
142 const nic_address_t *address_list, size_t address_count);
143extern int nic_rxc_vlan_get_mask(const nic_rxc_t *rxc, nic_vlan_mask_t *mask);
144extern int nic_rxc_vlan_set_mask(nic_rxc_t *rxc, const nic_vlan_mask_t *mask);
145
146#endif
147
148/** @}
149 */
Note: See TracBrowser for help on using the repository browser.