Exemplo n.º 1
0
/*
 * Function g_netbuf_prepend_hdr (msg, hdr, len)
 *
 *    
 *
 */
uint8_t *g_netbuf_prepend_hdr(GNetBuf *msg, uint8_t *hdr, unsigned int len)
{
	uint8_t *tmp;
	
	/* Make room for header */
	tmp = g_netbuf_push(msg, len);

	/* Copy body data to object */
	memcpy(tmp, hdr, len);

	return tmp;
}
Exemplo n.º 2
0
/*
 * Function obex_data_request (self, opcode, cmd)
 *
 *    Send response or command code along with optional headers/data.
 *
 */
int obex_data_request(obex_t *self, GNetBuf *msg, int opcode)
{
	obex_common_hdr_t *hdr;
	int actual = 0;

	obex_return_val_if_fail(self != NULL, -1);
	obex_return_val_if_fail(msg != NULL, -1);

	/* Insert common header */
	hdr = (obex_common_hdr_t *) g_netbuf_push(msg, sizeof(obex_common_hdr_t));

	hdr->opcode = opcode;
	hdr->len = htons((uint16_t)msg->len);

	DUMPBUFFER(1, "Tx", msg);
	DEBUG(1, "len = %d bytes\n", msg->len);

	actual = obex_transport_write(self, msg);
	return actual;
}