C12Adapter Opensource C++ Interface
|
ANSI C12.22 protocol implementation. More...
Public Member Functions | |
MProtocolC1222 (MChannel *channel=NULL, bool channelIsOwned=true) | |
Create C12.22 protocol object. More... | |
virtual | ~MProtocolC1222 () |
Destroy the protocol object. | |
void | DisconnectService () |
Perform ANSI C12 Disconnect request. More... | |
virtual void | SetIssueSecurityOnStartSession (bool) |
Whether the start session includes the security service or the authenticate service. More... | |
unsigned | GetNegotiatedMaximumApduSizeIncoming () const |
Get the incoming negotiated maximum size of the APDU. More... | |
unsigned | GetNegotiatedMaximumApduSize () const |
Get the outgoing negotiated maximum size of the APDU. More... | |
virtual void | ChangeNegotiatedMaximumApduSizeIncoming (unsigned size) |
Change the negotiated incoming maximum APDU size parameter in a way so that all dependents are also updated. | |
virtual void | ChangeNegotiatedMaximumApduSizeOutgoing (unsigned size) |
Change the negotiated outgoing maximum APDU size parameter in a way so that all dependents are also updated. | |
int | GetIncomingCallingAeQualifier () const |
The Incoming Application Entity Qualifier is to supply additional information about the message. More... | |
MByteString | GetIncomingEpsem () const |
The whole incoming application EPSEM. More... | |
MByteString | GetOutgoingApdu () const |
Get the whole outgoing application data unit. More... | |
const MStdString & | GetIncomingEdClass () const |
Get the EPSEM EdClass that was used in the last EPSEM response. More... | |
const MStdString & | GetIncomingCalledApTitle () const |
The Called Application Title of the incoming EPSEM packet. More... | |
const MStdString & | GetIncomingCallingApTitle () const |
The Calling Application Title of the incoming EPSEM packet. More... | |
SecurityModeEnum | GetIncomingSecurityMode () const |
Security Mode of the incoming EPSEM packet. More... | |
ResponseControlEnum | GetIncomingResponseControl () const |
The Response Control of the incoming EPSEM packet, as defined by the ANSI Standard C12.22 documentation. More... | |
unsigned | GetIncomingSecurityKeyId () const |
The value of security key ID, as received from the peer in the most recent APDU. More... | |
unsigned | GetIncomingInitializationVector () const |
The value of initialization vector, as received from the peer in the most recent APDU. More... | |
unsigned | GetIncomingCallingApInvocationId () const |
The value of invocation ID received from the peer in the most recent APDU. More... | |
int | GetSecurityKeyListSuccessfulEntry () const |
Return the entry which was successfully tried with the meter. | |
void | ServerStart () |
Start processing of the incoming APDU. More... | |
void | ServerReset () |
Reset server so that it is ready to send back the outgoing APDU. More... | |
void | ProcessIncomingEPSEM () |
Initialize protocol machine for processing the incoming EPSEM. More... | |
void | ServerEnd () |
End the processing of incoming request by making and sending back the response. More... | |
void | SendStart () |
Start making the outgoing EPSEM packet. | |
void | SendEnd () |
Finish making the outgoing EPSEM packet and send it out to client. | |
bool | SendEndReceiveStart () |
Combines SendEnd and ReceiveStart. More... | |
virtual void | ReadApdu () |
Read raw incoming APDU. More... | |
void | WriteApdu (const MByteString &buffer) |
Write raw incoming APDU. More... | |
void | ReceiveStart () |
Start parsing the incoming EPSEM. | |
void | ReceiveEnd () |
End parsing the incoming EPSEM. | |
void | SendService (char command) |
Send command-only service. More... | |
void | SendServiceWithData (char command, const MByteString &data) |
Send service with command and data. More... | |
unsigned | ReceiveServiceLength () |
Receive service length. More... | |
char | ReceiveServiceCodeIgnoreLength () |
Receive and ignore service length, then service code or status. More... | |
virtual void | Logon () |
Perform ANSI C12 Logon request, both request and response. More... | |
virtual void | ApplyChannelParameters () |
Setup the configuration of the channel according to C12.22 protocol handshake settings. | |
void | SetSecurityMode (SecurityModeEnum mode) |
SecurityModeEnum | GetSecurityMode () const |
void | SetSecurityKey (const MStdString &) |
MStdString | GetSecurityKey () const |
void | SetSecurityKeyId (int) |
int | GetSecurityKeyId () const |
void | SetSessionless (bool) |
bool | GetSessionless () const |
bool | GetOneServicePerApdu () const |
When OneServicePerApdu is true the behavior differs. More... | |
void | SetOneServicePerApdu (bool yes) |
When OneServicePerApdu is true the behavior differs. More... | |
ResponseControlEnum | GetResponseControl () const |
void | SetResponseControl (ResponseControlEnum c) |
bool | GetIssueTerminateOnEndSession () const |
void | SetIssueTerminateOnEndSession (bool yes) |
bool | GetNegotiatedSessionIdleTimeoutPresent () const |
unsigned | GetNegotiatedSessionIdleTimeout () const |
unsigned | GetResponseTimeout () const |
void | SetResponseTimeout (unsigned timeout) |
unsigned | GetMaximumApduSizeIncoming () const |
void | SetMaximumApduSizeIncoming (unsigned size) |
unsigned | GetMaximumApduSize () const |
void | SetMaximumApduSize (unsigned size) |
int | GetCallingAeQualifier () const |
void | SetCallingAeQualifier (int q) |
void | SetApplicationContext (const MStdString &) |
const MStdString & | GetApplicationContext () const |
void | SetCallingApTitle (const MStdString &) |
const MStdString & | GetCallingApTitle () const |
unsigned | GetSessionIdleTimeout () const |
void | SetSessionIdleTimeout (unsigned timeout) |
void | SetCalledApTitle (const MStdString &calledApTitle) |
const MStdString & | GetCalledApTitle () const |
const MStdString & | GetEdClass () const |
void | SetEdClass (const MStdString &edClass) |
MByteString | GetIncomingApdu () const |
void | SetIncomingApdu (const MByteString &) |
unsigned | GetInitializationVector () const |
void | SetInitializationVector (unsigned id) |
unsigned | GetCallingApInvocationId () const |
void | SetCallingApInvocationId (unsigned id) |
const MByteStringVector & | GetSecurityKeyList () const |
void | SetSecurityKeyList (const MByteStringVector &) |
void | SendLogon () |
void | ReceiveLogon () |
void | SendSecurity () |
void | ReceiveSecurity () |
void | SendTableRead (MCOMNumberConstRef number) |
MByteString | ReceiveTableRead (MCOMNumberConstRef number) |
void | SendTableWrite (MCOMNumberConstRef number, const MByteString &request) |
void | ReceiveTableWrite (MCOMNumberConstRef number, const MByteString &request) |
void | SendTableReadPartial (MCOMNumberConstRef number, int offset, int length) |
MByteString | ReceiveTableReadPartial (MCOMNumberConstRef number, int offset, int length) |
void | SendTableWritePartial (MCOMNumberConstRef number, const MByteString &request, int offset) |
void | ReceiveTableWritePartial (MCOMNumberConstRef number, const MByteString &request, int offset) |
void | FunctionExecuteSend (MCOMNumberConstRef number) |
void | FunctionExecuteReceive (MCOMNumberConstRef number) |
void | FunctionExecuteRequestSend (MCOMNumberConstRef number, const MByteString &request) |
void | FunctionExecuteRequestReceive (MCOMNumberConstRef number, const MByteString &request) |
void | FunctionExecuteResponseSend (MCOMNumberConstRef number) |
MByteString | FunctionExecuteResponseReceive (MCOMNumberConstRef number) |
void | FunctionExecuteRequestResponseSend (MCOMNumberConstRef number, const MByteString &request) |
MByteString | FunctionExecuteRequestResponseReceive (MCOMNumberConstRef number, const MByteString &request) |
![]() | |
virtual | ~MProtocolC12 () |
Destroy the C12 protocol object. More... | |
virtual void | Security () |
Perform ANSI C12 Security service. More... | |
virtual void | FullLogin () |
Perform whatever is required by the protocol to clear security with the meter. More... | |
virtual void | Logoff () |
Perform ANSI C12 Logoff service. More... | |
virtual void | Wait (unsigned seconds) |
Perform ANSI C12 Wait service. More... | |
virtual void | Terminate () |
Perform ANSI C12 Terminate service. More... | |
virtual Muint16 | CalculateCRC16FromBuffer (const char *buffer, unsigned length) const |
Two-byte CRC calculation procedure specific to C12 protocol. More... | |
unsigned | GetMaximumReadTableSize () const |
Return the maximum possible size of a table to read partially or fully in a single application layer packet. More... | |
virtual unsigned | CalculateChecksumFromBuffer (const char *buffer, unsigned length) const |
Protocol dependent one-byte checksum calculation procedure that uses buffer and its size. More... | |
MByteString | ApplicationLayerRequestResponse (char command, const MByteString &request) |
Perform the full application layer request and return a response. More... | |
char | ReceiveServiceCode () |
Read a code of the incoming application layer data packet. More... | |
Muint8 | ReceiveServiceByte () |
Read one byte from the incoming application layer data packet. More... | |
unsigned | ReceiveServiceUInt (unsigned size) |
Read several bytes from the incoming application layer data packet. More... | |
MByteString | ReceiveServiceBytes (unsigned length) |
Read several bytes of the incoming application layer data packet. More... | |
MByteString | ReceiveServiceRemainingBytes () |
Read bytes of the incoming application layer data packet. More... | |
unsigned | GetLinkLayerRetries () const |
void | SetLinkLayerRetries (unsigned retries) |
bool | GetIssueSecurityOnStartSession () const |
ReadFunctionResponseEnum | GetAlwaysReadFunctionResponse () const |
void | SetAlwaysReadFunctionResponse (ReadFunctionResponseEnum value) |
bool | GetAlwaysUsePartial () const |
void | SetAlwaysUsePartial (bool yes) |
bool | GetUseReadInKeepSessionAlive () const |
void | SetUseReadInKeepSessionAlive (bool yes) |
unsigned | GetUserId () const |
void | SetUserId (unsigned userId) |
const MByteString & | GetUser () const |
void | SetUser (const MByteString &userName) |
unsigned | GetTurnAroundDelay () const |
void | SetTurnAroundDelay (unsigned delay) |
unsigned | GetApplicationLayerRetries () const |
void | SetApplicationLayerRetries (unsigned retries) |
unsigned | GetApplicationLayerRetryDelay () const |
void | SetApplicationLayerRetryDelay (unsigned milliseconds) |
unsigned | GetApplicationLayerProcedureRetries () const |
void | SetApplicationLayerProcedureRetries (unsigned retries) |
unsigned | GetApplicationLayerProcedureRetryDelay () const |
void | SetApplicationLayerProcedureRetryDelay (unsigned milliseconds) |
unsigned | GetProcedureSequenceNumber () const |
void | SetProcedureSequenceNumber (unsigned number) |
void | SetEndSessionOnApplicationLayerError (bool endSessionOnApplicationLayerError) |
bool | GetEndSessionOnApplicationLayerError () const |
![]() | |
virtual MProtocol * | CreateClone () const |
Virtual copy constructor, creates the protocol which is a clone of current. More... | |
virtual | ~MProtocol ()=0 |
Destroy the protocol object. More... | |
void | Finalize () |
Execute this method as first action in the destructor of any child protocol. More... | |
unsigned | GetCountApplicationLayerServicesSuccessful () const |
The number of Application Layer services that have been successfully processed. More... | |
void | IncrementCountApplicationLayerServicesSuccessful () |
Increment the number of application layer services successfully processed. More... | |
unsigned | GetCountApplicationLayerServicesRetried () const |
The number of Application Layer services that have been retried. More... | |
void | IncrementCountApplicationLayerServicesRetried () |
Increment the number of application layer services retried. More... | |
unsigned | GetCountApplicationLayerServicesFailed () const |
The number of Application Layer services that have failed. More... | |
void | IncrementCountApplicationLayerServicesFailed () |
Increment the number of application layer services failed. More... | |
unsigned | GetCountLinkLayerPacketsSuccessful () const |
The number of Link Layer packets that have been successfully processed. More... | |
void | IncrementCountLinkLayerPacketsSuccessful () |
Increment the number of data link layer packets successfully processed. More... | |
unsigned | GetCountLinkLayerPacketsRetried () const |
The number of Link Layer packets that have been retried. More... | |
void | IncrementCountLinkLayerPacketsRetried () |
Increment the number of data link layer packets retried. More... | |
unsigned | GetCountLinkLayerPacketsFailed () const |
Get number of data link layer packets failed. More... | |
void | IncrementCountLinkLayerPacketsFailed () |
Increment the number of data link layer packets failed. More... | |
unsigned | GetMaximumRoundTripTime () const |
Gets the maximum measured approximate packet round trip time over the link layer. More... | |
unsigned | GetMinimumRoundTripTime () const |
Gets the minimum measured approximate packet round trip time over the link layer. More... | |
unsigned | GetAverageRoundTripTime () const |
Gets the average measured approximate packet round trip time over the link layer. More... | |
void | ClearPasswordList () |
Set the password list for the protocol to none, so the SetPassword property is used. More... | |
void | AddToPasswordList (const MByteString &password) |
Add a password to the password list. More... | |
int | GetPasswordListSuccessfulEntry () const |
Return the entry, which was successfully tried with the meter. More... | |
void | ResetCounts () |
Clear the statistical data for the channel. More... | |
void | Connect () |
Initializes the channel and establishes the connection with the peer. More... | |
void | Disconnect () |
Severs the connection between the computer and the end device. More... | |
bool | IsConnected () const |
Tells whether the protocol is currently connected. More... | |
bool | IsInSession () const |
Whether the protocol is in session. More... | |
MProgressAction * | CreateRootProgressAction () |
Create root of the progress actions hierarchy. More... | |
MProgressAction * | GetLocalProgressAction () |
Read-only access to the currently preset local action in progress monitor. More... | |
bool | QNeedToCommit () const |
Whether or not it is time to call QCommit(true) in order to sync with the background thread. More... | |
bool | QIsBackgroundCommunicationProgressing () const |
True if the background communication is still progressing. More... | |
bool | QIsDone () |
Combines QNeedToCommit with the following QCommit in case all commands in the queue have been sent. More... | |
void | QAbort () |
Clears the commands in the queue, or cancel the ongoing background communication. More... | |
void | QWriteToMonitor (const MStdString &message) |
Add the message to write to the Monitor log file to MProtocol's command queue. More... | |
void | QConnect () |
Places a Connect command in the queue. More... | |
void | QDisconnect () |
Places a Disconnect command in the queue. More... | |
void | QIdentifyMeter () |
Places an IdentifyMeter task in the queue. More... | |
void | QStartSession () |
Adds a start session command to MProtocol's command queue. More... | |
void | QEndSession () |
Adds an end session command to MProtocol's command queue. More... | |
void | QEndSessionNoThrow () |
EndSessionNoThrow request is queued. More... | |
void | QTableRead (MCOMNumberConstRef number, unsigned expectedSize, int id) |
Adds a ReadTable command to MProtocol's command queue. More... | |
void | QTableWrite (MCOMNumberConstRef number, const MByteString &data) |
Adds a table write command to MProtocol's command queue. More... | |
void | QTableReadPartial (MCOMNumberConstRef number, int offset, int size, int id) |
Adds a partial table read command to MProtocol's command queue. More... | |
void | QTableWritePartial (MCOMNumberConstRef number, const MByteString &data, int offset) |
Adds a partial table write command to MProtocol's command queue. More... | |
void | QFunctionExecute (MCOMNumberConstRef number) |
Place a function without data request in MProtocol command queue. More... | |
void | QFunctionExecuteRequest (MCOMNumberConstRef number, const MByteString &request) |
Place a function with request data in MProtocol's command queue. More... | |
void | QFunctionExecuteResponse (MCOMNumberConstRef number, int id, unsigned estimatedResponseSize=DEFAULT_ESTIMATED_RESPONSE_SIZE) |
Place a function with response data in MProtocol's command queue. More... | |
void | QFunctionExecuteRequestResponse (MCOMNumberConstRef number, const MByteString &request, int id, unsigned estimatedResponseSize=DEFAULT_ESTIMATED_RESPONSE_SIZE) |
Place a function with request and response data in MProtocol's command queue. More... | |
virtual void | QCommit (bool asynchronously=false) |
Executes all operations in MProtocol's command queue. More... | |
MByteString | QGetTableData (MCOMNumberConstRef number, int id=-1) |
Fetch the table data after the table read has been successfully performed by QCommit. More... | |
MByteString | QGetFunctionData (MCOMNumberConstRef number, int id=-1) |
Fetch the function response data after the function has been successfully executed in QCommit. More... | |
MStdString | QGetIdentifyMeterData () |
Fetch the identify meter string after the QIdentifyMeter has been successfully performed in QCommit. More... | |
virtual void | WriteToMonitor (const MStdString &message) |
Synchronously write a message to the monitor, if it is connected. More... | |
void | WriteCountsToMonitor () |
Write running values of communication quality counters to monitor. More... | |
void | StartSession () |
Synchronously start the session. More... | |
void | EndSession () |
Synchronously end the session. More... | |
void | EndSessionNoThrow () |
End the session, but do not throw errors. More... | |
Muint8 | ReadStartByte (const MByteString &setOfValidStartBytes, unsigned trafficTimeout) |
Read the start byte of the packet in a proper way, taking into consideration timeouts and ignoring garbage. More... | |
MByteString | TableRead (MCOMNumberConstRef number, unsigned expectedSize=0) |
Synchronously read the whole table with number given as parameter. More... | |
void | TableReadBuffer (MCOMNumberConstRef number, void *buff, unsigned size) |
Same as ReadTable, but instead of returning a byte string, read table into a given buffer. More... | |
template<class T > | |
void | TableReadBuffer (MCOMNumberConstRef number, T &table) |
Same as ReadTable, but instead of returning a byte string, read table into a given template variable. More... | |
MByteString | TableReadNoThrow (MCOMNumberConstRef number, MException **exception, unsigned expectedSize=0) |
Synchronously read the whole table with number given as parameter, do not throw an exception, but rather return it. More... | |
void | TableWrite (MCOMNumberConstRef number, const MByteString &data) |
Synchronously write the whole table with number given as parameter. More... | |
void | TableWriteBuffer (MCOMNumberConstRef number, const void *data, unsigned size) |
Same as TableWrite, but uses buffer, given as data and size parameters. More... | |
template<class T > | |
void | TableWriteBuffer (MCOMNumberConstRef number, const T &table) |
Same as WriteTable, but uses variable of some specific template class or structure. More... | |
MByteString | TableReadPartial (MCOMNumberConstRef number, int offset, int size) |
Synchronously read part of the table with number given as parameter. More... | |
void | TableReadPartialBuffer (MCOMNumberConstRef number, int offset, void *buff, unsigned size) |
Same as TableReadPartial, but instead of returning a byte string, read table into a given buffer. More... | |
template<class T > | |
void | TableReadPartialBuffer (MCOMNumberConstRef number, T &table, int offset) |
Same as TableReadPartial, but instead of returning a byte string, partially read table into a given template variable. More... | |
void | TableWritePartial (MCOMNumberConstRef number, const MByteString &data, int offset) |
Synchronously write part of the table with number given as parameter. More... | |
void | TableWritePartialBuffer (MCOMNumberConstRef number, int offset, const void *buff, unsigned size) |
Same as TableWritePartial, but instead of using a byte string, write table using a given buffer. More... | |
template<class T > | |
void | TableWritePartialBuffer (MCOMNumberConstRef number, const T &table, int offset) |
Same as TableWritePartial, but instead of using a byte string, write table using a given template class contents. More... | |
void | FunctionExecute (MCOMNumberConstRef number) |
Synchronously execute the function with no parameters, the number of the function is given as parameter. More... | |
void | FunctionExecuteRequest (MCOMNumberConstRef number, const MByteString &request) |
Synchronously execute the function with request data, the number of the function is given as parameter. More... | |
MByteString | FunctionExecuteResponse (MCOMNumberConstRef number) |
Synchronously execute the function with response data, the number of the function is given as parameter. More... | |
MByteString | FunctionExecuteRequestResponse (MCOMNumberConstRef number, const MByteString &request) |
Synchronously execute the function with request and response data, the number of the function is given as parameter. More... | |
virtual unsigned | GetNumberOfDataLinkPackets (MCommunicationCommand::CommandType typeOfRequest, unsigned applicationLayerDataSize=0) |
Return the number of data link packets that are required for a given request, provided an optional size of the application data. More... | |
MStdString | IdentifyMeterWithContext (bool sessionIsStarted=false, TableRawDataVector *tablesRead=NULL) |
Identify the meter if the protocol is known (note this is not an ANSI Identify protocol command). More... | |
unsigned | CalculateChecksum (const MByteString &buffer) const |
Protocol dependent one-byte checksum calculation procedure that uses byte string. More... | |
unsigned | CalculateCRC16 (const MByteString &buffer) const |
Protocol dependent two-byte CRC calculation procedure that accepts the byte string. More... | |
void | Sleep (unsigned milliseconds) |
Calls channel's Sleep method if the channel is present. More... | |
bool | GetMeterIsLittleEndian () const |
void | SetMeterIsLittleEndian (bool isLittleEndian) |
MChannel * | GetChannel () const |
void | SetChannel (MChannel *channel) |
bool | IsChannelOwned () const |
void | SetIsChannelOwned (bool yes) |
bool | GetKeepSessionAlive () const |
void | SetKeepSessionAlive (bool alive) |
MByteString | GetPassword () const |
void | SetPassword (const MByteString &password) |
const MByteStringVector & | GetPasswordList () const |
void | SetPasswordList (const MByteStringVector &passwordList) |
MProgressMonitor * | GetProgressMonitor () const |
void | SetProgressMonitor (MProgressMonitor *p) |
MCommunicationQueue & | GetCommandQueue () |
M_NO_PROGRESS_MONITOR. More... | |
const MCommunicationQueue & | GetCommandQueue () const |
M_NO_PROGRESS_MONITOR. More... | |
MStdString | IdentifyMeter (bool sessionIsStarted=false) |
MStdString | DoIdentifyMeter0 () |
![]() | |
virtual | ~MCOMObject () |
Object destructor. | |
virtual MStdStringVector | GetAllPropertyNames () const |
Return the list of publicly available properties in MCOM syntax. More... | |
virtual MStdStringVector | GetAllPersistentPropertyNames () const |
Return the list of publicly available persistent properties in MCOM syntax. More... | |
MStdString | GetPersistentPropertyValues (bool onlyNondefaults=false, bool excludeSecurityRelated=false) const |
Get the string with the list of persistent property names and their values. More... | |
void | SetPersistentPropertyValues (const MStdString &values) |
Set the persistent properties for the object using the string with the following format: More... | |
void | SetPropertyValues (const MDictionary &values) |
Set the properties for the object using the property list object. More... | |
void | WritePropertiesToMonitor () |
Write all non-default values of protocol properties into monitor. More... | |
MStdString | DoGetPersistentPropertyValues0 () const |
Get the string with the whole list of persistent property names and their values. More... | |
MStdString | DoGetPersistentPropertyValues1 (bool onlyNondefaults) const |
Get the string with the list of persistent property names and their values. More... | |
![]() | |
virtual | ~MObject () |
Object destructor. | |
virtual const MClass * | GetClass () const =0 |
Get the final class of the object. More... | |
virtual unsigned | GetEmbeddedSizeof () const |
For embedded object types, return the size of the class. More... | |
bool | IsEmbeddedObject () const |
Tell if the object is of embedded kind. More... | |
SHOW_INTERNAL MVariant | Call (const MStdString &name, const MVariant ¶ms) |
Call the object service with parameters, given as variant. More... | |
MVariant | Call0 (const MStdString &name) |
Call the object service with no parameters. More... | |
MVariant | Call1 (const MStdString &name, const MVariant &p1) |
Call the object service with one parameter. More... | |
MVariant | Call2 (const MStdString &name, const MVariant &p1, const MVariant &p2) |
Call the object service with two parameter. More... | |
MVariant | Call3 (const MStdString &name, const MVariant &p1, const MVariant &p2, const MVariant &p3) |
Call the object service with three parameter. More... | |
MVariant | Call4 (const MStdString &name, const MVariant &p1, const MVariant &p2, const MVariant &p3, const MVariant &p4) |
Call the object service with four parameter. More... | |
MVariant | Call5 (const MStdString &name, const MVariant &p1, const MVariant &p2, const MVariant &p3, const MVariant &p4, const MVariant &p5) |
Call the object service with five parameter. More... | |
MVariant | Call6 (const MStdString &name, const MVariant &p1, const MVariant &p2, const MVariant &p3, const MVariant &p4, const MVariant &p5, const MVariant &p6) |
Call the object service with six parameter. More... | |
virtual MVariant | CallV (const MStdString &name, const MVariant::VariantVector ¶ms) |
Call the object service with parameters, given as variant vector. More... | |
virtual bool | IsPropertyPresent (const MStdString &name) const |
Tell if the property with the given name exists. | |
virtual bool | IsServicePresent (const MStdString &name) const |
Tell if the service with the given name exists. | |
virtual MVariant | GetProperty (const MStdString &name) const |
Get the property value using name of the property. More... | |
virtual void | SetProperty (const MStdString &name, const MVariant &value) |
Set the property using name of the property, and value. More... | |
virtual void | SetPersistentPropertiesToDefault () |
Set the persistent properties of the object to their default values. More... | |
virtual MVariant | GetPersistentPropertyDefaultValue (const MStdString &name) const |
Get the default value of persistent property with the name given. More... | |
virtual void | SetPersistentPropertyToDefault (const MStdString &name) |
Set the persistent property with the name given to default value. More... | |
virtual const char * | GetType () const |
Get the name of the type for the object (could be the same as class name). | |
virtual void | SetType (const MStdString &) |
Intentionally, it will set the name of the type for the object, but the service will not allow setting the name to anything other than the current name. More... | |
virtual void | Validate () |
Validate internal structures of the object. More... | |
Additional Inherited Members | |
![]() | |
static unsigned | StaticCalculateChecksum (const MByteString &buff) |
Compute checksum of the byte string given as parameters. More... | |
static unsigned | StaticCalculateChecksumFromBuffer (const char *data, unsigned size) |
Compute checksum of the buffer and length given as parameters. More... | |
static Muint16 | StaticCalculateCRC16FromBuffer (const char *buffer, unsigned length) |
Two-byte CRC calculation static procedure specific to C12 protocol. More... | |
static unsigned | CRC16 (const MByteString &buffer) |
Same as above, but taking byte string, reflected. More... | |
![]() | |
static unsigned | StaticCalculateChecksumFromBuffer (const char *buff, unsigned size) |
Most popular one-byte checksum calculation procedure, a sum of all bytes. More... | |
static unsigned | StaticCalculateChecksum (const MByteString &buffer) |
Compute checksum of the byte string given as parameters. More... | |
![]() | |
static const MClass * | GetStaticClass () |
Get the declared class of this particular object. More... | |
static bool | IsClassPresent (const MStdString &name) |
Tells if the given class name is available. More... | |
![]() | |
static const MClass | s_class |
Class of MObject. | |
![]() | |
MProtocolC12 (MChannel *channel, bool channelIsOwned=true) | |
Create a new abstract ANSI C12 protocol with the channel given. More... | |
![]() | |
MProtocol (MChannel *channel, bool channelIsOwned=true) | |
Create a new abstract protocol with the channel given. More... | |
virtual void | DoStartSession () |
Synchronously start the session, don't do service count. More... | |
virtual void | DoEndSession () |
Synchronously end the session, don't do service count. More... | |
virtual void | DoTableRead (MCOMNumberConstRef number, MByteString &data, unsigned expectedSize=0) |
Synchronously read the whole table with number given as parameter, don't do service count. More... | |
virtual void | DoTableWrite (MCOMNumberConstRef number, const MByteString &data) |
Synchronously write the whole table with number given as parameter, don't do service count. More... | |
virtual void | DoTableReadPartial (MCOMNumberConstRef number, MByteString &data, int offset, int size) |
Synchronously read part of the table with number given as parameter, don't do service count. More... | |
virtual void | DoTableWritePartial (MCOMNumberConstRef number, const MByteString &data, int offset) |
Synchronously write part of the table with number given as parameter, don't do service count. More... | |
virtual void | DoFunctionExecute (MCOMNumberConstRef number) |
Synchronously execute the function with no parameters, the number of the function is given as parameter, don't do service count. More... | |
virtual void | DoFunctionExecuteRequest (MCOMNumberConstRef number, const MByteString &request) |
Synchronously execute the function with request data, the number of the function is given as parameter, don't do service count. More... | |
virtual void | DoFunctionExecuteResponse (MCOMNumberConstRef number, MByteString &response) |
Synchronously execute the function with response data, the number of the function is given as parameter, don't do service count. More... | |
virtual void | DoFunctionExecuteRequestResponse (MCOMNumberConstRef number, const MByteString &request, MByteString &response) |
Synchronously execute the function with request and response data, the number of the function is given as parameter, don't do service count. More... | |
virtual MStdString | DoIdentifyMeter (bool sessionIsStarted, TableRawDataVector *tablesRead) |
Identify the meter if the protocol is known (note this is not an ANSI Identify protocol command). More... | |
void | DoTryPasswordOrPasswordList () |
Try password or passwords for the protocol according to the PASSWORD and PasswordList settings. More... | |
virtual void | DoTryPasswordEntry (const MByteString &entry) |
Try one password, throw if error. More... | |
virtual void | DoBuildComplexServiceName (MChars fullServiceName, MConstChars serviceName, MCOMNumberConstRef number, int par1=-1, int par2=-1) |
Build service name with a number and given parameters. More... | |
void | DoBuildPossiblyNumericComplexServiceName (MChars fullServiceName, MConstChars serviceName, MCOMNumberConstRef number, bool isHex, int par1=-1, int par2=-1) |
Helper service name builder that can interpret numeric values either as hex or as decimal. More... | |
![]() | |
MCOMObject () | |
Object constructor, protected as the class is abstract. | |
![]() | |
MObject () | |
Object constructor, protected as the class is abstract. | |
void | DoSetPersistentPropertiesToDefault (const MClass *staticClass) |
Set the persistent properties to their default values for one object provided the class for that object. More... | |
ANSI C12.22 protocol implementation.
ANSI Std C12.22-200x "PROTOCOL SPECIFICATION FOR INTERFACING TO DATA COMMUNICATION NETWORKS", is intended as a single communications standard for Water, Gas, and Electricity meters that will work on any manufacturer's conforming product. The ANSI C12.22 protocol was developed to transport table data over a networking communications system. It does not have a data link layer, so the link layer counter properties will remain zero for this protocol. A copy of the document can be obtained through NEMA or ANSI.
MProtocolC1222 is intended for communications through the socket channel, MChannelSocket.
anonymous enum |
Enumerator | |
---|---|
MaximumProperApduHeaderSize |
Maximum possible size of APDU header (everything but data), calculated correctly. |
MaximumLegacyApduHeaderSize |
Maximum possible size of APDU header (everything but data), calculated by legacy former devices. |
MaximumEpsemServiceLengthSize |
Maximum size in bytes of ISO length of a PSEM within EPSEM. The length will be is 1 to 3 bytes. 3 bytes is when it is bigger than 0xFF. |
MinimumMaximumApduTotalSize |
Minimum supported total size of APDU. As applied to GetMaximumApduSize and GetMaximumApduSizeIncoming |
MaximumMaximumApduTotalSize |
Maximum supported total size of APDU. As applied to GetMaximumApduSize and GetMaximumApduSizeIncoming |
EPSEM Response control bits.
Comprises all possible values of property GetResponseControl
Enumerator | |
---|---|
ResponseControlAlways |
Always respond to a C12.22 request. |
ResponseControlOnException |
Respond only on exception. |
ResponseControlNever |
Never respond, one way communication. |
Values for security mode property.
Property GetSecurityMode is based on ASCII standard's definition of security modes.
|
explicit |
Create C12.22 protocol object.
channel | The channel object. Most often used object here will be MChannelSocket, When this parameter is NULL, the channel shall be given later to SetChannel property prior to any communication attempt. |
channelIsOwned | Whether the channel object is owned by the protocol. The value can be set later using SetIsChannelOwned property.
|
void MProtocolC1222::DisconnectService | ( | ) |
Perform ANSI C12 Disconnect request.
This is named DisconnectService because the name Disconnect is already used in class MProtocol.
void MProtocolC1222::FunctionExecuteReceive | ( | MCOMNumberConstRef | number | ) |
Process PSEM with C12 function (procedure) execute service, no request or response.
void MProtocolC1222::FunctionExecuteRequestReceive | ( | MCOMNumberConstRef | number, |
const MByteString & | request | ||
) |
Process PSEM with C12 function (procedure) execute service, request is present.
MByteString MProtocolC1222::FunctionExecuteRequestResponseReceive | ( | MCOMNumberConstRef | number, |
const MByteString & | request | ||
) |
Process PSEM with C12 function (procedure) execute service, both request and response are present.
void MProtocolC1222::FunctionExecuteRequestResponseSend | ( | MCOMNumberConstRef | number, |
const MByteString & | request | ||
) |
Process PSEM with C12 function (procedure) execute service, both request and response are present.
void MProtocolC1222::FunctionExecuteRequestSend | ( | MCOMNumberConstRef | number, |
const MByteString & | request | ||
) |
Process PSEM with C12 function (procedure) execute service, request is present.
MByteString MProtocolC1222::FunctionExecuteResponseReceive | ( | MCOMNumberConstRef | number | ) |
Process PSEM with C12 function (procedure) execute service, response is present.
void MProtocolC1222::FunctionExecuteResponseSend | ( | MCOMNumberConstRef | number | ) |
Process PSEM with C12 function (procedure) execute service, response is present.
void MProtocolC1222::FunctionExecuteSend | ( | MCOMNumberConstRef | number | ) |
Process PSEM with C12 function (procedure) execute service, no request or response.
|
inline |
Application context is the ISO8825 Universal Identifier of the common context for all Relative IOS8825 Universal Identifiers used by the protocol.
When ApplicationContext is "", it is not included in the message. Both the C12.22 Client and C12.22 Communication Module assume that the ApplicationContext is "2.16.124.113620.1.22", which is the identifier reserved to C12.22.
The following text is taken, nearly verbatim, from the ANSI C12.22 standard:
The called application title uniquely identifies the target of an ACSE (Association Control Service Element, ISO8650-1-1995) message. This uniqueness is guaranteed by the use of an Absolute or Relative Universal Identifier. Relative Universal Identifiers are derived from the ANSI C12.22 ApTitle branch (<application-context-oid>.0).
The value of <application-context-oid> is set by ApplicationContext. The value of the called application title is set by GetCalledApTitle. Here is an example of how to use Relative Universal Identifiers:
When using Relative Universal Identifiers, the CalledApTitle should start with a period. However, no error is thrown if it doesn't which allows firmware developers and testers to try invalid combinations.
Here is an example of how to use Absolute Universal Identifiers:
When MeteringSDK assembles the message, the ApplicationContext property (if not "") is sent in the Application Context Element (0xA1), and the GetCalledApTitle is sent in the Called AP Title Element (0xA2).
For more information, refer to the ANSI Standard C12.22-200x documentation, or the ISO8825-1-1997 documentation.
|
inline |
Called Ap Title is the ISO8825 Universal Identifier of the called application. If the string is empty, no Application Title will be associated with the called application and it will not be sent to the device.
The following is taken, nearly verbatim from the ANSI C12.22 standard:
The called application title uniquely identifies the target of an ACSE (Association Control Service Element, ISO8650-1-1995) message. This uniqueness is guaranteed by the use of an Absolute or Relative Universal Identifier. Relative Universal Identifiers are derived from the ANSI C12.22 ApTitle branch (application-context-oid.0).
The value of application-context-oid is set by GetApplicationContext. Here is an example of how to use Absolute Universal Identifiers:
Here is an example of how to use Relative Universal Identifiers:
When using Relative Universal Identifiers, the CalledApTitle should start with a period. However, no error is thrown if it doesn't which allows firmware developers and testers to try invalid combinations.
When MeteringSDK assembles the message, the GetApplicationContext property (if not "") is sent in the Application Context Element (0xA1), and the CalledApTitle is sent in the Called AP Title Element (0xA2).
The effect of setting this property will take place next time the session is started, or the logon procedure is performed.
For more information, refer to the ANSI Standard C12.22-200x documentation, or the ISO8825-1-1997 documentation.
|
inline |
Calling Application Entity Qualifier is to supply additional information about the message.
In MeteringSDK 6.1.0.3832, this property was renamed from IncomingAeQualifier to IncomingCallingAeQualifier
This is an optional ACSE element, bit mask. When it is -1, the AE Qualifier was not included in the incoming message, or there was no incoming message. The property stands for the outgoing message, while there is also a read-only property IncomingCallingAeQualifier. When the device does not support Calling AE Qualifier, the incoming property will not be present (will return -1).
The ANSI C12.22 standard defines the following bits for the AE Qualifier:
|
inline |
The value of calling invocation ID as used in the outgoing APDU.
Accessing this property has debugging and security purpose only. MCOM will always send the invocation ID in the outgoing packet, behaving as the standard requires, but if this property is assigned by the application, the newly assigned value will be used exactly once in the next APDU, after which MCOM will be using its default behavior again.
|
inline |
Calling Ap Title is the ISO8825 Universal Identifier of the calling application.
If the string is empty, no Application Title will be associated with the calling application. The calling application title uniquely identifies the initiator of an ASCE (Association Control Service Element, ISO8650-1-1995) message. This uniqueness is guaranteed by the use of a absolute or relative Universal Identifier. Relative Universal Identifiers are derived from the ANSI C12.22 ApTitle branch (1.2.840.10066.3).
The effect of setting this property will take place next time the session is started, or the logon procedure is performed.
|
inline |
The EdClass string to place in the outgoing packet.
If this is an empty string, EdClass will not be included into the EPSEM outgoing request. The EdClass is encoded in the General Configuration Table (Table 0) of ANSI C12.19 Version 2.0 or the MANUFACTURER code as defined in the General Configuration Table (Table 0) of ANSI C12.19-1997 (Version 1.0).
MByteString MProtocolC1222::GetIncomingApdu | ( | ) | const |
The whole incoming application data unit.
After any successfully accepted APDU, this property will hold the whole byte representation of the arrived APDU, convenient for custom logging, data forwarding, or any other purpose. If there was no successful APDU received, this property will return an empty byte string.
When the property is assigned a byte string, the given representation of APDU will be parsed up to the ACSE that comprises the header of the APDU, everything except the EPSEM of the packet. This should be sufficient to use the calling AP title to fetch the key from the storage, and assign it to the protocol. After that, ProcessIncomingEPSEM can be called in order to decrypt the packet and initialize GetIncomingEpsem property.
|
inline |
The Called Application Title of the incoming EPSEM packet.
If no incoming packet has been received, this property returns an empty string. This property is most useful to clients who need to emulate a C12.22 device. It is not particularly useful to clients communicating to a real C12.22 device.
|
inline |
The Incoming Application Entity Qualifier is to supply additional information about the message.
In MeteringSDK 6.1.0.3832, this property was renamed from AeQualifier to CallingAeQualifier
This is an optional ACSE element, bit mask. When it is -1, the AE Qualifier was not included in the incoming message, or there was no incoming message. If the outgoing message had a calling AE qualifier but the corresponding incoming one does not, according to standard this means that incoming AE qualifier is not supported by the callee.
|
inline |
The value of invocation ID received from the peer in the most recent APDU.
If there was no APDU exchanged, the property will return zero. MCOM will unconditionally throw an exception if the incoming APDU has no invocation ID, and zero is a valid invocation id. Therefore, the presence of the actual value can be detected by the fact that the communication succeeded at the ACSE level.
|
inline |
The Calling Application Title of the incoming EPSEM packet.
If no incoming packet has been received, this property returns an empty string. This property is most useful to clients who need to emulate a C12.22 device. It is not particularly useful to clients communicating to a real C12.22 device.
|
inline |
Get the EPSEM EdClass that was used in the last EPSEM response.
If this is an empty string, EdClass was not included into the last response, or there was no EPSEM issued.
The EdClass string retrieved from the incoming packet. If there was no incoming packet, then it is an empty string. For more information about this property, refer to the ANSI Standard C12.22-200x documentation.
MByteString MProtocolC1222::GetIncomingEpsem | ( | ) | const |
The whole incoming application EPSEM.
This property is an empty string until ProcessIncomingEPSEM is called after receiving or initializing the incoming APDU. After a successful ProcessIncomingEPSEM call, this property is a byte string that represents a sequence of PSEM data.
|
inline |
The value of initialization vector, as received from the peer in the most recent APDU.
If IncomingSecurityMode is nonzero, and initialization vector ACSE was not sent by the peer, or if IncomingInitializationVector is zero, MCOM is going to unconditionally throw an error. Therefore, zero value of this property will mean the incoming packet's security is clear text, and the initialization vector was not obtained.
|
inline |
The Response Control of the incoming EPSEM packet, as defined by the ANSI Standard C12.22 documentation.
|
inline |
The value of security key ID, as received from the peer in the most recent APDU.
The property behaves like GetIncomingInitializationVector, except that zero is a valid incoming value. To know whether or not GetIncomingSecurityKeyId was obtained from peer, one will need to check GetIncomingInitializationVector for being nonzero.
|
inline |
Security Mode of the incoming EPSEM packet.
If no incoming packet has been received, this property returns a value of zero. This property is most useful to clients who need to emulate a C12.22 device. It is not particularly useful to clients communicating to a real C12.22 device.
|
inline |
Initialization vector, as used in the outgoing APDU. Initialization vector will return zero if MCOM has not sent the ACSE initialization vector parameter to the peer. At the event of secure message exchange, MCOM will initialize the value of the property according to C12.22 standard, unless it was changed programmatically by the client application through assigning the value to InitializationVector. After the value is assigned by the application, even if it is zero, MProtocolC1222 will use it exactly once in the following APDU - if security settings require initialization vector ACSE to be sent. After that, if InitializationVector is not assigned by client again, MCOM will be free to fall into its way of changing initialization vector.
|
inline |
Whether the end of the session shall be completed with Terminate (or Logoff) C12 service.
When true, the session is ended with C12.22 Terminate service. When false, the session is ended with C12.22 Logoff service. This property is applied only when GetSessionless = False.
For more information regarding the end session behavior, refer to the ANSI Standard C12.22-200x documentation.
|
inline |
Maximum size of the outgoing application protocol data unit (APDU).
Prior to the introduction of GetMaximumApduSizeIncoming, this property set the maximum size of both the incoming and outgoing APDU. If GetMaximumApduSizeIncoming is zero, this property still sets the maximum limit for both the incoming and outgoing APDU size.
For more information about maximum APDU size, refer to the ANSI Standard C12.22-200x documentation.
|
inline |
Maximum size of the incoming application protocol data unit (APDU).
The property was introduced in MeteringSDK 6.1 with compatibility in mind. When this property is zero, GetMaximumApduSize sets both the incoming and outgoing maximum APDU size, as it did before the introduction of this property. When this property is not zero, it sets the maximum size of the incoming APDU.
For more information about maximum APDU size, refer to the ANSI Standard C12.22-200x documentation.
|
inline |
Get the outgoing negotiated maximum size of the APDU.
This value in the beginning of the session is equal to GetMaximumApduSize. Later on the value of negotiated maximum APDU size can change if RQTL C12 NOK response is received.
|
inline |
Get the incoming negotiated maximum size of the APDU.
This value in the beginning of the session is equal to the maximum incoming APDU size, whether it is determined by a dedicated property GetMaximumApduSizeIncoming, or, if this is zero, by GetMaximumApduSize. Later on the value of negotiated maximum APDU size can change if RSTL C12 Nok response is received.
unsigned MProtocolC1222::GetNegotiatedSessionIdleTimeout | ( | ) | const |
Tells whether or not the GetNegotiatedSessionIdleTimeout property is available.
For more information regarding the session idle timeout properties, refer to the ANSI Standard C12.22-200x documentation.
|
inline |
Tells whether or not the GetNegotiatedSessionIdleTimeout property is available.
For more information regarding the session idle timeout properties, refer to the ANSI Standard C12.22-200x documentation.
|
inline |
When OneServicePerApdu is true the behavior differs.
Whether the protocol should transmit services one at a time (only one service per APDU).
When OneServicePerApdu is false the protocol will attempt to place as many C12 services as possible into the packet.on whether the protocol is sessionless:
MByteString MProtocolC1222::GetOutgoingApdu | ( | ) | const |
Get the whole outgoing application data unit.
After any successfully sent APDU, this property will have its whole byte representation, convenient for monitoring or debugging. If there was no successful APDU sent this property will return an empty byte string.
|
inline |
Whether the protocol EPSEM request is going to be one-way. One way requests cannot pass information back from devices, therefore table reads and function executions with response cannot be handled.
Response control of the outgoing EPSEM packet, as defined by the ANSI Standard C12.22 documentation. When ResponseControl <> 0, GetSessionless = False is not supported and an error is thrown. When ResponseControl <> 0, an error is thrown for any request that requires application- level information to be returned from the peer. Examples are: full/partial table read, and executing a function that has RESPONSE data.
|
inline |
The number of seconds to wait after sending a packet to get a response.
Should this timeout be exceeded, a timeout error is raised.
MStdString MProtocolC1222::GetSecurityKey | ( | ) | const |
The security key used for encryption and authentication.
The security key is a hex string of exactly 32 characters (representing 16 bytes). The property is only used when GetSecurityMode <> 0. For more information regarding the security key, refer to the ANSI Standard C12.22-200x documentation.
|
inline |
Security key ID identifies the key used to encrypt and decrypt the information.
The SecurityKeyID is matched with an entry in the KEY_ENTRIES array located in the Security Table (Table 45, KEY_TBL or Table 46, EXTENDED_KEY_TBL) of the target C12.22 Node. This element is optional, and when not provided in a sessionless message, the SecurityKeyId shall be 0, otherwise the previous SecurityKeyId of the session shall be used.
The SecurityKeyId may be different in each C12.22 Message transmitted. The SecurityKeyId used in a request may be different from the SecurityKeyId used in the response message. For more information regarding the security key ID, refer to the ANSI Standard C12.22-200x documentation.
|
inline |
Security key list for the protocol.
The security key lists overwrite the security key property, when given. These are used to try multiple keys through a single connection, which is, no doubt, a too nice security invention.
|
inline |
Protocol security mode.
Determines whether or not the request and response messages are encrypted. For more information regarding the security mode, refer to the ANSI Standard C12.22 documentation.
|
inline |
Session idle timeout, value to use in C12 Logon service.
The maximum number of seconds a session may be idle on the C12.22 Server side before the C12.22 Server may terminate the session. There is also a special value, zero, that means the session will never time out.
|
inline |
Whether the protocol mode is sessionless.
When Sessionless = true, communications are done in the sessionless mode, and start and end session requires are ignored. Sessionless mode is more efficient for connections with high latency, as it puts many services into one request. There is no guarantee that the whole queue will be done in one trip in sessionless mode.
For more information regarding the sessionless behavior, refer to the ANSI Standard C12.22-200x documentation.
|
virtual |
Perform ANSI C12 Logon request, both request and response.
The particular implementation of this abstract service is typically called from StartSession, but it can also be called directly by the user for testing purpose.
Reimplemented from MProtocolC12.
void MProtocolC1222::ProcessIncomingEPSEM | ( | ) |
Initialize protocol machine for processing the incoming EPSEM.
Do all necessary checking such as security mode check, and reset EPSEM buffer for parsing.
|
virtual |
Read raw incoming APDU.
Serial variant of the protocol processes the necessary link layer wrapping.
void MProtocolC1222::ReceiveLogon | ( | ) |
Process PSEM with C12 Logon service.
void MProtocolC1222::ReceiveSecurity | ( | ) |
Process PSEM with C12 Security service.
char MProtocolC1222::ReceiveServiceCodeIgnoreLength | ( | ) |
Receive and ignore service length, then service code or status.
This call should be made within ReceiveStart/ReceiveEnd pair of calls. Length parameter, not made available to the caller, is used for initialization of application layer buffer.
unsigned MProtocolC1222::ReceiveServiceLength | ( | ) |
Receive service length.
This call should be made within ReceiveStart/ReceiveEnd pair of calls.
MByteString MProtocolC1222::ReceiveTableRead | ( | MCOMNumberConstRef | number | ) |
Process PSEM with C12 table read service.
MByteString MProtocolC1222::ReceiveTableReadPartial | ( | MCOMNumberConstRef | number, |
int | offset, | ||
int | length | ||
) |
Process PSEM with C12 partial table read service.
void MProtocolC1222::ReceiveTableWrite | ( | MCOMNumberConstRef | number, |
const MByteString & | request | ||
) |
Process PSEM with C12 table write service.
void MProtocolC1222::ReceiveTableWritePartial | ( | MCOMNumberConstRef | number, |
const MByteString & | request, | ||
int | offset | ||
) |
Process PSEM with C12 partial table write service.
bool MProtocolC1222::SendEndReceiveStart | ( | ) |
Combines SendEnd and ReceiveStart.
void MProtocolC1222::SendLogon | ( | ) |
Process PSEM with C12 Logon service.
void MProtocolC1222::SendSecurity | ( | ) |
Process PSEM with C12 Security service.
void MProtocolC1222::SendService | ( | char | command | ) |
Send command-only service.
This call should be made within SendStart/SendEnd pair of calls.
command | C12 command or status code that has to be sent. |
void MProtocolC1222::SendServiceWithData | ( | char | command, |
const MByteString & | data | ||
) |
Send service with command and data.
This call should be made within SendStart/SendEnd pair of calls.
command | C12 command or status code that has to be sent. |
data | Data associated with the command. |
void MProtocolC1222::SendTableRead | ( | MCOMNumberConstRef | number | ) |
Process PSEM with C12 table read service.
void MProtocolC1222::SendTableReadPartial | ( | MCOMNumberConstRef | number, |
int | offset, | ||
int | length | ||
) |
Process PSEM with C12 partial table read service.
void MProtocolC1222::SendTableWrite | ( | MCOMNumberConstRef | number, |
const MByteString & | request | ||
) |
Process PSEM with C12 table write service.
void MProtocolC1222::SendTableWritePartial | ( | MCOMNumberConstRef | number, |
const MByteString & | request, | ||
int | offset | ||
) |
Process PSEM with C12 partial table write service.
void MProtocolC1222::ServerEnd | ( | ) |
End the processing of incoming request by making and sending back the response.
This call does SendEnd inside.
void MProtocolC1222::ServerReset | ( | ) |
Reset server so that it is ready to send back the outgoing APDU.
Outgoing EPSEM is cleared, ready to be filled. AP titles are initialized: calling AP Title will be set to be equal to the incoming called AP title, and called AP title will be set to the incoming calling AP title.
void MProtocolC1222::ServerStart | ( | ) |
Start processing of the incoming APDU.
Accept the whole incoming APDU and parse all its ACSE headers. This call can be used by software for implementing C12.22 server.
Initialize GetIncomingApdu with the whole contents of what is read.
All other Incoming properties are initialized, and EPSEM part is loaded into the protocol, available for processing.
void MProtocolC1222::SetApplicationContext | ( | const MStdString & | ) |
Application context is the ISO8825 Universal Identifier of the common context for all Relative IOS8825 Universal Identifiers used by the protocol.
When ApplicationContext is "", it is not included in the message. Both the C12.22 Client and C12.22 Communication Module assume that the ApplicationContext is "2.16.124.113620.1.22", which is the identifier reserved to C12.22.
The following text is taken, nearly verbatim, from the ANSI C12.22 standard:
The called application title uniquely identifies the target of an ACSE (Association Control Service Element, ISO8650-1-1995) message. This uniqueness is guaranteed by the use of an Absolute or Relative Universal Identifier. Relative Universal Identifiers are derived from the ANSI C12.22 ApTitle branch (<application-context-oid>.0).
The value of <application-context-oid> is set by ApplicationContext. The value of the called application title is set by GetCalledApTitle. Here is an example of how to use Relative Universal Identifiers:
When using Relative Universal Identifiers, the CalledApTitle should start with a period. However, no error is thrown if it doesn't which allows firmware developers and testers to try invalid combinations.
Here is an example of how to use Absolute Universal Identifiers:
When MeteringSDK assembles the message, the ApplicationContext property (if not "") is sent in the Application Context Element (0xA1), and the GetCalledApTitle is sent in the Called AP Title Element (0xA2).
For more information, refer to the ANSI Standard C12.22-200x documentation, or the ISO8825-1-1997 documentation.
void MProtocolC1222::SetCalledApTitle | ( | const MStdString & | calledApTitle | ) |
Called Ap Title is the ISO8825 Universal Identifier of the called application. If the string is empty, no Application Title will be associated with the called application and it will not be sent to the device.
The following is taken, nearly verbatim from the ANSI C12.22 standard:
The called application title uniquely identifies the target of an ACSE (Association Control Service Element, ISO8650-1-1995) message. This uniqueness is guaranteed by the use of an Absolute or Relative Universal Identifier. Relative Universal Identifiers are derived from the ANSI C12.22 ApTitle branch (application-context-oid.0).
The value of application-context-oid is set by GetApplicationContext. Here is an example of how to use Absolute Universal Identifiers:
Here is an example of how to use Relative Universal Identifiers:
When using Relative Universal Identifiers, the CalledApTitle should start with a period. However, no error is thrown if it doesn't which allows firmware developers and testers to try invalid combinations.
When MeteringSDK assembles the message, the GetApplicationContext property (if not "") is sent in the Application Context Element (0xA1), and the CalledApTitle is sent in the Called AP Title Element (0xA2).
The effect of setting this property will take place next time the session is started, or the logon procedure is performed.
For more information, refer to the ANSI Standard C12.22-200x documentation, or the ISO8825-1-1997 documentation.
|
inline |
Calling Application Entity Qualifier is to supply additional information about the message.
In MeteringSDK 6.1.0.3832, this property was renamed from IncomingAeQualifier to IncomingCallingAeQualifier
This is an optional ACSE element, bit mask. When it is -1, the AE Qualifier was not included in the incoming message, or there was no incoming message. The property stands for the outgoing message, while there is also a read-only property IncomingCallingAeQualifier. When the device does not support Calling AE Qualifier, the incoming property will not be present (will return -1).
The ANSI C12.22 standard defines the following bits for the AE Qualifier:
|
inline |
The value of calling invocation ID as used in the outgoing APDU.
Accessing this property has debugging and security purpose only. MCOM will always send the invocation ID in the outgoing packet, behaving as the standard requires, but if this property is assigned by the application, the newly assigned value will be used exactly once in the next APDU, after which MCOM will be using its default behavior again.
void MProtocolC1222::SetCallingApTitle | ( | const MStdString & | ) |
Calling Ap Title is the ISO8825 Universal Identifier of the calling application.
If the string is empty, no Application Title will be associated with the calling application. The calling application title uniquely identifies the initiator of an ASCE (Association Control Service Element, ISO8650-1-1995) message. This uniqueness is guaranteed by the use of a absolute or relative Universal Identifier. Relative Universal Identifiers are derived from the ANSI C12.22 ApTitle branch (1.2.840.10066.3).
The effect of setting this property will take place next time the session is started, or the logon procedure is performed.
void MProtocolC1222::SetEdClass | ( | const MStdString & | edClass | ) |
The EdClass string to place in the outgoing packet.
If this is an empty string, EdClass will not be included into the EPSEM outgoing request. The EdClass is encoded in the General Configuration Table (Table 0) of ANSI C12.19 Version 2.0 or the MANUFACTURER code as defined in the General Configuration Table (Table 0) of ANSI C12.19-1997 (Version 1.0).
void MProtocolC1222::SetIncomingApdu | ( | const MByteString & | ) |
The whole incoming application data unit.
After any successfully accepted APDU, this property will hold the whole byte representation of the arrived APDU, convenient for custom logging, data forwarding, or any other purpose. If there was no successful APDU received, this property will return an empty byte string.
When the property is assigned a byte string, the given representation of APDU will be parsed up to the ACSE that comprises the header of the APDU, everything except the EPSEM of the packet. This should be sufficient to use the calling AP title to fetch the key from the storage, and assign it to the protocol. After that, ProcessIncomingEPSEM can be called in order to decrypt the packet and initialize GetIncomingEpsem property.
|
inline |
Initialization vector, as used in the outgoing APDU. Initialization vector will return zero if MCOM has not sent the ACSE initialization vector parameter to the peer. At the event of secure message exchange, MCOM will initialize the value of the property according to C12.22 standard, unless it was changed programmatically by the client application through assigning the value to InitializationVector. After the value is assigned by the application, even if it is zero, MProtocolC1222 will use it exactly once in the following APDU - if security settings require initialization vector ACSE to be sent. After that, if InitializationVector is not assigned by client again, MCOM will be free to fall into its way of changing initialization vector.
|
virtual |
Whether the start session includes the security service or the authenticate service.
When it is set to False, neither the security nor the authenticate service is sent, allowing data that is not password protected to be accessed without the password.
Refer to the ANSI protocol standards for more information on the start session, security, and authenticate services.
Reimplemented from MProtocolC12.
|
inline |
Whether the end of the session shall be completed with Terminate (or Logoff) C12 service.
When true, the session is ended with C12.22 Terminate service. When false, the session is ended with C12.22 Logoff service. This property is applied only when GetSessionless = False.
For more information regarding the end session behavior, refer to the ANSI Standard C12.22-200x documentation.
void MProtocolC1222::SetMaximumApduSize | ( | unsigned | size | ) |
Maximum size of the outgoing application protocol data unit (APDU).
Prior to the introduction of GetMaximumApduSizeIncoming, this property set the maximum size of both the incoming and outgoing APDU. If GetMaximumApduSizeIncoming is zero, this property still sets the maximum limit for both the incoming and outgoing APDU size.
For more information about maximum APDU size, refer to the ANSI Standard C12.22-200x documentation.
void MProtocolC1222::SetMaximumApduSizeIncoming | ( | unsigned | size | ) |
Maximum size of the incoming application protocol data unit (APDU).
The property was introduced in MeteringSDK 6.1 with compatibility in mind. When this property is zero, GetMaximumApduSize sets both the incoming and outgoing maximum APDU size, as it did before the introduction of this property. When this property is not zero, it sets the maximum size of the incoming APDU.
For more information about maximum APDU size, refer to the ANSI Standard C12.22-200x documentation.
|
inline |
When OneServicePerApdu is true the behavior differs.
Whether the protocol should transmit services one at a time (only one service per APDU).
When OneServicePerApdu is false the protocol will attempt to place as many C12 services as possible into the packet.on whether the protocol is sessionless:
void MProtocolC1222::SetResponseControl | ( | ResponseControlEnum | c | ) |
Whether the protocol EPSEM request is going to be one-way. One way requests cannot pass information back from devices, therefore table reads and function executions with response cannot be handled.
Response control of the outgoing EPSEM packet, as defined by the ANSI Standard C12.22 documentation. When ResponseControl <> 0, GetSessionless = False is not supported and an error is thrown. When ResponseControl <> 0, an error is thrown for any request that requires application- level information to be returned from the peer. Examples are: full/partial table read, and executing a function that has RESPONSE data.
void MProtocolC1222::SetResponseTimeout | ( | unsigned | timeout | ) |
The number of seconds to wait after sending a packet to get a response.
Should this timeout be exceeded, a timeout error is raised.
void MProtocolC1222::SetSecurityKey | ( | const MStdString & | ) |
The security key used for encryption and authentication.
The security key is a hex string of exactly 32 characters (representing 16 bytes). The property is only used when GetSecurityMode <> 0. For more information regarding the security key, refer to the ANSI Standard C12.22-200x documentation.
void MProtocolC1222::SetSecurityKeyId | ( | int | ) |
Security key ID identifies the key used to encrypt and decrypt the information.
The SecurityKeyID is matched with an entry in the KEY_ENTRIES array located in the Security Table (Table 45, KEY_TBL or Table 46, EXTENDED_KEY_TBL) of the target C12.22 Node. This element is optional, and when not provided in a sessionless message, the SecurityKeyId shall be 0, otherwise the previous SecurityKeyId of the session shall be used.
The SecurityKeyId may be different in each C12.22 Message transmitted. The SecurityKeyId used in a request may be different from the SecurityKeyId used in the response message. For more information regarding the security key ID, refer to the ANSI Standard C12.22-200x documentation.
void MProtocolC1222::SetSecurityKeyList | ( | const MByteStringVector & | ) |
Security key list for the protocol.
The security key lists overwrite the security key property, when given. These are used to try multiple keys through a single connection, which is, no doubt, a too nice security invention.
void MProtocolC1222::SetSecurityMode | ( | SecurityModeEnum | mode | ) |
Protocol security mode.
Determines whether or not the request and response messages are encrypted. For more information regarding the security mode, refer to the ANSI Standard C12.22 documentation.
void MProtocolC1222::SetSessionIdleTimeout | ( | unsigned | timeout | ) |
Session idle timeout, value to use in C12 Logon service.
The maximum number of seconds a session may be idle on the C12.22 Server side before the C12.22 Server may terminate the session. There is also a special value, zero, that means the session will never time out.
void MProtocolC1222::SetSessionless | ( | bool | ) |
Whether the protocol mode is sessionless.
When Sessionless = true, communications are done in the sessionless mode, and start and end session requires are ignored. Sessionless mode is more efficient for connections with high latency, as it puts many services into one request. There is no guarantee that the whole queue will be done in one trip in sessionless mode.
For more information regarding the sessionless behavior, refer to the ANSI Standard C12.22-200x documentation.
void MProtocolC1222::WriteApdu | ( | const MByteString & | buffer | ) |
Write raw incoming APDU.
Serial variant of the protocol processes the necessary link layer wrapping.