fu-chunk: fwupd Reference Manual

## fu-chunk fu-chunk |

## Functions

FuChunk * | fu_chunk_bytes_new ()
void | fu_chunk_set_idx ()
guint32 | fu_chunk_get_idx ()
void | fu_chunk_set_page ()
guint32 | fu_chunk_get_page ()
void | fu_chunk_set_address ()
guint32 | fu_chunk_get_address ()
const guint8 * | fu_chunk_get_data ()
guint8 * | fu_chunk_get_data_out ()
guint32 | fu_chunk_get_data_sz ()
void | fu_chunk_set_bytes ()
GBytes * | fu_chunk_get_bytes ()
FuChunk * | fu_chunk_new ()
gchar * | fu_chunk_to_string ()
gchar * | fu_chunk_array_to_string ()
GPtrArray * | fu_chunk_array_new ()
GPtrArray * | fu_chunk_array_mutable_new ()
GPtrArray * | fu_chunk_array_new_from_bytes ()

## Types and Values

#define | FU_TYPE_CHUNK
| FuChunk

## Description

## Functions

### fu_chunk_bytes_new ()

    FuChunk *
    fu_chunk_bytes_new (GBytes *bytes);

Creates a new packet of data.

#### Parameters

bytes | data. | [nullable]

#### Returns

a FuChunk.

[transfer full]

Since: 1.5.6

### fu_chunk_set_idx ()

    void
    fu_chunk_set_idx (FuChunk *self,
                      guint32 idx);

Sets the index of the chunk.

#### Parameters

self | a FuChunk |
idx | index, starting at 0 |

Since: 1.5.6

### fu_chunk_get_idx ()

    guint32
    fu_chunk_get_idx (FuChunk *self);

Gets the index of the chunk.

#### Parameters

self | a FuChunk |

#### Returns

index

Since: 1.5.6

### fu_chunk_set_page ()

    void
    fu_chunk_set_page (FuChunk *self,
                       guint32 page);

Sets the page of the chunk.

#### Parameters

self | a FuChunk |
page | page number, starting at 0 |

Since: 1.5.6

### fu_chunk_get_page ()

    guint32
    fu_chunk_get_page (FuChunk *self);

Gets the page of the chunk.

#### Parameters

self | a FuChunk |

#### Returns

page

Since: 1.5.6

### fu_chunk_set_address ()

    void
    fu_chunk_set_address (FuChunk *self,
                          guint32 address);

Sets the address of the chunk.

#### Parameters

self | a FuChunk |
address | memory address |

Since: 1.5.6

### fu_chunk_get_address ()

    guint32
    fu_chunk_get_address (FuChunk *self);

Gets the address of the chunk.

#### Parameters

self | a FuChunk |

#### Returns

address

Since: 1.5.6

### fu_chunk_get_data ()

    const guint8 *
    fu_chunk_get_data (FuChunk *self);

Gets the data of the chunk.

#### Parameters

self | a FuChunk |

#### Returns

bytes

Since: 1.5.6

### fu_chunk_get_data_out ()

    guint8 *
    fu_chunk_get_data_out (FuChunk *self);

Gets the mutable data of the chunk.

WARNING: At the moment `fu_chunk_get_data_out()` returns the same data as `fu_chunk_get_data()` in all cases. The caller should verify the data passed to `fu_chunk_array_new()` is also writable (i.e. not `const` or `mmap`) before using this function.

#### Parameters

self | a FuChunk |

#### Returns

bytes.

[transfer none]

Since: 1.5.6

### fu_chunk_get_data_sz ()

    guint32
    fu_chunk_get_data_sz (FuChunk *self);

Gets the data size of the chunk.

#### Parameters

self | a FuChunk |

#### Returns

size in bytes

Since: 1.5.6

### fu_chunk_set_bytes ()

    void
    fu_chunk_set_bytes (FuChunk *self,
                        GBytes *bytes);

Sets the data to use for the chunk.

#### Parameters

self | a FuChunk |
bytes | data. | [nullable]

Since: 1.5.6

### fu_chunk_get_bytes ()

    GBytes *
    fu_chunk_get_bytes (FuChunk *self);

Gets the data of the chunk.

#### Parameters

self | a FuChunk |

#### Returns

data.

[transfer full]

Since: 1.5.6

### fu_chunk_new ()

    FuChunk *
    fu_chunk_new (guint32 idx,
                  guint32 page,
                  guint32 address,
                  const guint8 *data,
                  guint32 data_sz);

Creates a new packet of chunked data.

#### Parameters

idx | the packet number |
page | the hardware memory page |
address | the address *within* the page |
data | the data |
data_sz | size of `data_sz` |

#### Returns

a FuChunk.

[transfer full]

Since: 1.1.2

### fu_chunk_to_string ()

    gchar *
    fu_chunk_to_string (FuChunk *self);

Converts the chunked packet to a string representation.

#### Parameters

self | a FuChunk |

#### Returns

a string.

[transfer full]

Since: 1.1.2

### fu_chunk_array_to_string ()

    gchar *
    fu_chunk_array_to_string (GPtrArray *chunks);

Converts all the chunked packets in an array to a string representation.

#### Parameters

chunks | array of chunks. | [element-type FuChunk]

#### Returns

a string.

[transfer full]

Since: 1.0.1

### fu_chunk_array_new ()

    GPtrArray *
    fu_chunk_array_new (const guint8 *data,
                        guint32 data_sz,
                        guint32 addr_start,
                        guint32 page_sz,
                        guint32 packet_sz);

Chunks a linear blob of memory into packets, ensuring each packet does not cross a package boundary and is less that a specific transfer size.

#### Parameters

data | an optional linear blob of memory. | [nullable]
data_sz | size of `data_sz` |
addr_start | the hardware address offset, or 0 |
page_sz | the hardware page size, or 0 |
packet_sz | the transfer size, or 0 |

#### Returns

array of packets.

[transfer container][element-type FuChunk]

Since: 1.1.2

### fu_chunk_array_mutable_new ()

    GPtrArray *
    fu_chunk_array_mutable_new (guint8 *data,
                                guint32 data_sz,
                                guint32 addr_start,
                                guint32 page_sz,
                                guint32 packet_sz);

Chunks a mutable blob of memory into packets, ensuring each packet does not cross a package boundary and is less that a specific transfer size.

#### Parameters

data | a mutable blob of memory |
data_sz | size of `data_sz` |
addr_start | the hardware address offset, or 0 |
page_sz | the hardware page size, or 0 |
packet_sz | the transfer size, or 0 |

#### Returns

array of packets.

[transfer container][element-type FuChunk]

Since: 1.5.6

### fu_chunk_array_new_from_bytes ()

    GPtrArray *
    fu_chunk_array_new_from_bytes (GBytes *blob,
                                   guint32 addr_start,
                                   guint32 page_sz,
                                   guint32 packet_sz);

Chunks a linear blob of memory into packets, ensuring each packet does not cross a package boundary and is less that a specific transfer size.

#### Parameters

blob | data |
addr_start | the hardware address offset, or 0 |
page_sz | the hardware page size, or 0 |
packet_sz | the transfer size, or 0 |

#### Returns

array of packets.

[transfer container][element-type FuChunk]

Since: 1.1.2

## Types and Values

### FU_TYPE_CHUNK

    #define FU_TYPE_CHUNK (fu_chunk_get_type ())

### FuChunk

    typedef struct _FuChunk FuChunk;

A optionally mutable packet of chunked data with address, page and index.