KM3NeT CLB  2.0
KM3NeT CLB v2 Embedded Software
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
network.h
Go to the documentation of this file.
1 /*
2  * KM3NeT CLB v2 Firmware
3  * ----------------------
4  *
5  * Copyright 2013 KM3NeT Collaboration
6  *
7  * All Rights Reserved.
8  *
9  *
10  * File : network.h
11  * Created : 22 nov. 2013
12  * Author : Vincent van Beveren
13  */
14 
15 #ifndef NETWORK_H_
16 #define NETWORK_H_
17 
18 /**
19  * @file
20  *
21  * @ingroup network
22  */
23 
24 #include <stdbool.h>
25 #include <stdint.h>
26 #include "kernel/err.h"
27 #include "errorcode.h"
28 
29 // When set, logs the first 32 packets.
30 #define LOG_RX_PACKETS 32
31 
32 /**
33  * Packet log.
34  */
35 typedef struct PacketLog_s
36 {
37  uint32_t ticks; // Ticks time (ms)
38  uint16_t length; // packet length
39  uint16_t eth_type; // Ethernet type
40  uint16_t proc_time; // Time processing this packet (ms)
41  uint8_t d_mac5; // Octet 5 of destination MAC
42  uint8_t d_mac6; // Octet 6 of destination MAC
43 } PacketLog_t;
44 
45 /**
46  * Get packet log at position pos. Maximum is LOG_RX_PACKTS.
47  *
48  * @return A PacketLog_t pointer for the given position, or NULL
49  * if the packet log is not enabled or there is no packet logged
50  * at that location.
51  */
52 PacketLog_t * getPacketLog(uint32_t pos);
53 
54 /**
55  * Reset the packet log. Will cause the packet buffer to be filled again
56  * up to LOG_RX_PACKETS packets.
57  */
58 void resetPacketLog();
59 
60 
61 #define E_NET_WRXMAC ( E_NET + 0x01 )
62 #define E_NET_WRXMAC_DESCR "Could not retrieve MAC"
63 
64 /**
65  * Initializes the network.
66  */
67 bool netInit();
68 
69 
70 
71 
72 /**
73  * Sets the IPMux destination.
74  *
75  * @param destIP Destination IP
76  * @param destMAC Destinaion Mac
77  */
78 bool netMuxDest(uint32_t destIp, uint16_t * destMac);
79 
80 /**
81  * Shows network configuration information.
82  *
83  * @param extended show extended information.
84  */
85 void netShowInfo(bool extended);
86 
87 /**
88  * Sets the Ip address to the network.
89  *
90  * @param ip The new IP addresss.
91  */
92 void netSetIp(uint8_t * ip);
93 
94 /**
95  * Returns the number of events failed to be transmitted since the
96  * the function was previously invoked.
97  *
98  * Calling this function will also reset the function counter.
99  *
100  * @return The number of transmission failures.
101  */
102 uint32_t netEventFailedCount();
103 
104 /**
105  * Returns whether or not the Ip is valid.
106  *
107  * @retval true Its valid
108  * @retval false Its not valid.
109  */
110 bool netIpValid();
111 
112 #endif /* NETWORK_H_ */
bool netIpValid()
Returns whether or not the Ip is valid.
Definition: network.c:677
PacketLog_t * getPacketLog(uint32_t pos)
Get packet log at position pos.
Definition: network.c:71
bool netMuxDest(uint32_t destIp, uint16_t *destMac)
Sets the IPMux destination.
Definition: network.c:361
bool netInit()
Initializes the network.
Definition: network.c:687
Manages the global system error.
struct PacketLog_s PacketLog_t
Packet log.
void resetPacketLog()
Reset the packet log.
Definition: network.c:77
This module is responsible for distributing error codes.
Packet log.
Definition: network.h:35
uint32_t netEventFailedCount()
Returns the number of events failed to be transmitted since the the function was previously invoked...
Definition: network.c:667
void netSetIp(uint8_t *ip)
Sets the Ip address to the network.
Definition: network.c:475
void netShowInfo(bool extended)
Shows network configuration information.
Definition: network.c:541