1 /*
2  * Copyright (C) 2003-2015 FreeIPMI Core Team
3  *
4  * This program is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation, either version 3 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
16  *
17  */
18 
19 #ifndef IPMI_SOL_PAYLOAD_H
20 #define IPMI_SOL_PAYLOAD_H
21 
22 #ifdef __cplusplus
23 extern "C" {
24 #endif
25 
26 #include <stdint.h>
27 #include <freeipmi/fiid/fiid.h>
28 
29 #define IPMI_SOL_PACKET_SEQUENCE_NUMBER_MAX    0xF
30 
31 #define IPMI_SOL_FLUSH_OUTBOUND        0x1
32 #define IPMI_SOL_DO_NOT_FLUSH_OUTBOUND 0x0
33 
34 #define IPMI_SOL_FLUSH_OUTBOUND_VALID(__val) \
35   (((__val) == IPMI_SOL_FLUSH_OUTBOUND       \
36     || (__val) == IPMI_SOL_DO_NOT_FLUSH_OUTBOUND) ? 1 : 0)
37 
38 #define IPMI_SOL_FLUSH_INBOUND        0x1
39 #define IPMI_SOL_DO_NOT_FLUSH_INBOUND 0x0
40 
41 #define IPMI_SOL_FLUSH_INBOUND_VALID(__val) \
42   (((__val) == IPMI_SOL_FLUSH_INBOUND       \
43     || (__val) == IPMI_SOL_DO_NOT_FLUSH_INBOUND) ? 1 : 0)
44 
45 #define IPMI_SOL_ASSERT_DCD_DSR       0x0
46 #define IPMI_SOL_DEASSERT_DCD_DSR     0x1
47 
48 #define IPMI_SOL_ASSERT_DCD_DSR_VALID(__val) \
49   (((__val) == IPMI_SOL_ASSERT_DCD_DSR       \
50     || (__val) == IPMI_SOL_DEASSERT_DCD_DSR) ? 1 : 0)
51 
52 #define IPMI_SOL_ASSERT_CTS       0x0
53 #define IPMI_SOL_DEASSERT_CTS     0x1
54 
55 #define IPMI_SOL_ASSERT_CTS_VALID(__val) \
56   (((__val) == IPMI_SOL_ASSERT_CTS       \
57     || (__val) == IPMI_SOL_DEASSERT_CTS) ? 1 : 0)
58 
59 #define IPMI_SOL_GENERATE_BREAK        0x1
60 #define IPMI_SOL_DO_NOT_GENERATE_BREAK 0x0
61 
62 #define IPMI_SOL_GENERATE_BREAK_VALID(__val) \
63   (((__val) == IPMI_SOL_GENERATE_BREAK       \
64     || (__val) == IPMI_SOL_DO_NOT_GENERATE_BREAK) ? 1 : 0)
65 
66 #define IPMI_SOL_ASSERT_RI       0x0
67 #define IPMI_SOL_DEASSERT_RI     0x1
68 
69 #define IPMI_SOL_ASSERT_RI_VALID(__val) \
70   (((__val) == IPMI_SOL_ASSERT_RI       \
71     || (__val) == IPMI_SOL_DEASSERT_RI) ? 1 : 0)
72 
73 #define IPMI_SOL_ACK                0x0
74 #define IPMI_SOL_NACK               0x1
75 
76 #define IPMI_SOL_ACK_VALID(__val) \
77   (((__val) == IPMI_SOL_ACK       \
78     || (__val) == IPMI_SOL_NACK) ? 1 : 0)
79 
80 #define IPMI_SOL_NACK_VALID(__val) \
81   (((__val) == IPMI_SOL_ACK        \
82     || (__val) == IPMI_SOL_NACK) ? 1 : 0)
83 
84 #define IPMI_SOL_BREAK_CONDITION_DETECTED 0x1
85 #define IPMI_SOL_NO_BREAK_DETECTED        0x0
86 
87 #define IPMI_SOL_TRANSMIT_OVERRUN_CHARACTERS_DROPPED     0x1
88 #define IPMI_SOL_TRANSMIT_OVERRUN_NO_CHARACTERS_DROPPED  0x0
89 
90 #define IPMI_SOL_SOL_DEACTIVATING 0x1
91 #define IPMI_SOL_SOL_ACTIVE       0x0
92 
93 #define IPMI_SOL_CHARACTER_TRANSFER_UNAVAILABLE 0x1
94 #define IPMI_SOL_CHARACTER_TRANSFER_AVAILABLE   0x0
95 
96 /*
97  * fill* functions return 0 on success, -1 on error.
98  *
99  * obj_sol_payload must be for the fill function's respective fiid
100  * template request.
101  *
102  * see freeipmi/templates/ for template definitions
103  */
104 
105 extern fiid_template_t tmpl_sol_payload_data;
106 extern fiid_template_t tmpl_sol_payload_data_remote_console_to_bmc;
107 extern fiid_template_t tmpl_sol_payload_data_bmc_to_remote_console;
108 
109 int fill_sol_payload_data (uint8_t packet_sequence_number,
110                            uint8_t packet_ack_nack_sequence_number,
111                            uint8_t accepted_character_count,
112                            uint8_t operation_status,
113                            const void *character_data,
114                            unsigned int character_data_len,
115                            fiid_obj_t obj_sol_payload);
116 
117 int fill_sol_payload_data_remote_console_to_bmc (uint8_t packet_sequence_number,
118                                                  uint8_t packet_ack_nack_sequence_number,
119                                                  uint8_t accepted_character_count,
120                                                  uint8_t flush_outbound,
121                                                  uint8_t flush_inbound,
122                                                  uint8_t drop_dcd_dsr,
123                                                  uint8_t cts_pause,
124                                                  uint8_t generate_break,
125                                                  uint8_t ring_wor,
126                                                  uint8_t nack,
127                                                  const void *character_data,
128                                                  unsigned int character_data_len,
129                                                  fiid_obj_t obj_sol_payload);
130 
131 #ifdef __cplusplus
132 }
133 #endif
134 
135 #endif /* IPMI_SOL_PAYLOAD_H */
136