|
1 /* |
|
2 * Copyright (c) 2008-2008 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of the License "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: State machine for updating arp filter |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include "core_operation_set_arp_filter.h" |
|
20 #include "core_server.h" |
|
21 #include "core_tools.h" |
|
22 #include "am_debug.h" |
|
23 |
|
24 // ======== MEMBER FUNCTIONS ======== |
|
25 |
|
26 // --------------------------------------------------------------------------- |
|
27 // --------------------------------------------------------------------------- |
|
28 // |
|
29 core_operation_set_arp_filter_c::core_operation_set_arp_filter_c( |
|
30 u32_t request_id, |
|
31 core_server_c* server, |
|
32 abs_core_driverif_c* drivers, |
|
33 abs_core_server_callback_c* adaptation, |
|
34 const core_arp_filter_s& filter ) : |
|
35 core_operation_base_c( core_operation_set_arp_filter, request_id, server, |
|
36 drivers, adaptation, core_base_flag_none ), |
|
37 arp_filter_m( filter ) |
|
38 { |
|
39 DEBUG( "core_operation_set_arp_filter_c::core_operation_set_arp_filter_c()" ); |
|
40 } |
|
41 |
|
42 // --------------------------------------------------------------------------- |
|
43 // --------------------------------------------------------------------------- |
|
44 // |
|
45 core_operation_set_arp_filter_c::~core_operation_set_arp_filter_c() |
|
46 { |
|
47 DEBUG( "core_operation_set_arp_filter_c::~core_operation_set_arp_filter_c()" ); |
|
48 } |
|
49 |
|
50 // --------------------------------------------------------------------------- |
|
51 // --------------------------------------------------------------------------- |
|
52 // |
|
53 core_error_e core_operation_set_arp_filter_c::next_state() |
|
54 { |
|
55 DEBUG( "core_operation_set_arp_filter_c::next_state()" ); |
|
56 |
|
57 switch ( operation_state_m ) |
|
58 { |
|
59 case core_state_init: |
|
60 { |
|
61 |
|
62 if ( !server_m->get_core_settings().is_driver_loaded() ) |
|
63 { |
|
64 DEBUG( "core_operation_set_arp_filter_c::next_state() - driver not loaded, enabling not possible, completing operation" ); |
|
65 |
|
66 return core_error_ok; |
|
67 } |
|
68 |
|
69 operation_state_m = core_state_set_arp_filter; |
|
70 |
|
71 if ( arp_filter_m.enable_filter ) |
|
72 { |
|
73 DEBUG( "core_operation_set_arp_filter_c::next_state() - setting ARP IP filter" ); |
|
74 DEBUG4( "core_operation_set_arp_filter_c::next_state() - IP addr: %d.%d.%d.%d", |
|
75 ( arp_filter_m.ipv4_addr & 0x000000ff ), |
|
76 ( arp_filter_m.ipv4_addr & 0x0000ff00 ) >> 8, |
|
77 ( arp_filter_m.ipv4_addr & 0x00ff0000 ) >> 16, |
|
78 ( arp_filter_m.ipv4_addr & 0xff000000 ) >> 24 ); |
|
79 } |
|
80 else |
|
81 { |
|
82 DEBUG( "core_operation_set_arp_filter_c::next_state() - disabling ARP IP filter" ); |
|
83 } |
|
84 |
|
85 drivers_m->set_arp_filter( request_id_m, arp_filter_m ); |
|
86 |
|
87 break; |
|
88 } |
|
89 case core_state_set_arp_filter: |
|
90 { |
|
91 return core_error_ok; |
|
92 } |
|
93 default: |
|
94 { |
|
95 ASSERT( false_t ); |
|
96 } |
|
97 } |
|
98 |
|
99 return core_error_request_pending; |
|
100 } |