Debian Codegraph @

gobi-api/Gobi_2012-06-18-1054/Core/QMIProtocolServer.h

raw
1 /*===========================================================================
2 FILE:
3 QMIProtocolServer.h
4
5 DESCRIPTION:
6 QMI protocol server
7
8 PUBLIC CLASSES AND METHODS:
9 cQMIProtocolServer
10
11 Copyright (c) 2012, Code Aurora Forum. All rights reserved.
12
13 Redistribution and use in source and binary forms, with or without
14 modification, are permitted provided that the following conditions are met:
15 * Redistributions of source code must retain the above copyright
16 notice, this list of conditions and the following disclaimer.
17 * Redistributions in binary form must reproduce the above copyright
18 notice, this list of conditions and the following disclaimer in the
19 documentation and/or other materials provided with the distribution.
20 * Neither the name of Code Aurora Forum nor
21 the names of its contributors may be used to endorse or promote
22 products derived from this software without specific prior written
23 permission.
24
25
26 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
27 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
28 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
29 ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
30 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
31 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
32 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
33 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
34 CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
35 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36 POSSIBILITY OF SUCH DAMAGE.
37 ===========================================================================*/
38
39 //---------------------------------------------------------------------------
40 // Pragmas
41 //---------------------------------------------------------------------------
42 #pragma once
43
44 //---------------------------------------------------------------------------
45 // Include Files
46 //---------------------------------------------------------------------------
47 #include "ProtocolServer.h"
48 #include "QMIEnum.h"
49
50 //---------------------------------------------------------------------------
51 // Definitions
52 //---------------------------------------------------------------------------
53
54 /*=========================================================================*/
55 // Class cQMIProtocolServer
56 /*=========================================================================*/
57 class cQMIProtocolServer : public cProtocolServer
58 {
59 public:
60 // Constructor
61 cQMIProtocolServer(
62 eQMIService serviceType,
63 ULONG bufferSzRx,
64 ULONG logSz );
65
66 // Destructor
67 virtual ~cQMIProtocolServer();
68
69 // Connect to the given QMI service using the configured QMI
70 // control file
71 bool Connect( LPCSTR pControlFile );
72
73 // (Inline) Return the QMI service type
74 eQMIService GetServiceType()
75 {
76 return mService;
77 };
78
79 protected:
80 // Validate a request that is about to be scheduled
81 virtual bool ValidateRequest( const sProtocolRequest & req );
82
83 // Perform protocol specific communications port initialization
84 virtual bool InitializeComm();
85
86 // Perform protocol specific communications port cleanup
87 virtual bool CleanupComm();
88
89 // Decode incoming data into packets returning the last response
90 virtual bool DecodeRxData(
91 ULONG bytesReceived,
92 ULONG & rspIdx,
93 bool & bAbortTx );
94
95 // Encode data for transmission
96 virtual sSharedBuffer * EncodeTxData(
97 sSharedBuffer * pBuffer,
98 bool & bEncoded );
99
100 // Is the passed in data a response to the current request?
101 virtual bool IsResponse( const sProtocolBuffer & rsp );
102
103 // (Inline) Is the passed in data a response that aborts the
104 // current request?
105 virtual bool IsTxAbortResponse( const sProtocolBuffer & /* rsp */ )
106 {
107 // QMI doesn't necessarily require this
108 return false;
109 };
110
111 /* Current transaction ID */
112 SHORT mLastTID;
113
114 /* Type of QMI service we are serving */
115 eQMIService mService;
116 };