D-Bus  1.6.12
dbus-marshal-header.h
1 /* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
2 /* dbus-marshal-header.h Managing marshaling/demarshaling of message headers
3  *
4  * Copyright (C) 2005 Red Hat, Inc.
5  *
6  * Licensed under the Academic Free License version 2.1
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 2 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21  *
22  */
23 
24 #ifndef DBUS_MARSHAL_HEADER_H
25 #define DBUS_MARSHAL_HEADER_H
26 
27 #include <dbus/dbus-marshal-basic.h>
28 #include <dbus/dbus-marshal-validate.h>
29 
30 typedef struct DBusHeader DBusHeader;
31 typedef struct DBusHeaderField DBusHeaderField;
32 
33 #define _DBUS_HEADER_FIELD_VALUE_UNKNOWN -1
34 #define _DBUS_HEADER_FIELD_VALUE_NONEXISTENT -2
35 
40 {
41  int value_pos;
42 };
43 
47 struct DBusHeader
48 {
60 };
61 
63 void _dbus_header_free (DBusHeader *header);
64 void _dbus_header_reinit (DBusHeader *header);
66  int byte_order,
67  int type,
68  const char *destination,
69  const char *path,
70  const char *interface,
71  const char *member,
72  const char *error_name);
74  DBusHeader *dest);
77  dbus_uint32_t serial);
80  int body_len);
82  int field,
83  int type,
84  const void *value);
86  int field,
87  int type,
88  void *value);
90  int field,
91  const DBusString **str,
92  int *pos);
94  int field);
96  dbus_uint32_t flag,
97  dbus_bool_t value);
99  dbus_uint32_t flag);
100 dbus_bool_t _dbus_header_ensure_signature (DBusHeader *header,
101  DBusString **type_str,
102  int *type_pos);
103 dbus_bool_t _dbus_header_have_message_untrusted (int max_message_length,
104  DBusValidity *validity,
105  int *byte_order,
106  int *fields_array_len,
107  int *header_len,
108  int *body_len,
109  const DBusString *str,
110  int start,
111  int len);
113  DBusValidationMode mode,
114  DBusValidity *validity,
115  int byte_order,
116  int fields_array_len,
117  int header_len,
118  int body_len,
119  const DBusString *str,
120  int start,
121  int len);
122 void _dbus_header_byteswap (DBusHeader *header,
123  int new_order);
124 char _dbus_header_get_byte_order (const DBusHeader *header);
125 
126 
127 
128 #endif /* DBUS_MARSHAL_HEADER_H */
unsigned int dbus_uint32_t
A 32-bit unsigned integer on all platforms.
dbus_bool_t _dbus_header_load(DBusHeader *header, DBusValidationMode mode, DBusValidity *validity, int byte_order, int fields_array_len, int header_len, int body_len, const DBusString *str, int start, int len)
Creates a message header from potentially-untrusted data.
dbus_bool_t _dbus_header_copy(const DBusHeader *header, DBusHeader *dest)
Initializes dest with a copy of the given header.
dbus_uint32_t byte_order
byte order of header
dbus_uint32_t padding
bytes of alignment in header
dbus_uint32_t _dbus_header_get_serial(DBusHeader *header)
See dbus_message_get_serial()
dbus_bool_t _dbus_header_get_flag(DBusHeader *header, dbus_uint32_t flag)
Gets a message flag bit, returning TRUE if the bit is set.
dbus_bool_t _dbus_header_init(DBusHeader *header)
Initializes a header, but doesn&#39;t prepare it for use; to make the header valid, you have to call _dbu...
#define DBUS_HEADER_FIELD_LAST
Value of the highest-numbered header field code, can be used to determine the size of an array indexe...
DBusString data
Header network data, stored separately from body so we can independently realloc it.
DBusValidationMode
This is used rather than a bool for high visibility.
DBusValidity
This is primarily used in unit testing, so we can verify that each invalid message is invalid for the...
int _dbus_header_get_message_type(DBusHeader *header)
Gets the type of the message.
dbus_uint32_t dbus_bool_t
A boolean, valid values are TRUE and FALSE.
Definition: dbus-types.h:35
int value_pos
Position of field value, or -1/-2.
dbus_bool_t _dbus_header_get_field_basic(DBusHeader *header, int field, int type, void *value)
Gets the value of a field with basic type.
Cached information about a header field in the message.
void _dbus_header_byteswap(DBusHeader *header, int new_order)
Swaps the header into the given order if required.
dbus_bool_t _dbus_header_have_message_untrusted(int max_message_length, DBusValidity *validity, int *byte_order, int *fields_array_len, int *header_len, int *body_len, const DBusString *str, int start, int len)
Given data long enough to contain the length of the message body and the fields array, check whether the data is long enough to contain the entire message (assuming the claimed lengths are accurate).
void _dbus_header_reinit(DBusHeader *header)
Re-initializes a header that was previously initialized and never freed.
dbus_bool_t _dbus_header_delete_field(DBusHeader *header, int field)
Deletes a field, if it exists.
dbus_bool_t _dbus_header_set_field_basic(DBusHeader *header, int field, int type, const void *value)
Sets the value of a field with basic type.
dbus_bool_t _dbus_header_create(DBusHeader *header, int byte_order, int message_type, const char *destination, const char *path, const char *interface, const char *member, const char *error_name)
Fills in the primary fields of the header, so the header is ready for use.
void _dbus_header_free(DBusHeader *header)
Frees a header.
DBusHeaderField fields[DBUS_HEADER_FIELD_LAST+1]
Track the location of each field in header.
void _dbus_header_set_serial(DBusHeader *header, dbus_uint32_t serial)
Sets the serial number of a header.
char _dbus_header_get_byte_order(const DBusHeader *header)
Returns the header&#39;s byte order.
dbus_bool_t _dbus_header_get_field_raw(DBusHeader *header, int field, const DBusString **str, int *pos)
Gets the raw marshaled data for a field.
Message header data and some cached details of it.
void _dbus_header_toggle_flag(DBusHeader *header, dbus_uint32_t flag, dbus_bool_t value)
Toggles a message flag bit, turning on the bit if value = TRUE and flipping it off if value = FALSE...
void _dbus_header_update_lengths(DBusHeader *header, int body_len)
Fills in the correct body length.