m_ipmodem.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef __BARRY_M_IPMODEM_H__
00024 #define __BARRY_M_IPMODEM_H__
00025
00026 #include "dll.h"
00027 #include "modem.h"
00028 #include "usbwrap.h"
00029 #include "data.h"
00030 #include "pppfilter.h"
00031 #include <pthread.h>
00032
00033 #define SB_IPMODEM_SESSION_KEY_LENGTH 8
00034
00035 namespace Barry {
00036
00037
00038 class Controller;
00039
00040 namespace Mode {
00041
00042 class BXEXPORT IpModem : public Modem
00043 {
00044 public:
00045 typedef void (*DeviceDataCallback)(void *context, const unsigned char *data, int len);
00046
00047 private:
00048 Controller &m_con;
00049 Usb::Device &m_dev;
00050
00051 PppFilter m_filter;
00052
00053
00054 volatile bool m_continue_reading;
00055 pthread_t m_modem_read_thread;
00056
00057
00058 DeviceDataCallback m_callback;
00059 void *m_callback_context;
00060
00061 unsigned char m_session_key[SB_IPMODEM_SESSION_KEY_LENGTH];
00062
00063 private:
00064 BXLOCAL bool SendPassword(const char *password, uint32_t seed);
00065
00066 protected:
00067 static void *DataReadThread(void *userptr);
00068
00069 public:
00070 IpModem(Controller &con, DeviceDataCallback callback, void *callback_context);
00071 ~IpModem();
00072
00073
00074
00075 void Open(const char *password = 0);
00076 void Close();
00077
00078
00079
00080
00081
00082 void Write(const Data &data, int timeout = -1);
00083 };
00084
00085 }}
00086
00087 #endif
00088