liblnp.h

Go to the documentation of this file.
00001 //------------------------------------------------------------------------------
00002 // $HeadURL: file:///s:/svn/lego_programs/lib/liblnp/liblnp.h $
00003 // revision  $LastChangedRevision: 2 $ at $LastChangedDate: 2006-01-24 18:20:16 +0100 (Tue, 24 Jan 2006) $
00004 //------------------------------------------------------------------------------
00005 
00006 //
00007 // API for liblnp
00008 //
00009 
00010 #ifndef LIBLNP_H
00011 #define LIBLNP_H
00012 
00013 // the integrity layer packet handler type
00014 // arguments are (data,length).
00015 typedef void (*lnp_integrity_handler_t) (const unsigned char *, unsigned char);
00016 
00017 // the addressing layer packet handler type
00018 // arguments are (data,length,src_address).
00019 typedef void (*lnp_addressing_handler_t) (const unsigned char *, unsigned char, unsigned char);
00020 
00021 // result of init
00022 typedef enum lnp_init_result { INIT_OK, INIT_BAD_PARAM, INIT_ERROR } lnp_init_result;
00023 
00024 // out come of a packet transmit
00025 typedef enum lnp_tx_result { TX_SUCCESS, TX_FAILURE, TX_ERROR } lnp_tx_result;
00026 
00027 #define LNP_DISCARD_WHILE_TX 1
00028 
00029 int lnp_init_com();
00030 // initialise, connect to lnpd
00031 //
00032 //
00033 //  TCP part NOT IMPLEMENTED, parameters only for compatibility with linux
00034 // 
00035 // parameters:
00036 // tcp_hostname: NOT IMPLEMENTED -> use 0
00037 //      host running lnpd to connect - ascii or dotted quad
00038 //      0 means: default to localhost
00039 // tcp_port: NOT IMPLEMENTED -> use 0
00040 //  portnumber to connect to
00041 //  0 means: default to 7776
00042 // lnp_address:
00043 //  LNP hostaddress to use
00044 //  0 means: default to 0x80
00045 // lnp_mask:
00046 //  LNP hostmask to use
00047 //  0 means: default to 0xF0
00048 // flags: NOT IMPLEMENTED -> use 0
00049 //      bitwise or of:
00050 //  LNP_DISCARD_WHILE_TX :
00051 //              discard all packets received while waiting for tx result
00052 //     
00053 //
00054 // returns:
00055 //      INIT_OK                 ok, connected to lnp-daemon
00056 //      INIT_BAD_PARAM  bad parameters
00057 //      INIT_ERROR      network error, errno is set
00058 //      
00059 extern lnp_init_result lnp_init
00060 (
00061         char *tcp_hostname,
00062         unsigned short tcp_port,
00063         unsigned char lnp_address,
00064         unsigned char lnp_mask,
00065         int flags
00066 );
00067 
00068 // returns true if communication tower is online, 
00069 // this is to check if you have to run lnp_init
00070 extern bool lnp_test(void);
00071 
00072 // shutdown lnp, disconnect
00073 extern void lnp_shutdown(void);
00074 
00075 // set the integrity layer packet handler
00076 extern void lnp_integrity_set_handler(lnp_integrity_handler_t handler);
00077 
00078 // set an addressing layer packet handler for a lnp port.
00079 extern void lnp_addressing_set_handler(unsigned char port, lnp_addressing_handler_t handler);
00080 
00081 // send a LNP integrity layer packet of given length
00082 // returns:
00083 //      TX_SUCCESS success
00084 //      TX_FAILURE collision
00085 //      TX_ERROR   network error, errno is set
00086 //
00087 extern lnp_tx_result lnp_integrity_write(const unsigned char *data,unsigned char length);
00088 
00089 // send a LNP addressing layer packet of given length
00090 // returns:
00091 //      TX_SUCCESS success
00092 //      TX_FAILURE collision
00093 //      TX_ERROR   network error, errno is set
00094 //
00095 extern lnp_tx_result lnp_addressing_write(const unsigned char *data,unsigned char length,
00096                          unsigned char dest,unsigned char srcport);
00097 
00098 //
00099 // prevent all handlers from being invoked
00100 //
00101 extern void block_rcv(void);
00102 
00103 //
00104 // unblock handlers
00105 //
00106 extern void unblock_rcv(void);
00107 
00108 #endif
00109 
00110 
00111 
00112 
00113 
00114 

Generated on Wed Nov 29 01:27:41 2006 by  doxygen 1.4.6