#include <stdio.h>
#include <stdlib.h>
#include <inttypes.h>
#include <string.h>
#include <unistd.h>
#include <netinet/in.h>
#include "crc.h"
#include "bfb.h"
#include <common.h>
Defines | |
#define | STRUCT_OFFSET(struct_type, member) ((uint64_t) ((char*) &((struct_type*) 0)->member)) |
#define | STRUCT_MEMBER_P(struct_p, struct_offset) ((void *) ((char*) (struct_p) + (uint64_t) (struct_offset))) |
#define | STRUCT_MEMBER(member_type, struct_p, struct_offset) (*(member_type*) STRUCT_MEMBER_P ((struct_p), (struct_offset))) |
#define | htoms(A) (A) |
#define | htoml(A) (A) |
#define | mtohs(A) (A) |
#define | mtohl(A) (A) |
Functions | |
uint8_t | bfb_checksum (uint8_t *data, int len) |
Returns the whole buffer folded with xor. | |
int | bfb_stuff_data (uint8_t *buffer, uint8_t type, uint8_t *data, uint16_t len, uint8_t seq) |
Stuff data frame into serial cable encapsulation. | |
int | bfb_write_subcmd (fd_t fd, uint8_t type, uint8_t subtype) |
Send a cmd, subcmd packet, add chk (no parameters). | |
int | bfb_write_subcmd0 (fd_t fd, uint8_t type, uint8_t subtype) |
Send a cmd, subcmd packet. | |
int | bfb_write_subcmd8 (fd_t fd, uint8_t type, uint8_t subtype, uint8_t p1) |
Send a cmd, subcmd, data packet. | |
int | bfb_write_subcmd1 (fd_t fd, uint8_t type, uint8_t subtype, uint16_t p1) |
Send a cmd, subcmd packet, add chk (one word parameter). | |
int | bfb_write_subcmd2 (fd_t fd, uint8_t type, uint8_t subtype, uint16_t p1, uint16_t p2) |
Send a cmd, subcmd packet, add chk (two word parameter). | |
int | bfb_write_subcmd3 (fd_t fd, uint8_t type, uint8_t subtype, uint16_t p1, uint16_t p2, uint16_t p3) |
Send a cmd, subcmd packet, add chk (three word parameter). | |
int | bfb_write_subcmd_lw (fd_t fd, uint8_t type, uint8_t subtype, uint32_t p1, uint16_t p2) |
Send a cmd, subcmd packet, add long, word parameter. | |
int | bfb_write_packets (fd_t fd, uint8_t type, uint8_t *buffer, int length) |
Send actual packets. | |
int | bfb_send_data (fd_t fd, uint8_t type, uint8_t *data, uint16_t length, uint8_t seq) |
Stuff data into packet buffers and send all packets. | |
bfb_frame_t * | bfb_read_packets (uint8_t *buffer, int *length) |
Retrieve actual packets. | |
int | bfb_assemble_data (bfb_data_t **data, int *size, int *len, bfb_frame_t *frame) |
Append BFB frame to a data buffer. | |
int | bfb_check_data (bfb_data_t *data, int len) |
Check if data buffer is complete and valid. |
ObexFTP library - language bindings for OBEX file transfer.
Copyright (c) 2002-2007 Christian W. Zuckschwerdt <zany@triq.net>
ObexFTP is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License along with ObexFTP. If not, see <http://www.gnu.org/>.
#define htoml | ( | A | ) | (A) |
#define htoms | ( | A | ) | (A) |
#define mtohl | ( | A | ) | (A) |
#define mtohs | ( | A | ) | (A) |
#define STRUCT_MEMBER | ( | member_type, | |||
struct_p, | |||||
struct_offset | ) | (*(member_type*) STRUCT_MEMBER_P ((struct_p), (struct_offset))) |
#define STRUCT_MEMBER_P | ( | struct_p, | |||
struct_offset | ) | ((void *) ((char*) (struct_p) + (uint64_t) (struct_offset))) |
#define STRUCT_OFFSET | ( | struct_type, | |||
member | ) | ((uint64_t) ((char*) &((struct_type*) 0)->member)) |
int bfb_assemble_data | ( | bfb_data_t ** | data, | |
int * | size, | |||
int * | len, | |||
bfb_frame_t * | frame | |||
) |
Append BFB frame to a data buffer.
int bfb_check_data | ( | bfb_data_t * | data, | |
int | len | |||
) |
Check if data buffer is complete and valid.
uint8_t bfb_checksum | ( | uint8_t * | data, | |
int | len | |||
) |
Returns the whole buffer folded with xor.
bfb_frame_t* bfb_read_packets | ( | uint8_t * | buffer, | |
int * | length | |||
) |
Retrieve actual packets.
int bfb_send_data | ( | fd_t | fd, | |
uint8_t | type, | |||
uint8_t * | data, | |||
uint16_t | length, | |||
uint8_t | seq | |||
) |
Stuff data into packet buffers and send all packets.
int bfb_stuff_data | ( | uint8_t * | buffer, | |
uint8_t | type, | |||
uint8_t * | data, | |||
uint16_t | len, | |||
uint8_t | seq | |||
) |
Stuff data frame into serial cable encapsulation.
buffer needs to be of at leaset len+7 size Type 0x01: "prepare" command. Type 0x02: first transmission in a row. Type 0x03: continued transmission. seq needs to be incremented afterwards.
int bfb_write_packets | ( | fd_t | fd, | |
uint8_t | type, | |||
uint8_t * | buffer, | |||
int | length | |||
) |
Send actual packets.
Patch from Jorge Ventura to handle EAGAIN from write.
int bfb_write_subcmd | ( | fd_t | fd, | |
uint8_t | type, | |||
uint8_t | subtype | |||
) |
Send a cmd, subcmd packet, add chk (no parameters).
int bfb_write_subcmd0 | ( | fd_t | fd, | |
uint8_t | type, | |||
uint8_t | subtype | |||
) |
Send a cmd, subcmd packet.
int bfb_write_subcmd1 | ( | fd_t | fd, | |
uint8_t | type, | |||
uint8_t | subtype, | |||
uint16_t | p1 | |||
) |
Send a cmd, subcmd packet, add chk (one word parameter).
int bfb_write_subcmd2 | ( | fd_t | fd, | |
uint8_t | type, | |||
uint8_t | subtype, | |||
uint16_t | p1, | |||
uint16_t | p2 | |||
) |
Send a cmd, subcmd packet, add chk (two word parameter).
int bfb_write_subcmd3 | ( | fd_t | fd, | |
uint8_t | type, | |||
uint8_t | subtype, | |||
uint16_t | p1, | |||
uint16_t | p2, | |||
uint16_t | p3 | |||
) |
Send a cmd, subcmd packet, add chk (three word parameter).
int bfb_write_subcmd8 | ( | fd_t | fd, | |
uint8_t | type, | |||
uint8_t | subtype, | |||
uint8_t | p1 | |||
) |
Send a cmd, subcmd, data packet.
int bfb_write_subcmd_lw | ( | fd_t | fd, | |
uint8_t | type, | |||
uint8_t | subtype, | |||
uint32_t | p1, | |||
uint16_t | p2 | |||
) |
Send a cmd, subcmd packet, add long, word parameter.