summaryrefslogtreecommitdiff
path: root/cesar/maximus/sci/inc/EtherSciMsg.h
blob: ef4542f260bf750879b0c87e4add92286f2558e9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#ifndef maximus_sci_inc_etherscimsg_h
#define maximus_sci_inc_etherscimsg_h
/* Maximus project {{{
 *
 * Copyright (C) 2012 MStar Semiconductor
 *
 * <<<Licence>>>
 *
 * }}} */
/**
 * \file    maximus/sci/inc/EtherSciMsg.h
 * \ingroup maximus_sci
 *
 */
#include "maximus/sci/inc/SciMsg.h"
#include "maximus/common/types/ethernet_types.h"


class EtherSciMsg : public SciMsg
{
private:

    Ethernet_Header *p_ether_header;
    unsigned char *p_ether_data;

    uint8_t h_ether_version;
    Ethernet_Type h_ether_type;
    uint8_t h_ether_flags;
    uint8_t h_ether_reserved;

public:

    /**
     * Constructor used for RX path:
     * when a SciMsg come from SciServer.
     */
    EtherSciMsg (struct Sci_Msg_Header &header,
                 unsigned char *p_alloc);

    /**
     * Constructor used for TX path:
     * when ethernet Processor want to send a message to the SciServer.
     */
    EtherSciMsg (size_t size_of_data);

    virtual ~EtherSciMsg ( );

    void display_specialized_header ( ) const;

    void setup_and_send (SciServer &SciServer);

    inline uint8_t get_ether_version () const
    {
        return h_ether_version;
    }

    inline Ethernet_Type get_ether_type () const
    {
        return h_ether_type;
    }

    inline void set_ether_type (Ethernet_Type val)
    {
        h_ether_type = val;
    }

    inline size_t get_ether_data_size () const
    {
        return (get_sci_datalength ()
                - sizeof (Ethernet_Header));
    }

    inline unsigned char *get_ether_data_addr ()
    {
        return p_ether_data;
    }
};

#endif // maximus_sci_inc_etherscimsg_h