marshaling and unmarshaling
[D-BUS internal implementation details]

functions to marshal/unmarshal data from the wire More...

Data Structures

struct  HeaderFieldType
struct  DBusTypeReaderClass
 Virtual table for a type reader. More...
struct  ReplacementBlock

Defines

#define FIELDS_ARRAY_SIGNATURE_OFFSET   6
 Offset from start of _dbus_header_signature_str to the signature of the fields array.
#define FIELDS_ARRAY_ELEMENT_SIGNATURE_OFFSET   7
 Offset from start of _dbus_header_signature_str to the signature of an element of the fields array.
#define BYTE_ORDER_OFFSET   0
 Offset to byte order from start of header.
#define TYPE_OFFSET   1
 Offset to type from start of header.
#define FLAGS_OFFSET   2
 Offset to flags from start of header.
#define VERSION_OFFSET   3
 Offset to version from start of header.
#define BODY_LENGTH_OFFSET   4
 Offset to body length from start of header.
#define SERIAL_OFFSET   8
 Offset to client serial from start of header.
#define FIELDS_ARRAY_LENGTH_OFFSET   12
 Offset to fields array length from start of header.
#define FIRST_FIELD_OFFSET   16
 Offset to first field in header.
#define EXPECTED_TYPE_OF_FIELD(field)   (_dbus_header_field_types[field].type)
 Macro to look up the correct type for a field.
#define MAX_POSSIBLE_HEADER_PADDING   7
 The most padding we could ever need for a header.
#define HEADER_END_BEFORE_PADDING(header)   (_dbus_string_get_length (&(header)->data) - (header)->padding)
 Compute the end of the header, ignoring padding.
#define RECURSIVE_MARSHAL_READ_TRACE   0
 turn this on to get deluged in TypeReader verbose spam
#define RECURSIVE_MARSHAL_WRITE_TRACE   0
 turn this on to get deluged in TypeWriter verbose spam
#define ARRAY_READER_LEN_POS(reader)   ((reader)->u.array.start_pos - ((int)(reader)->array_len_offset) - 4)
 compute position of array length given array_len_offset, which is the offset back from start_pos to end of the len
#define VALID_INITIAL_NAME_CHARACTER(c)
 Determine wether the given character is valid as the first character in a name.
#define VALID_NAME_CHARACTER(c)
 Determine wether the given character is valid as a second or later character in a name.
#define VALID_INITIAL_BUS_NAME_CHARACTER(c)
 Determine wether the given character is valid as the first character in a bus name.
#define VALID_BUS_NAME_CHARACTER(c)
 Determine wether the given character is valid as a second or later character in a bus name.

Enumerations

enum  { MARSHAL_AS_STRING, MARSHAL_AS_SIGNATURE, MARSHAL_AS_BYTE_ARRAY }

Functions

void _dbus_pack_uint32 (dbus_uint32_t value, int byte_order, unsigned char *data)
 Packs a 32 bit unsigned integer into a data pointer.
dbus_uint16_t _dbus_unpack_uint16 (int byte_order, const unsigned char *data)
 Unpacks a 16 bit unsigned integer from a data pointer.
dbus_uint32_t _dbus_unpack_uint32 (int byte_order, const unsigned char *data)
 Unpacks a 32 bit unsigned integer from a data pointer.
void _dbus_marshal_set_uint32 (DBusString *str, int pos, dbus_uint32_t value, int byte_order)
 Sets the 4 bytes at the given offset to a marshaled unsigned integer, replacing anything found there previously.
dbus_bool_t _dbus_marshal_set_basic (DBusString *str, int pos, int type, const void *value, int byte_order, int *old_end_pos, int *new_end_pos)
 Sets an existing basic type value to a new value.
dbus_uint32_t _dbus_marshal_read_uint32 (const DBusString *str, int pos, int byte_order, int *new_pos)
 Convenience function to demarshal a 32 bit unsigned integer.
void _dbus_marshal_read_basic (const DBusString *str, int pos, int type, void *value, int byte_order, int *new_pos)
 Demarshals a basic-typed value.
void _dbus_marshal_read_fixed_multi (const DBusString *str, int pos, int element_type, void *value, int n_elements, int byte_order, int *new_pos)
 Reads a block of fixed-length basic values, as an optimization vs.
dbus_bool_t _dbus_marshal_write_basic (DBusString *str, int insert_at, int type, const void *value, int byte_order, int *pos_after)
 Marshals a basic-typed value.
void _dbus_swap_array (unsigned char *data, int n_elements, int alignment)
 Swaps the elements of an array to the opposite byte order.
dbus_bool_t _dbus_marshal_write_fixed_multi (DBusString *str, int insert_at, int element_type, const void *value, int n_elements, int byte_order, int *pos_after)
 Marshals a block of values of fixed-length type all at once, as an optimization.
void _dbus_marshal_skip_basic (const DBusString *str, int type, int byte_order, int *pos)
 Skips over a basic-typed value, reporting the following position.
void _dbus_marshal_skip_array (const DBusString *str, int element_type, int byte_order, int *pos)
 Skips an array, returning the next position.
int _dbus_type_get_alignment (int typecode)
 Gets the alignment requirement for the given type; will be 1, 4, or 8.
dbus_bool_t _dbus_type_is_valid (int typecode)
 Return TRUE if the typecode is a valid typecode.
const char * _dbus_type_to_string (int typecode)
 Returns a string describing the given type.
void _dbus_verbose_bytes (const unsigned char *data, int len, int offset)
 If in verbose mode, print a block of binary data.
void _dbus_verbose_bytes_of_string (const DBusString *str, int start, int len)
 Dump the given part of the string to verbose log.
int _dbus_first_type_in_signature (const DBusString *str, int pos)
 Get the first type in the signature.
int _dbus_first_type_in_signature_c_str (const char *str, int pos)
 Similar to _dbus_first_type_in_signature, but operates on a C string buffer.
void _dbus_marshal_byteswap (const DBusString *signature, int signature_start, int old_byte_order, int new_byte_order, DBusString *value_str, int value_pos)
 Byteswaps the marshaled data in the given value_str.
 _DBUS_STRING_DEFINE_STATIC (_dbus_header_signature_str, DBUS_HEADER_SIGNATURE)
 Static DBusString containing the signature of a message header.
 _DBUS_STRING_DEFINE_STATIC (_dbus_local_interface_str, DBUS_INTERFACE_LOCAL)
 Static DBusString containing the local interface.
 _DBUS_STRING_DEFINE_STATIC (_dbus_local_path_str, DBUS_PATH_LOCAL)
 Static DBusString containing the local path.
int _dbus_header_get_message_type (DBusHeader *header)
 Gets the type of the message.
void _dbus_header_set_serial (DBusHeader *header, dbus_uint32_t serial)
 Sets the serial number of a header.
dbus_uint32_t _dbus_header_get_serial (DBusHeader *header)
 See dbus_message_get_serial().
void _dbus_header_reinit (DBusHeader *header, int byte_order)
 Re-initializes a header that was previously initialized and never freed.
dbus_bool_t _dbus_header_init (DBusHeader *header, int byte_order)
 Initializes a header, but doesn't prepare it for use; to make the header valid, you have to call _dbus_header_create().
void _dbus_header_free (DBusHeader *header)
 Frees a header.
dbus_bool_t _dbus_header_copy (const DBusHeader *header, DBusHeader *dest)
 Initializes dest with a copy of the given header.
dbus_bool_t _dbus_header_create (DBusHeader *header, 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.
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).
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.
void _dbus_header_update_lengths (DBusHeader *header, int body_len)
 Fills in the correct body length.
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_get_field_basic (DBusHeader *header, int field, int type, void *value)
 Gets the value of a field with basic type.
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.
dbus_bool_t _dbus_header_delete_field (DBusHeader *header, int field)
 Deletes a field, if it exists.
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.
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.
void _dbus_header_byteswap (DBusHeader *header, int new_order)
 Swaps the header into the given order if required.
void _dbus_type_signature_next (const char *type_str, int *type_pos)
 Skips to the next "complete" type inside a type signature.
void _dbus_type_reader_init (DBusTypeReader *reader, int byte_order, const DBusString *type_str, int type_pos, const DBusString *value_str, int value_pos)
 Initializes a type reader.
void _dbus_type_reader_init_from_mark (DBusTypeReader *reader, int byte_order, const DBusString *type_str, const DBusString *value_str, const DBusTypeMark *mark)
 Initializes a type reader that's been compressed into a DBusTypeMark.
void _dbus_type_reader_init_types_only (DBusTypeReader *reader, const DBusString *type_str, int type_pos)
 Like _dbus_type_reader_init() but the iteration is over the signature, not over values.
void _dbus_type_reader_init_types_only_from_mark (DBusTypeReader *reader, const DBusString *type_str, const DBusTypeMark *mark)
 Like _dbus_type_reader_init_from_mark() but only iterates over the signature, not the values.
void _dbus_type_reader_save_mark (const DBusTypeReader *reader, DBusTypeMark *mark)
 Compresses a type reader into a DBusTypeMark, useful for example if you want to cache a bunch of positions in a block of values.
int _dbus_type_reader_get_current_type (const DBusTypeReader *reader)
 Gets the type of the value the reader is currently pointing to; or for a types-only reader gets the type it's currently pointing to.
int _dbus_type_reader_get_element_type (const DBusTypeReader *reader)
 Gets the type of an element of the array the reader is currently pointing to.
int _dbus_type_reader_get_value_pos (const DBusTypeReader *reader)
 Gets the current position in the value block.
void _dbus_type_reader_read_raw (const DBusTypeReader *reader, const unsigned char **value_location)
 Get the address of the marshaled value in the data being read.
void _dbus_type_reader_read_basic (const DBusTypeReader *reader, void *value)
 Reads a basic-typed value, as with _dbus_marshal_read_basic().
int _dbus_type_reader_get_array_length (const DBusTypeReader *reader)
 Returns the number of values remaining in the current array reader.
void _dbus_type_reader_read_fixed_multi (const DBusTypeReader *reader, void *value, int *n_elements)
 Reads a block of fixed-length basic values, from the current point in an array to the end of the array.
void _dbus_type_reader_recurse (DBusTypeReader *reader, DBusTypeReader *sub)
 Initialize a new reader pointing to the first type and corresponding value that's a child of the current container.
dbus_bool_t _dbus_type_reader_next (DBusTypeReader *reader)
 Skip to the next value on this "level".
dbus_bool_t _dbus_type_reader_has_next (const DBusTypeReader *reader)
 Check whether there's another value on this "level".
void _dbus_type_reader_get_signature (const DBusTypeReader *reader, const DBusString **str_p, int *start_p, int *len_p)
 Gets the string and range of said string containing the signature of the current value.
dbus_bool_t _dbus_type_reader_set_basic (DBusTypeReader *reader, const void *value, const DBusTypeReader *realign_root)
 Sets a new value for the basic type value pointed to by the reader, leaving the reader valid to continue reading.
dbus_bool_t _dbus_type_reader_delete (DBusTypeReader *reader, const DBusTypeReader *realign_root)
 Recursively deletes any value pointed to by the reader, leaving the reader valid to continue reading.
dbus_bool_t _dbus_type_reader_greater_than (const DBusTypeReader *lhs, const DBusTypeReader *rhs)
 Compares two readers, which must be iterating over the same value data.
void _dbus_type_writer_init (DBusTypeWriter *writer, int byte_order, DBusString *type_str, int type_pos, DBusString *value_str, int value_pos)
 Initialize a write iterator, which is used to write out values in serialized D-BUS format.
void _dbus_type_writer_init_types_delayed (DBusTypeWriter *writer, int byte_order, DBusString *value_str, int value_pos)
 Initialize a write iterator, with the signature to be provided later.
void _dbus_type_writer_add_types (DBusTypeWriter *writer, DBusString *type_str, int type_pos)
 Adds type string to the writer, if it had none.
void _dbus_type_writer_remove_types (DBusTypeWriter *writer)
 Removes type string from the writer.
void _dbus_type_writer_init_values_only (DBusTypeWriter *writer, int byte_order, const DBusString *type_str, int type_pos, DBusString *value_str, int value_pos)
 Like _dbus_type_writer_init(), except the type string passed in should correspond to an existing signature that matches what you're going to write out.
dbus_bool_t _dbus_type_writer_recurse (DBusTypeWriter *writer, int container_type, const DBusString *contained_type, int contained_type_start, DBusTypeWriter *sub)
 Opens a new container and writes out the initial information for that container.
dbus_bool_t _dbus_type_writer_append_array (DBusTypeWriter *writer, const DBusString *contained_type, int contained_type_start, DBusTypeWriter *sub)
 Append to an existing array.
dbus_bool_t _dbus_type_writer_unrecurse (DBusTypeWriter *writer, DBusTypeWriter *sub)
 Closes a container created by _dbus_type_writer_recurse() and writes any additional information to the values block.
dbus_bool_t _dbus_type_writer_write_basic (DBusTypeWriter *writer, int type, const void *value)
 Writes out a basic type.
dbus_bool_t _dbus_type_writer_write_fixed_multi (DBusTypeWriter *writer, int element_type, const void *value, int n_elements)
 Writes a block of fixed-length basic values, i.e.
dbus_bool_t _dbus_type_writer_write_reader_partial (DBusTypeWriter *writer, DBusTypeReader *reader, const DBusTypeReader *start_after, int start_after_new_pos, int start_after_new_len, DBusList **fixups)
 Iterate through all values in the given reader, writing a copy of each value to the writer.
dbus_bool_t _dbus_type_writer_write_reader (DBusTypeWriter *writer, DBusTypeReader *reader)
 Iterate through all values in the given reader, writing a copy of each value to the writer.
void _dbus_type_writer_set_enabled (DBusTypeWriter *writer, dbus_bool_t enabled)
 If disabled, a writer can still be iterated forward and recursed/unrecursed but won't write any values.
DBusValidity _dbus_validate_signature_with_reason (const DBusString *type_str, int type_pos, int len)
 Verifies that the range of type_str from type_pos to type_end is a valid signature.
DBusValidity _dbus_validate_body_with_reason (const DBusString *expected_signature, int expected_signature_start, int byte_order, int *bytes_remaining, const DBusString *value_str, int value_pos, int len)
 Verifies that the range of value_str from value_pos to value_end is a legitimate value of type expected_signature.
dbus_bool_t _dbus_validate_path (const DBusString *str, int start, int len)
 Checks that the given range of the string is a valid object path name in the D-BUS protocol.
dbus_bool_t _dbus_validate_interface (const DBusString *str, int start, int len)
 Checks that the given range of the string is a valid interface name in the D-BUS protocol.
dbus_bool_t _dbus_validate_member (const DBusString *str, int start, int len)
 Checks that the given range of the string is a valid member name in the D-BUS protocol.
dbus_bool_t _dbus_validate_error_name (const DBusString *str, int start, int len)
 Checks that the given range of the string is a valid error name in the D-BUS protocol.
dbus_bool_t _dbus_validate_bus_name (const DBusString *str, int start, int len)
 Checks that the given range of the string is a valid bus name in the D-BUS protocol.
dbus_bool_t _dbus_validate_signature (const DBusString *str, int start, int len)
 Checks that the given range of the string is a valid message type signature in the D-BUS protocol.
 DEFINE_DBUS_NAME_CHECK (path)
 define _dbus_check_is_valid_path()
 DEFINE_DBUS_NAME_CHECK (interface)
 define _dbus_check_is_valid_interface()
 DEFINE_DBUS_NAME_CHECK (member)
 define _dbus_check_is_valid_member()
 DEFINE_DBUS_NAME_CHECK (error_name)
 define _dbus_check_is_valid_error_name()
 DEFINE_DBUS_NAME_CHECK (bus_name)
 define _dbus_check_is_valid_bus_name()
 DEFINE_DBUS_NAME_CHECK (signature)
 define _dbus_check_is_valid_signature()

Detailed Description

functions to marshal/unmarshal data from the wire

Types and functions related to converting primitive data types from wire format to native machine format, and vice versa.

A signature is just a string with multiple types one after the other. for example a type is "i" or "(ii)", a signature is "i(ii)" where i is int and (ii) is struct { int; int; }


Define Documentation

#define VALID_BUS_NAME_CHARACTER  ) 
 

Value:

( ((c) >= '0' && (c) <= '9') ||               \
    ((c) >= 'A' && (c) <= 'Z') ||               \
    ((c) >= 'a' && (c) <= 'z') ||               \
    ((c) == '_') || ((c) == '-'))
Determine wether the given character is valid as a second or later character in a bus name.

Definition at line 938 of file dbus-marshal-validate.c.

Referenced by _dbus_validate_bus_name().

#define VALID_INITIAL_BUS_NAME_CHARACTER  ) 
 

Value:

( ((c) >= 'A' && (c) <= 'Z') ||               \
    ((c) >= 'a' && (c) <= 'z') ||               \
    ((c) == '_') || ((c) == '-'))
Determine wether the given character is valid as the first character in a bus name.

Definition at line 929 of file dbus-marshal-validate.c.

Referenced by _dbus_validate_bus_name().

#define VALID_INITIAL_NAME_CHARACTER  ) 
 

Value:

( ((c) >= 'A' && (c) <= 'Z') ||               \
    ((c) >= 'a' && (c) <= 'z') ||               \
    ((c) == '_') )
Determine wether the given character is valid as the first character in a name.

Definition at line 683 of file dbus-marshal-validate.c.

Referenced by _dbus_validate_interface(), and _dbus_validate_member().

#define VALID_NAME_CHARACTER  ) 
 

Value:

( ((c) >= '0' && (c) <= '9') ||               \
    ((c) >= 'A' && (c) <= 'Z') ||               \
    ((c) >= 'a' && (c) <= 'z') ||               \
    ((c) == '_') )
Determine wether the given character is valid as a second or later character in a name.

Definition at line 692 of file dbus-marshal-validate.c.

Referenced by _dbus_validate_interface(), _dbus_validate_member(), and _dbus_validate_path().


Function Documentation

int _dbus_first_type_in_signature const DBusString str,
int  pos
 

Get the first type in the signature.

The difference between this and just getting the first byte of the signature is that you won't get DBUS_STRUCT_BEGIN_CHAR, you'll get DBUS_TYPE_STRUCT instead.

Parameters:
str string containing signature
pos where the signature starts
Returns:
the first type in the signature

Definition at line 1504 of file dbus-marshal-basic.c.

References _dbus_string_get_byte().

Referenced by _dbus_type_reader_get_current_type(), _dbus_type_reader_get_element_type(), _dbus_type_reader_read_fixed_multi(), and _dbus_type_reader_recurse().

int _dbus_first_type_in_signature_c_str const char *  str,
int  pos
 

Similar to _dbus_first_type_in_signature, but operates on a C string buffer.

Parameters:
str a C string buffer
pos where the signature starts
Returns:
the first type in the signature

Definition at line 1519 of file dbus-marshal-basic.c.

Referenced by dbus_signature_iter_get_current_type(), and dbus_signature_iter_get_element_type().

void _dbus_header_byteswap DBusHeader header,
int  new_order
 

Swaps the header into the given order if required.

Parameters:
header the header
new_order the new byte order

Definition at line 1462 of file dbus-marshal-header.c.

References _dbus_marshal_byteswap(), DBusHeader::byte_order, and DBusHeader::data.

dbus_bool_t _dbus_header_copy const DBusHeader header,
DBusHeader dest
 

Initializes dest with a copy of the given header.

Resets the message serial to 0 on the copy.

Parameters:
header header to copy
dest destination for copy
Returns:
FALSE if not enough memory

Definition at line 477 of file dbus-marshal-header.c.

References _dbus_header_set_serial(), _dbus_string_copy(), _dbus_string_free(), _dbus_string_get_length(), _dbus_string_init_preallocated(), DBusHeader::data, FALSE, and TRUE.

Referenced by dbus_message_copy().

dbus_bool_t _dbus_header_create DBusHeader header,
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.

NULL may be specified for some or all of the fields to avoid adding those fields. Some combinations of fields don't make sense, and passing them in will trigger an assertion failure.

Parameters:
header the header
message_type the message type
destination destination field or NULL
path path field or NULL
interface interface field or NULL
member member field or NULL
error_name error name or NULL
Returns:
FALSE if not enough memory

Definition at line 514 of file dbus-marshal-header.c.

References _dbus_assert, _dbus_string_delete(), _dbus_string_get_length(), _dbus_type_writer_init_values_only(), _dbus_type_writer_recurse(), _dbus_type_writer_unrecurse(), _dbus_type_writer_write_basic(), DBusTypeWriter::byte_order, DBusHeader::data, FALSE, FIELDS_ARRAY_SIGNATURE_OFFSET, HEADER_END_BEFORE_PADDING, NULL, and TRUE.

Referenced by dbus_message_new(), dbus_message_new_error(), dbus_message_new_method_call(), dbus_message_new_method_return(), and dbus_message_new_signal().

dbus_bool_t _dbus_header_delete_field DBusHeader header,
int  field
 

Deletes a field, if it exists.

Parameters:
header the header
field the field to delete
Returns:
FALSE if no memory

Definition at line 1382 of file dbus-marshal-header.c.

References _dbus_assert, _dbus_type_reader_delete(), FALSE, and TRUE.

void _dbus_header_free DBusHeader header  ) 
 

Frees a header.

Parameters:
header the header

Definition at line 463 of file dbus-marshal-header.c.

References _dbus_string_free(), and DBusHeader::data.

Referenced by dbus_message_copy().

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.

If the field doesn't exist, returns FALSE, otherwise returns TRUE.

Parameters:
header the header
field the field to get
type the type of the value
value the value as for _dbus_marshal_read_basic()
Returns:
FALSE if the field doesn't exist

Definition at line 1317 of file dbus-marshal-header.c.

References _dbus_assert, _dbus_marshal_read_basic(), EXPECTED_TYPE_OF_FIELD, FALSE, NULL, and TRUE.

Referenced by _dbus_header_have_message_untrusted(), dbus_message_get_destination(), dbus_message_get_error_name(), dbus_message_get_interface(), dbus_message_get_member(), dbus_message_get_path(), dbus_message_get_reply_serial(), and dbus_message_get_sender().

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.

If the field doesn't exist, returns FALSE, otherwise returns TRUE. Returns the start of the marshaled data, i.e. usually the byte where the length starts (for strings and arrays) or for basic types just the value itself.

Parameters:
header the header
field the field to get
str return location for the data string
pos return location for start of field value
Returns:
FALSE if the field doesn't exist

Definition at line 1358 of file dbus-marshal-header.c.

References FALSE, and TRUE.

Referenced by _dbus_header_have_message_untrusted().

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.

Parameters:
header the header
flag the message flag to get
Returns:
TRUE if the flag is set

Definition at line 1445 of file dbus-marshal-header.c.

References _dbus_string_get_const_data_len(), DBusHeader::data, and FLAGS_OFFSET.

Referenced by dbus_message_get_auto_start(), and dbus_message_get_no_reply().

int _dbus_header_get_message_type DBusHeader header  ) 
 

Gets the type of the message.

Parameters:
header the header
Returns:
the type

Definition at line 368 of file dbus-marshal-header.c.

References _dbus_assert, _dbus_string_get_byte(), DBusHeader::data, and TYPE_OFFSET.

Referenced by _dbus_header_have_message_untrusted(), and dbus_message_get_type().

dbus_uint32_t _dbus_header_get_serial DBusHeader header  ) 
 

See dbus_message_get_serial().

Parameters:
header the header
Returns:
the client serial

Definition at line 409 of file dbus-marshal-header.c.

References _dbus_marshal_read_uint32(), DBusHeader::byte_order, DBusHeader::data, NULL, and SERIAL_OFFSET.

Referenced by _dbus_header_set_serial(), and dbus_message_get_serial().

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).

Also checks that the lengths are in sanity parameters.

Parameters:
max_message_length maximum length of a valid message
validity return location for why the data is invalid if it is
byte_order return location for byte order
fields_array_len return location for claimed fields array length
header_len return location for claimed header length
body_len return location for claimed body length
str the data
start start of data, 8-aligned
len length of data
Returns:
TRUE if the data is long enough for the claimed length, and the lengths were valid

Definition at line 656 of file dbus-marshal-header.c.

References _dbus_assert, _dbus_assert_not_reached, _dbus_header_get_field_basic(), _dbus_header_get_field_raw(), _dbus_header_get_message_type(), _DBUS_INT32_MAX, _dbus_marshal_read_uint32(), _dbus_string_equal_substring(), _dbus_string_get_byte(), _dbus_string_get_length(), _dbus_type_reader_get_current_type(), _dbus_validate_bus_name(), _dbus_validate_error_name(), _dbus_validate_interface(), _dbus_validate_member(), BODY_LENGTH_OFFSET, DBusHeader::byte_order, BYTE_ORDER_OFFSET, EXPECTED_TYPE_OF_FIELD, FALSE, DBusHeader::fields, FIELDS_ARRAY_LENGTH_OFFSET, FIRST_FIELD_OFFSET, NULL, and DBusHeaderField::value_pos.

Referenced by _dbus_message_loader_queue_messages().

dbus_bool_t _dbus_header_init DBusHeader header,
int  byte_order
 

Initializes a header, but doesn't prepare it for use; to make the header valid, you have to call _dbus_header_create().

Parameters:
header header to initialize
byte_order byte order of the header
Returns:
FALSE if not enough memory

Definition at line 446 of file dbus-marshal-header.c.

References _dbus_header_reinit(), _dbus_string_init_preallocated(), DBusHeader::data, FALSE, and TRUE.

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.

The return value is TRUE if there was enough memory and the data was valid. If it returns TRUE, the header will be created. If it returns FALSE and *validity == DBUS_VALIDITY_UNKNOWN_OOM_ERROR, then there wasn't enough memory. If it returns FALSE and *validity != DBUS_VALIDITY_UNKNOWN_OOM_ERROR then the data was invalid.

The byte_order, fields_array_len, and body_len args should be from _dbus_header_have_message_untrusted(). Validation performed in _dbus_header_have_message_untrusted() is assumed to have been already done.

Parameters:
header the header (must be initialized)
mode whether to do validation
validity return location for invalidity reason
byte_order byte order from header
fields_array_len claimed length of fields array
body_len claimed length of body
header_len claimed length of header
str a string
start start of header, 8-aligned
len length of string to look at
Returns:
FALSE if no memory or data was invalid, TRUE otherwise

Definition at line 948 of file dbus-marshal-header.c.

References _dbus_assert, _dbus_string_copy_len(), _dbus_string_get_length(), _dbus_string_set_length(), _dbus_string_validate_nul(), _dbus_type_reader_get_current_type(), _dbus_type_reader_get_value_pos(), _dbus_type_reader_init(), _dbus_type_reader_next(), _dbus_type_reader_read_basic(), _dbus_type_reader_recurse(), _dbus_validate_body_with_reason(), BODY_LENGTH_OFFSET, DBusHeader::byte_order, BYTE_ORDER_OFFSET, DBusHeader::data, FALSE, DBusHeader::fields, FIELDS_ARRAY_LENGTH_OFFSET, FIRST_FIELD_OFFSET, FLAGS_OFFSET, DBusHeader::padding, SERIAL_OFFSET, TRUE, TYPE_OFFSET, DBusHeaderField::value_pos, and VERSION_OFFSET.

void _dbus_header_reinit DBusHeader header,
int  byte_order
) </