Add NumberList to InfoMessage.

Also make comments fit in 80 columns when formatted as a man page.
This commit is contained in:
Todd C. Miller
2019-10-24 20:04:32 -06:00
parent 6c6f0567ba
commit 3b8011ea9e
3 changed files with 126 additions and 44 deletions

View File

@@ -148,6 +148,12 @@ void info_message__string_list__init
static const InfoMessage__StringList init_value = INFO_MESSAGE__STRING_LIST__INIT;
*message = init_value;
}
void info_message__number_list__init
(InfoMessage__NumberList *message)
{
static const InfoMessage__NumberList init_value = INFO_MESSAGE__NUMBER_LIST__INIT;
*message = init_value;
}
void info_message__init
(InfoMessage *message)
{
@@ -919,7 +925,45 @@ const ProtobufCMessageDescriptor info_message__string_list__descriptor =
(ProtobufCMessageInit) info_message__string_list__init,
NULL,NULL,NULL /* reserved[123] */
};
static const ProtobufCFieldDescriptor info_message__field_descriptors[4] =
static const ProtobufCFieldDescriptor info_message__number_list__field_descriptors[1] =
{
{
"numbers",
1,
PROTOBUF_C_LABEL_REPEATED,
PROTOBUF_C_TYPE_INT64,
offsetof(InfoMessage__NumberList, n_numbers),
offsetof(InfoMessage__NumberList, numbers),
NULL,
NULL,
0 | PROTOBUF_C_FIELD_FLAG_PACKED, /* flags */
0,NULL,NULL /* reserved1,reserved2, etc */
},
};
static const unsigned info_message__number_list__field_indices_by_name[] = {
0, /* field[0] = numbers */
};
static const ProtobufCIntRange info_message__number_list__number_ranges[1 + 1] =
{
{ 1, 0 },
{ 0, 1 }
};
const ProtobufCMessageDescriptor info_message__number_list__descriptor =
{
PROTOBUF_C__MESSAGE_DESCRIPTOR_MAGIC,
"InfoMessage.NumberList",
"NumberList",
"InfoMessage__NumberList",
"",
sizeof(InfoMessage__NumberList),
1,
info_message__number_list__field_descriptors,
info_message__number_list__field_indices_by_name,
1, info_message__number_list__number_ranges,
(ProtobufCMessageInit) info_message__number_list__init,
NULL,NULL,NULL /* reserved[123] */
};
static const ProtobufCFieldDescriptor info_message__field_descriptors[5] =
{
{
"key",
@@ -969,9 +1013,22 @@ static const ProtobufCFieldDescriptor info_message__field_descriptors[4] =
0 | PROTOBUF_C_FIELD_FLAG_ONEOF, /* flags */
0,NULL,NULL /* reserved1,reserved2, etc */
},
{
"numlistval",
5,
PROTOBUF_C_LABEL_NONE,
PROTOBUF_C_TYPE_MESSAGE,
offsetof(InfoMessage, value_case),
offsetof(InfoMessage, numlistval),
&info_message__number_list__descriptor,
NULL,
0 | PROTOBUF_C_FIELD_FLAG_ONEOF, /* flags */
0,NULL,NULL /* reserved1,reserved2, etc */
},
};
static const unsigned info_message__field_indices_by_name[] = {
0, /* field[0] = key */
4, /* field[4] = numlistval */
1, /* field[1] = numval */
3, /* field[3] = strlistval */
2, /* field[2] = strval */
@@ -979,7 +1036,7 @@ static const unsigned info_message__field_indices_by_name[] = {
static const ProtobufCIntRange info_message__number_ranges[1 + 1] =
{
{ 1, 0 },
{ 0, 4 }
{ 0, 5 }
};
const ProtobufCMessageDescriptor info_message__descriptor =
{
@@ -989,7 +1046,7 @@ const ProtobufCMessageDescriptor info_message__descriptor =
"InfoMessage",
"",
sizeof(InfoMessage),
4,
5,
info_message__field_descriptors,
info_message__field_indices_by_name,
1, info_message__number_ranges,

View File

@@ -20,6 +20,7 @@ typedef struct _TimeSpec TimeSpec;
typedef struct _IoBuffer IoBuffer;
typedef struct _InfoMessage InfoMessage;
typedef struct _InfoMessage__StringList InfoMessage__StringList;
typedef struct _InfoMessage__NumberList InfoMessage__NumberList;
typedef struct _AcceptMessage AcceptMessage;
typedef struct _RejectMessage RejectMessage;
typedef struct _ExitMessage ExitMessage;
@@ -54,8 +55,8 @@ typedef enum {
} ClientMessage__TypeCase;
/*
* Client message to the server.
* Messages on the wire are prefixed with a 16-bit size in network byte order.
* Client message to the server. Messages on the wire are
* prefixed with a 32-bit size in network byte order.
*/
struct _ClientMessage
{
@@ -108,7 +109,7 @@ struct _IoBuffer
{
ProtobufCMessage base;
/*
* elapsed time since last record (monotonic)
* elapsed time since last record
*/
TimeSpec *delay;
/*
@@ -132,11 +133,23 @@ struct _InfoMessage__StringList
, 0,NULL }
struct _InfoMessage__NumberList
{
ProtobufCMessage base;
size_t n_numbers;
int64_t *numbers;
};
#define INFO_MESSAGE__NUMBER_LIST__INIT \
{ PROTOBUF_C_MESSAGE_INIT (&info_message__number_list__descriptor) \
, 0,NULL }
typedef enum {
INFO_MESSAGE__VALUE__NOT_SET = 0,
INFO_MESSAGE__VALUE_NUMVAL = 2,
INFO_MESSAGE__VALUE_STRVAL = 3,
INFO_MESSAGE__VALUE_STRLISTVAL = 4
INFO_MESSAGE__VALUE_STRLISTVAL = 4,
INFO_MESSAGE__VALUE_NUMLISTVAL = 5
PROTOBUF_C__FORCE_ENUM_TO_BE_INT_SIZE(INFO_MESSAGE__VALUE)
} InfoMessage__ValueCase;
@@ -153,6 +166,7 @@ struct _InfoMessage
int64_t numval;
char *strval;
InfoMessage__StringList *strlistval;
InfoMessage__NumberList *numlistval;
};
};
#define INFO_MESSAGE__INIT \
@@ -167,7 +181,7 @@ struct _AcceptMessage
{
ProtobufCMessage base;
/*
* time when command was submitted
* when command was submitted
*/
TimeSpec *submit_time;
/*
@@ -176,7 +190,7 @@ struct _AcceptMessage
size_t n_info_msgs;
InfoMessage **info_msgs;
/*
* true if I/O logging is enabled
* true if I/O logging enabled
*/
protobuf_c_boolean expect_iobufs;
};
@@ -192,11 +206,11 @@ struct _RejectMessage
{
ProtobufCMessage base;
/*
* time when command was submitted
* when command was submitted
*/
TimeSpec *submit_time;
/*
* reason commamd was rejected
* reason command was rejected
*/
char *reason;
/*
@@ -217,7 +231,7 @@ struct _ExitMessage
{
ProtobufCMessage base;
/*
* total elapsed run time (monotonic)
* total elapsed run time
*/
TimeSpec *run_time;
/*
@@ -249,7 +263,7 @@ struct _AlertMessage
{
ProtobufCMessage base;
/*
* time alert message ocurred
* time alert message occurred
*/
TimeSpec *alert_time;
/*
@@ -273,7 +287,7 @@ struct _RestartMessage
*/
char *log_id;
/*
* resume point in ellaped time (monotonic)
* resume point (elapsed time)
*/
TimeSpec *resume_point;
};
@@ -289,7 +303,7 @@ struct _ChangeWindowSize
{
ProtobufCMessage base;
/*
* elapsed time since last record (monotonic)
* elapsed time since last record
*/
TimeSpec *delay;
/*
@@ -313,11 +327,11 @@ struct _CommandSuspend
{
ProtobufCMessage base;
/*
* elapsed time since last record (monotonic)
* elapsed time since last record
*/
TimeSpec *delay;
/*
* signal that caused the suspend/resume
* signal that caused suspend/resume
*/
char *signal;
};
@@ -337,8 +351,8 @@ typedef enum {
} ServerMessage__TypeCase;
/*
* Server messages to the client.
* Messages on the wire are prefixed with a 16-bit size in network byte order.
* Server messages to the client. Messages on the wire are
* prefixed with a 32-bit size in network byte order.
*/
struct _ServerMessage
{
@@ -354,15 +368,15 @@ struct _ServerMessage
*/
TimeSpec *commit_point;
/*
* ID of new I/O log (AcceptMessage ACK)
* ID of server-side I/O log
*/
char *log_id;
/*
* error message from server (restartable)
* error message from server
*/
char *error;
/*
* abort message from server (kill session)
* abort message, kill command
*/
char *abort;
};
@@ -383,11 +397,11 @@ struct _ServerHello
*/
char *server_id;
/*
* optional redirect to other server if busy
* optional redirect if busy
*/
char *redirect;
/*
* optional list of known audit servers
* optional list of known servers
*/
size_t n_servers;
char **servers;
@@ -457,6 +471,9 @@ void io_buffer__free_unpacked
/* InfoMessage__StringList methods */
void info_message__string_list__init
(InfoMessage__StringList *message);
/* InfoMessage__NumberList methods */
void info_message__number_list__init
(InfoMessage__NumberList *message);
/* InfoMessage methods */
void info_message__init
(InfoMessage *message);
@@ -661,6 +678,9 @@ typedef void (*IoBuffer_Closure)
typedef void (*InfoMessage__StringList_Closure)
(const InfoMessage__StringList *message,
void *closure_data);
typedef void (*InfoMessage__NumberList_Closure)
(const InfoMessage__NumberList *message,
void *closure_data);
typedef void (*InfoMessage_Closure)
(const InfoMessage *message,
void *closure_data);
@@ -702,6 +722,7 @@ extern const ProtobufCMessageDescriptor time_spec__descriptor;
extern const ProtobufCMessageDescriptor io_buffer__descriptor;
extern const ProtobufCMessageDescriptor info_message__descriptor;
extern const ProtobufCMessageDescriptor info_message__string_list__descriptor;
extern const ProtobufCMessageDescriptor info_message__number_list__descriptor;
extern const ProtobufCMessageDescriptor accept_message__descriptor;
extern const ProtobufCMessageDescriptor reject_message__descriptor;
extern const ProtobufCMessageDescriptor exit_message__descriptor;

View File

@@ -1,8 +1,8 @@
syntax = "proto3";
/*
* Client message to the server.
* Messages on the wire are prefixed with a 16-bit size in network byte order.
* Client message to the server. Messages on the wire are
* prefixed with a 32-bit size in network byte order.
*/
message ClientMessage {
oneof type {
@@ -29,7 +29,7 @@ message TimeSpec {
/* I/O buffer with keystroke data */
message IoBuffer {
TimeSpec delay = 1; /* elapsed time since last record (monotonic) */
TimeSpec delay = 1; /* elapsed time since last record */
bytes data = 2; /* keystroke data */
}
@@ -41,11 +41,15 @@ message InfoMessage {
message StringList {
repeated string strings = 1;
}
message NumberList {
repeated int64 numbers = 1;
}
string key = 1;
oneof value {
int64 numval = 2;
string strval = 3;
StringList strlistval = 4;
NumberList numlistval = 5;
}
}
@@ -53,24 +57,24 @@ message InfoMessage {
* Event log data for command accepted by the policy.
*/
message AcceptMessage {
TimeSpec submit_time = 1; /* time when command was submitted */
TimeSpec submit_time = 1; /* when command was submitted */
repeated InfoMessage info_msgs = 2; /* key,value event log data */
bool expect_iobufs = 3; /* true if I/O logging is enabled */
bool expect_iobufs = 3; /* true if I/O logging enabled */
}
/*
* Event log data for command rejected by the policy.
*/
message RejectMessage {
TimeSpec submit_time = 1; /* time when command was submitted */
string reason = 2; /* reason commamd was rejected */
TimeSpec submit_time = 1; /* when command was submitted */
string reason = 2; /* reason command was rejected */
repeated InfoMessage info_msgs = 3; /* key,value event log data */
}
/* Message sent by client when command exits. */
/* Might revisit runtime and use end_time instead */
message ExitMessage {
TimeSpec run_time = 1; /* total elapsed run time (monotonic) */
TimeSpec run_time = 1; /* total elapsed run time */
int32 exit_value = 2; /* 0-255 */
bool dumped_core = 3; /* true if command dumped core */
string signal = 4; /* signal name if killed by signal */
@@ -79,46 +83,46 @@ message ExitMessage {
/* Alert message, policy module-specific. */
message AlertMessage {
TimeSpec alert_time = 1; /* time alert message ocurred */
TimeSpec alert_time = 1; /* time alert message occurred */
string reason = 2; /* description of policy violation */
}
/* Used to restart an existing I/O log on the server. */
message RestartMessage {
string log_id = 1; /* ID of log being restarted */
TimeSpec resume_point = 2; /* resume point in ellaped time (monotonic) */
TimeSpec resume_point = 2; /* resume point (elapsed time) */
}
/* Window size change event. */
message ChangeWindowSize {
TimeSpec delay = 1; /* elapsed time since last record (monotonic) */
TimeSpec delay = 1; /* elapsed time since last record */
int32 rows = 2; /* new number of rows */
int32 cols = 3; /* new number of columns */
}
/* Command suspend/resume event. */
message CommandSuspend {
TimeSpec delay = 1; /* elapsed time since last record (monotonic) */
string signal = 2; /* signal that caused the suspend/resume */
TimeSpec delay = 1; /* elapsed time since last record */
string signal = 2; /* signal that caused suspend/resume */
}
/*
* Server messages to the client.
* Messages on the wire are prefixed with a 16-bit size in network byte order.
* Server messages to the client. Messages on the wire are
* prefixed with a 32-bit size in network byte order.
*/
message ServerMessage {
oneof type {
ServerHello hello = 1; /* server hello message */
TimeSpec commit_point = 2; /* cumulative time of records stored */
string log_id = 3; /* ID of new I/O log (AcceptMessage ACK) */
string error = 4; /* error message from server (restartable) */
string abort = 5; /* abort message from server (kill session) */
string log_id = 3; /* ID of server-side I/O log */
string error = 4; /* error message from server */
string abort = 5; /* abort message, kill command */
}
}
/* Hello message from server when client connects. */
message ServerHello {
string server_id = 1; /* free-form server description */
string redirect = 2; /* optional redirect to other server if busy */
repeated string servers = 3; /* optional list of known audit servers */
string redirect = 2; /* optional redirect if busy */
repeated string servers = 3; /* optional list of known servers */
}