|
8 | 8 | #include "rpc_client.h" |
9 | 9 | #include "rpc_server.h" |
10 | 10 |
|
11 | | -static struct NetManNetProtStack MainNetProtStack; |
12 | | -static unsigned char IsInitialized=0, IsNetStackInitialized=0; |
13 | | -static char NIFLinkState = 0; |
| 11 | +#ifdef F___netman_MainNetProtStack |
| 12 | +struct NetManNetProtStack __netman_MainNetProtStack; |
| 13 | +#else |
| 14 | +extern struct NetManNetProtStack __netman_MainNetProtStack; |
| 15 | +#endif |
| 16 | + |
| 17 | +#ifdef F___netman_IsInitialized |
| 18 | +unsigned char __netman_IsInitialized=0; |
| 19 | +#else |
| 20 | +extern unsigned char __netman_IsInitialized; |
| 21 | +#endif |
| 22 | + |
| 23 | +#ifdef F___netman_IsNetStackInitialized |
| 24 | +unsigned char __netman_IsNetStackInitialized=0; |
| 25 | +#else |
| 26 | +extern unsigned char __netman_IsNetStackInitialized; |
| 27 | +#endif |
| 28 | + |
| 29 | +#ifdef F___netman_NIFLinkState |
| 30 | +char __netman_NIFLinkState = 0; |
| 31 | +#else |
| 32 | +extern char __netman_NIFLinkState; |
| 33 | +#endif |
| 34 | + |
| 35 | +static inline void NetManUpdateStack__netman_NIFLinkState(void) |
| 36 | +{ |
| 37 | + if(__netman_IsNetStackInitialized) |
| 38 | + { |
| 39 | + if(__netman_NIFLinkState) |
| 40 | + __netman_MainNetProtStack.LinkStateUp(); |
| 41 | + else |
| 42 | + __netman_MainNetProtStack.LinkStateDown(); |
| 43 | + } |
| 44 | +} |
14 | 45 |
|
| 46 | +#ifdef F_NetManToggleGlobalNetIFLinkState |
15 | 47 | /* Upon stack registration on the IOP side, this function will be called. |
16 | 48 | But the network stack won't be updated then because the RPC wouldn't have been completely initialized, |
17 | 49 | which would prevent the stack from performing some actions like sending Gratuitous Arp packets. |
18 | 50 |
|
19 | 51 | The NIF status updated will be sent again when the RPC is fully initialized, as shown in NetManRegisterNetworkStack(). */ |
20 | 52 | void NetManToggleGlobalNetIFLinkState(unsigned char state) |
21 | 53 | { |
22 | | - NIFLinkState = state; |
| 54 | + __netman_NIFLinkState = state; |
23 | 55 |
|
24 | | - NetManUpdateStackNIFLinkState(); |
| 56 | + NetManUpdateStack__netman_NIFLinkState(); |
25 | 57 | } |
| 58 | +#endif |
26 | 59 |
|
| 60 | +#ifdef F_NetManGetGlobalNetIFLinkState |
27 | 61 | int NetManGetGlobalNetIFLinkState(void) |
28 | 62 | { |
29 | | - return NIFLinkState; |
30 | | -} |
31 | | - |
32 | | -void NetManUpdateStackNIFLinkState(void) |
33 | | -{ |
34 | | - if(IsNetStackInitialized) |
35 | | - { |
36 | | - if(NIFLinkState) |
37 | | - MainNetProtStack.LinkStateUp(); |
38 | | - else |
39 | | - MainNetProtStack.LinkStateDown(); |
40 | | - } |
| 63 | + return __netman_NIFLinkState; |
41 | 64 | } |
| 65 | +#endif |
42 | 66 |
|
| 67 | +#ifdef F_NetManInit |
43 | 68 | int NetManInit(void) |
44 | 69 | { |
45 | 70 | int result; |
46 | 71 |
|
47 | | - if(!IsInitialized) |
| 72 | + if(!__netman_IsInitialized) |
48 | 73 | { |
49 | | - if((result=NetManInitRPCServer())==0) |
| 74 | + if((result=_NetManInitRPCServer())==0) |
50 | 75 | { |
51 | | - if((result=NetManInitRPCClient())==0) IsInitialized = 1; |
| 76 | + if((result=NetManInitRPCClient())==0) __netman_IsInitialized = 1; |
52 | 77 | } |
53 | 78 | }else result = 0; |
54 | 79 |
|
55 | 80 | return result; |
56 | 81 | } |
| 82 | +#endif |
57 | 83 |
|
| 84 | +#ifdef F_NetManDeinit |
58 | 85 | void NetManDeinit(void) |
59 | 86 | { |
60 | | - if(IsInitialized) |
| 87 | + if(__netman_IsInitialized) |
61 | 88 | { |
62 | 89 | NetManUnregisterNetworkStack(); |
63 | 90 |
|
64 | 91 | NetManDeinitRPCClient(); |
65 | | - NetManDeinitRPCServer(); |
66 | | - IsInitialized = 0; |
| 92 | + _NetManDeinitRPCServer(); |
| 93 | + __netman_IsInitialized = 0; |
67 | 94 | } |
68 | 95 | } |
| 96 | +#endif |
69 | 97 |
|
| 98 | +#ifdef F_NetManRegisterNetworkStack |
70 | 99 | int NetManRegisterNetworkStack(const struct NetManNetProtStack *stack) |
71 | 100 | { |
72 | 101 | int result; |
73 | 102 |
|
74 | 103 | if((result=NetManInit())==0) |
75 | 104 | { |
76 | | - if(!IsNetStackInitialized) |
| 105 | + if(!__netman_IsNetStackInitialized) |
77 | 106 | { |
78 | 107 | if((result=NetManRPCRegisterNetworkStack())==0) |
79 | 108 | { |
80 | | - memcpy(&MainNetProtStack, stack, sizeof(MainNetProtStack)); |
81 | | - IsNetStackInitialized=1; |
82 | | - if((result=NetManRPCAllocRxBuffers()) == 0) |
83 | | - NetManUpdateStackNIFLinkState(); |
| 109 | + memcpy(&__netman_MainNetProtStack, stack, sizeof(__netman_MainNetProtStack)); |
| 110 | + __netman_IsNetStackInitialized=1; |
| 111 | + if((result=_NetManRPCAllocRxBuffers()) == 0) |
| 112 | + NetManUpdateStack__netman_NIFLinkState(); |
84 | 113 | } |
85 | 114 | } |
86 | 115 | else result=0; |
87 | 116 | } |
88 | 117 |
|
89 | 118 | return result; |
90 | 119 | } |
| 120 | +#endif |
91 | 121 |
|
| 122 | +#ifdef F_NetManUnregisterNetworkStack |
92 | 123 | void NetManUnregisterNetworkStack(void) |
93 | 124 | { |
94 | | - if(IsNetStackInitialized) |
| 125 | + if(__netman_IsNetStackInitialized) |
95 | 126 | { |
96 | 127 | NetManRPCUnregisterNetworkStack(); |
97 | | - memset(&MainNetProtStack, 0, sizeof(MainNetProtStack)); |
| 128 | + memset(&__netman_MainNetProtStack, 0, sizeof(__netman_MainNetProtStack)); |
98 | 129 |
|
99 | | - IsNetStackInitialized=0; |
| 130 | + __netman_IsNetStackInitialized=0; |
100 | 131 | } |
101 | 132 | } |
| 133 | +#endif |
102 | 134 |
|
| 135 | +#ifdef F_NetManNetIFXmit |
103 | 136 | void NetManNetIFXmit(void) |
104 | 137 | { |
105 | | - if(IsInitialized) |
| 138 | + if(__netman_IsInitialized) |
106 | 139 | NetManRpcNetIFXmit(); |
107 | 140 | } |
| 141 | +#endif |
108 | 142 |
|
| 143 | +#ifdef F_NetManIoctl |
109 | 144 | int NetManIoctl(unsigned int command, void *arg, unsigned int arg_len, void *output, unsigned int length) |
110 | 145 | { |
111 | | - return IsInitialized?NetManRpcIoctl(command, arg, arg_len, output, length):-1; |
| 146 | + return __netman_IsInitialized?NetManRpcIoctl(command, arg, arg_len, output, length):-1; |
112 | 147 | } |
| 148 | +#endif |
113 | 149 |
|
| 150 | +#ifdef F_NetManNetProtStackAllocRxPacket |
114 | 151 | void *NetManNetProtStackAllocRxPacket(unsigned int length, void **payload) |
115 | 152 | { |
116 | | - return IsNetStackInitialized?MainNetProtStack.AllocRxPacket(length, payload):NULL; |
| 153 | + return __netman_IsNetStackInitialized? __netman_MainNetProtStack.AllocRxPacket(length, payload) : NULL; |
117 | 154 | } |
| 155 | +#endif |
118 | 156 |
|
| 157 | +#ifdef F_NetManNetProtStackFreeRxPacket |
119 | 158 | void NetManNetProtStackFreeRxPacket(void *packet) |
120 | 159 | { |
121 | | - if(IsNetStackInitialized) MainNetProtStack.FreeRxPacket(packet); |
| 160 | + if(__netman_IsNetStackInitialized) __netman_MainNetProtStack.FreeRxPacket(packet); |
122 | 161 | } |
| 162 | +#endif |
123 | 163 |
|
| 164 | +#ifdef F_NetManNetProtStackEnQRxPacket |
124 | 165 | void NetManNetProtStackEnQRxPacket(void *packet) |
125 | 166 | { |
126 | | - if(IsNetStackInitialized) |
127 | | - MainNetProtStack.EnQRxPacket(packet); |
| 167 | + if(__netman_IsNetStackInitialized) |
| 168 | + __netman_MainNetProtStack.EnQRxPacket(packet); |
128 | 169 | } |
| 170 | +#endif |
129 | 171 |
|
| 172 | +#ifdef F_NetManTxPacketNext |
130 | 173 | int NetManTxPacketNext(void **payload) |
131 | 174 | { |
132 | | - return IsInitialized?MainNetProtStack.NextTxPacket(payload):-1; |
| 175 | + return __netman_IsInitialized? __netman_MainNetProtStack.NextTxPacket(payload) : -1; |
133 | 176 | } |
| 177 | +#endif |
134 | 178 |
|
| 179 | +#ifdef F_NetManTxPacketDeQ |
135 | 180 | void NetManTxPacketDeQ(void) |
136 | 181 | { |
137 | | - if(IsInitialized) |
138 | | - MainNetProtStack.DeQTxPacket(); |
| 182 | + if(__netman_IsInitialized) |
| 183 | + __netman_MainNetProtStack.DeQTxPacket(); |
139 | 184 | } |
| 185 | +#endif |
140 | 186 |
|
| 187 | +#ifdef F_NetManTxPacketAfter |
141 | 188 | int NetManTxPacketAfter(void **payload) |
142 | 189 | { |
143 | | - return IsInitialized?MainNetProtStack.AfterTxPacket(payload):-1; |
| 190 | + return __netman_IsInitialized? __netman_MainNetProtStack.AfterTxPacket(payload) : -1; |
144 | 191 | } |
| 192 | +#endif |
145 | 193 |
|
| 194 | +#ifdef F_NetManNetProtStackReallocRxPacket |
146 | 195 | void NetManNetProtStackReallocRxPacket(void *packet, unsigned int length) |
147 | 196 | { |
148 | | - if(IsNetStackInitialized) MainNetProtStack.ReallocRxPacket(packet, length); |
| 197 | + if(__netman_IsNetStackInitialized) __netman_MainNetProtStack.ReallocRxPacket(packet, length); |
149 | 198 | } |
| 199 | +#endif |
0 commit comments