Nicholas Herriot / VodafoneK3770Lib
Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers PPPIPInterface.h Source File

PPPIPInterface.h

00001 /* PPPIPInterface.h */
00002 /*
00003 Copyright (C) 2012 ARM Limited.
00004 
00005 Permission is hereby granted, free of charge, to any person obtaining a copy of
00006 this software and associated documentation files (the "Software"), to deal in
00007 the Software without restriction, including without limitation the rights to
00008 use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
00009 of the Software, and to permit persons to whom the Software is furnished to do
00010 so, subject to the following conditions:
00011 
00012 The above copyright notice and this permission notice shall be included in all
00013 copies or substantial portions of the Software.
00014 
00015 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
00016 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
00017 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
00018 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
00019 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
00020 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
00021 SOFTWARE.
00022 */
00023 
00024 #ifndef PPPIPINTERFACE_H_
00025 #define PPPIPINTERFACE_H_
00026 
00027 #include "core/fwk.h"
00028 
00029 #include "LwIPInterface.h"
00030 
00031 #include "lwip/sio.h"
00032 
00033 namespace rtos {
00034 class Semaphore ;
00035 }
00036 using namespace rtos;
00037 
00038 /** Interface using PPP to connect to an IP-based network
00039  *
00040  */
00041 class PPPIPInterface : public LwIPInterface
00042 {
00043 public:
00044     PPPIPInterface(IOStream* pStream);
00045     virtual ~PPPIPInterface();
00046 
00047     virtual int init(); //Init PPP-specific stuff, create the right bindings, etc
00048     int setup(const char* user, const char* pw); //Setup authentication
00049   virtual int connect();
00050   virtual int disconnect();
00051 
00052 private:
00053     static void linkStatusCb(void *ctx, int errCode, void *arg); //PPP link status
00054     Semaphore  m_linkStatusSphre;
00055     int m_pppErrCode;
00056 
00057     IOStream* m_pStream; //Serial stream
00058     bool m_streamAvail;
00059 
00060     int m_pppd;
00061 
00062     friend u32_t sio_write(sio_fd_t fd, u8_t *data, u32_t len);
00063     friend u32_t sio_read(sio_fd_t fd, u8_t *data, u32_t len);
00064     friend void sio_read_abort(sio_fd_t fd);
00065 };
00066 
00067 #endif /* PPPIPINTERFACE_H_ */