Implementation of 3G USB Modem Huawei E372
PPPIPInterface.h@1:fbf17fb09581, 2015-02-20 (annotated)
- Committer:
- clemounet
- Date:
- Fri Feb 20 17:15:55 2015 +0000
- Revision:
- 1:fbf17fb09581
- Child:
- 2:61ac95f0af72
Add PPP networking
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
clemounet | 1:fbf17fb09581 | 1 | /* PPPIPInterface.h */ |
clemounet | 1:fbf17fb09581 | 2 | /* Copyright (C) 2012 mbed.org, MIT License |
clemounet | 1:fbf17fb09581 | 3 | * |
clemounet | 1:fbf17fb09581 | 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software |
clemounet | 1:fbf17fb09581 | 5 | * and associated documentation files (the "Software"), to deal in the Software without restriction, |
clemounet | 1:fbf17fb09581 | 6 | * including without limitation the rights to use, copy, modify, merge, publish, distribute, |
clemounet | 1:fbf17fb09581 | 7 | * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is |
clemounet | 1:fbf17fb09581 | 8 | * furnished to do so, subject to the following conditions: |
clemounet | 1:fbf17fb09581 | 9 | * |
clemounet | 1:fbf17fb09581 | 10 | * The above copyright notice and this permission notice shall be included in all copies or |
clemounet | 1:fbf17fb09581 | 11 | * substantial portions of the Software. |
clemounet | 1:fbf17fb09581 | 12 | * |
clemounet | 1:fbf17fb09581 | 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING |
clemounet | 1:fbf17fb09581 | 14 | * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
clemounet | 1:fbf17fb09581 | 15 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, |
clemounet | 1:fbf17fb09581 | 16 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
clemounet | 1:fbf17fb09581 | 17 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
clemounet | 1:fbf17fb09581 | 18 | */ |
clemounet | 1:fbf17fb09581 | 19 | |
clemounet | 1:fbf17fb09581 | 20 | #ifndef PPPIPINTERFACE_H_ |
clemounet | 1:fbf17fb09581 | 21 | #define PPPIPINTERFACE_H_ |
clemounet | 1:fbf17fb09581 | 22 | |
clemounet | 1:fbf17fb09581 | 23 | #include "core/fwk.h" |
clemounet | 1:fbf17fb09581 | 24 | |
clemounet | 1:fbf17fb09581 | 25 | #include "LwIPInterface.h" |
clemounet | 1:fbf17fb09581 | 26 | |
clemounet | 1:fbf17fb09581 | 27 | #include "lwip/sio.h" |
clemounet | 1:fbf17fb09581 | 28 | |
clemounet | 1:fbf17fb09581 | 29 | namespace rtos { |
clemounet | 1:fbf17fb09581 | 30 | class Semaphore; |
clemounet | 1:fbf17fb09581 | 31 | } |
clemounet | 1:fbf17fb09581 | 32 | using namespace rtos; |
clemounet | 1:fbf17fb09581 | 33 | |
clemounet | 1:fbf17fb09581 | 34 | /** Interface using PPP to connect to an IP-based network |
clemounet | 1:fbf17fb09581 | 35 | * |
clemounet | 1:fbf17fb09581 | 36 | */ |
clemounet | 1:fbf17fb09581 | 37 | class PPPIPInterface : public LwIPInterface |
clemounet | 1:fbf17fb09581 | 38 | { |
clemounet | 1:fbf17fb09581 | 39 | public: |
clemounet | 1:fbf17fb09581 | 40 | PPPIPInterface(IOStream* pStream); |
clemounet | 1:fbf17fb09581 | 41 | virtual ~PPPIPInterface(); |
clemounet | 1:fbf17fb09581 | 42 | |
clemounet | 1:fbf17fb09581 | 43 | int init(); //Init PPP-specific stuff, create the right bindings, etc |
clemounet | 1:fbf17fb09581 | 44 | int setup(const char* user, const char* pw); //Setup authentication |
clemounet | 1:fbf17fb09581 | 45 | virtual int connect(); |
clemounet | 1:fbf17fb09581 | 46 | virtual int disconnect(); |
clemounet | 1:fbf17fb09581 | 47 | |
clemounet | 1:fbf17fb09581 | 48 | private: |
clemounet | 1:fbf17fb09581 | 49 | int cleanupLink(); |
clemounet | 1:fbf17fb09581 | 50 | |
clemounet | 1:fbf17fb09581 | 51 | static void linkStatusCb(void *ctx, int errCode, void *arg); //PPP link status |
clemounet | 1:fbf17fb09581 | 52 | Semaphore m_linkStatusSphre; |
clemounet | 1:fbf17fb09581 | 53 | int m_pppErrCode; |
clemounet | 1:fbf17fb09581 | 54 | |
clemounet | 1:fbf17fb09581 | 55 | IOStream* m_pStream; //Serial stream |
clemounet | 1:fbf17fb09581 | 56 | bool m_streamAvail; |
clemounet | 1:fbf17fb09581 | 57 | |
clemounet | 1:fbf17fb09581 | 58 | int m_pppd; |
clemounet | 1:fbf17fb09581 | 59 | |
clemounet | 1:fbf17fb09581 | 60 | friend u32_t sio_write(sio_fd_t fd, u8_t *data, u32_t len); |
clemounet | 1:fbf17fb09581 | 61 | friend u32_t sio_read(sio_fd_t fd, u8_t *data, u32_t len); |
clemounet | 1:fbf17fb09581 | 62 | friend void sio_read_abort(sio_fd_t fd); |
clemounet | 1:fbf17fb09581 | 63 | }; |
clemounet | 1:fbf17fb09581 | 64 | |
clemounet | 1:fbf17fb09581 | 65 | #endif /* PPPIPINTERFACE_H_ */ |