btnut/btnode/include/mhop/vcp.h File Reference


Detailed Description

Virtual Connection Protocol Layer.

#include <sys/types.h>
#include <bt/bt_defs.h>
#include <mhop/tp.h>
#include <mhop/ppp.h>

Transport initialization functions

#define VCP_DATA_CB   void (*data_cb) (u_char vc_handle, u_char* data, u_short len, u_char port_nr);
 Registration function for connection less data callback. The registered funciton is called on arrival of cl data.
#define VCP_VC_CHANGE_CB   void (*vc_change_cb) (u_char vc_handle, u_char type, u_char reason);
 Registration function for vc connection changes. The registered function is called if a new vc opens or an existing vc was closed.
void tp_init (struct btstack *bt_stack, void(*rel_con_change_registration)(void(*cb)(u_char type, u_char detail, bt_con_handle_t con_handle)))
 Initializes the transport layer.
void tp_register_vc_data_cb (void(*cb)(u_char vc_handle, u_char *data, u_short len))
 Registration function for vc data callback. The registered function is called on arrival of vc data.
short vcp_register_service (u_char port, VCP_DATA_CB, VCP_VC_CHANGE_CB, u_char pkt_processors)

Defines

#define VCP_NR_PORTS   10
#define VCP_PPP_PORT   3
VC connection callback types and reasons
#define VCP_CLOSE_LINK   2
 VC close reason: normal close (by other side).
#define VCP_CLOSE_NORMAL   1
 VC close reason: link failure.
#define VCP_CON_CLOSE   2
 VC type: close.
#define VCP_CON_OPEN   1
 VC type: open.
TP error codes
Returned by tp_send_*_data() functions on failure.

#define VCP_ERR_DEST   3
 Destination invalid.
#define VCP_ERR_PKT_LEN   2
 Packet size too large.
#define VCP_ERR_SEND   1
 Send error.
VC Packets
#define VCP_HEADER_LEN   (2+2)
 virtual connection data packet header length
#define VCP_MAX_PAYLOAD   PPP_MAX_PAYLOAD - VCP_HEADER_LEN

Functions

VCP API functions
void vcp_close_vc (u_char vc_handle)
 Closes the virtual connection with handle vc_handle.
u_charvcp_get_data_pointer (vcp_pkt_t *pkt)
 Returns a pointer to the begin of payload data in a VC data packet.
void vcp_open_vc (bt_addr_t target, u_char ttl)
 Opens a virtual connection to the target with address target.
u_char vcp_send_data (vcp_pkt_t *pkt, u_char vc_handle, u_short len)
 Sends a VC data packet over the virtual connection with handle vc_handle.


Define Documentation

#define VCP_DATA_CB   void (*data_cb) (u_char vc_handle, u_char* data, u_short len, u_char port_nr);

Registration function for connection less data callback. The registered funciton is called on arrival of cl data.

Parameters:
cb Callback function to register. Fallowing arguments are passed to this function:
  • bt_addr_t source Address of the source node
  • u_char* data Pointer to the begin of data
  • u_short len Length of data in bytes


Function Documentation

void tp_init ( struct btstack bt_stack,
void(*)(void(*cb)(u_char type, u_char detail, bt_con_handle_t con_handle))  rel_con_change_registration 
)

Initializes the transport layer.

Parameters:
bt_stack Pointer to the btstack.
acl_com_stack Pointer to the acl com stack.
rel_con_change_registration Registration function for reliable connection changes.

void vcp_close_vc ( u_char  vc_handle  ) 

Closes the virtual connection with handle vc_handle.

Parameters:
vc_handle VC handle of the virtual connection to close

u_char* vcp_get_data_pointer ( vcp_pkt_t *  pkt  ) 

Returns a pointer to the begin of payload data in a VC data packet.

Parameters:
pkt Pointer to the bt_l2cap_pkt_t packet
Returns:
Pointer to the begin of the VC payload data in pkt

void vcp_open_vc ( bt_addr_t  target,
u_char  ttl 
)

Opens a virtual connection to the target with address target.

Parameters:
target Address of the target
ttl Time to live

u_char vcp_send_data ( vcp_pkt_t *  pkt,
u_char  vc_handle,
u_short  len 
)

Sends a VC data packet over the virtual connection with handle vc_handle.

To send a VC data packet, first use tp_get_vc_data_pointer(), fill in the data and then use this function.

Parameters:
pkt Pointer to the bt_l2cap_pkt_t packet to send
vc_handle VC handle of the virtual connection to use
len Length of the data to send in bytes
Returns:
0 on success, on error: TP_ERR_DEST, TP_ERR_PKT_LEN, TP_ERR_SEND


Generated on Wed Apr 29 11:12:29 2009 for BTnut System Software by doxygen 1.5.1
!!! Dieses Dokument stammt aus dem ETH Web-Archiv und wird nicht mehr gepflegt !!!
!!! This document is stored in the ETH Web archive and is no longer maintained !!!