OS-IoT
onem2m.hxx
Go to the documentation of this file.
1 /*
2  * SPDX-License-Identifier: BSD-3-Clause
3  * The above license addresses copyright obligations. Please refer to Section 10.4 of the
4  * ATIS Operating Procedures for information about patent licensing obligations under
5  * ATIS' Intellectual Property Rights Policy.
6  */
7 
8 
210 #ifndef ONEM2M_HXX_
211 #define ONEM2M_HXX_
212 
213 
214 
215 #include <string>
216 #include <vector>
217 #include <functional>
218 
219 #include "cdtHeads.hxx"
220 
221 /* Notes on adding new resource types
222  *
223  * To add a new resource type to the library consider the following steps:
224  * - Include all needed XSD in cdt/xsd_vx_y_z_ed. Note that this may include selecting which part(s) of the XSD files are needed
225  * - If needed, add a new root element to the end of the CDT-commonTypes file
226  * - Update "cdt/build_command" to add any new CDT files to the list to be processed
227  * - Update the data structures at the start of "cdt/cxxhelper/cxxhelper.py"
228  * - Run the "build_command" to build CodeSynthesis output and other automatically generated files
229  * - Add any enumerated values needed from CDT-enumeration types to this file
230  */
231 
237 namespace onem2m
238 {
239  // Magic values defined in CDT-enumerationTypes.xsd
240 
246  resourceTypeAccessControlPolicy,
247  resourceTypeAE,
248  resourceTypeContainer,
249  resourceTypeContentInstance,
250  resourceTypeCSEBase,
251  resourceTypePollingChannel = 15,
252  resourceTypeSubscription = 23,
253  resourceTypeFlexContainerResource = 28,
256  };
257 
269  };
270 
271 
281 
282  };
283 
284 
292  };
293 
294 
299  updateOfResource = 1,
300  deleteOfResource,
301  createOfDirectChildResource,
302  deleteOfDirectChildResource,
303  retrieveOfContainerResourceWithNoChildResource
304  };
305 
306 
313  };
314 
322  };
323 
329  rcACCEPTED = 1000,
330  rcOK = 2000,
331  rcCREATED = 2001,
332  rcDELETED = 2002,
333  rcUPDATED = 2004,
334  rcBAD_REQUEST = 4000,
335  rcNOT_FOUND = 4004,
336  rcOPERATION_NOT_ALLOWED = 4005,
337  rcREQUEST_TIMEOUT = 4008,
338  rcSUBSCRIPTION_CREATOR_HAS_NO_PRIVILEGE = 4101,
339  rcCONTENTS_UNACCEPTABLE = 4102,
340  rcORIGINATOR_HAS_NO_PRIVILEGE = 4103,
341  rcGROUP_REQUEST_IDENTIFIER_EXISTS = 4104,
342  rcCONFLICT = 4105,
343  rcORIGINATOR_HAS_NOT_REGISTERED = 4106,
344  rcSECURITY_ASSOCIATION_REQUIRED = 4107,
345  rcINVALID_CHILD_RESOURCE_TYPE = 4108,
346  rcNO_MEMBERS = 4109,
347  rcGROUP_MEMBER_TYPE_INCONSISTENT = 4110,
348  rcESPRIM_UNSUPPORTED_OPTION = 4111,
349  rcESPRIM_UNKNOWN_KEY_ID = 4112,
350  rcGESPRIM_UNKNOWN_ORIG_RAND_ID = 4113,
351  rcESPRIM_UNKNOWN_RECV_RAND_ID = 4114,
352  rcGESPRIM_BAD_MAC = 4115,
353  rcESPRIM_IMPERSONATION_ERROR = 4116,
354  rcINTERNAL_SERVER_ERROR = 5000,
355  rcNOT_IMPLEMENTED = 5001,
356  rcTARGET_NOT_REACHABLE = 5103,
357  rcRECEIVER_HAS_NO_PRIVILEGE = 5105,
358  rcALREADY_EXISTS = 5106,
359  rcTARGET_NOT_SUBSCRIBABLE = 5203,
360  rcSUBSCRIPTION_VERIFICATION_INITIATION_FAILED = 5204,
361  rcSUBSCRIPTION_HOST_HAS_NO_PRIVILEGE = 5205,
362  rcNON_BLOCKING_REQUEST_NOT_SUPPORTED = 5206,
363  rcNOT_ACCEPTABLE = 5207,
364  rcDISCOVERY_DENIED_BY_IPE = 5208,
365  rcGROUP_MEMBERS_NOT_RESPONDED = 5209,
366  rcESPRIM_DECRYPTION_ERROR = 5210,
367  rcESPRIM_ENCRYPTION_ERROR1 = 5211,
368  rcESPRIM_ENCRYPTION_ERROR2 = 5212,
369  rcSPARQL_UPDATE_ERROR = 6003,
370  rcEXTERNAL_OBJECT_NOT_FOUND = 6005,
371  rcMAX_NUMBER_OF_MEMBER_EXCEEDED = 6010,
372  rcMGMT_SESSION_CANNOT_BE_ESTABLISHED = 6020,
373  rcMGMT_SESSION_ESTABLISHMENT_TIMEOUT = 6021,
374  rcINVALID_CMDTYPE = 6022,
375  rcINVALID_ARGUMENTS = 6023,
376  rcINSUFFICIENT_ARGUMENTS = 6024,
377  rcMGMT_CONVERSION_ERROR = 6025,
378  rcMGMT_CANCELLATION_FAILED = 6026,
379  rcALREADY_COMPLETE = 6028,
380  rcMGMT_COMMAND_NOT_CANCELLABLE = 6029
381  };
382 
388  enum onem2mResult: long {
389  onem2mHttpCONTINUE = 100,
390  onem2mHttpSWITCHING_PROTOCOLS = 101,
391  onem2mHttpOK = 200,
392  onem2mHttpCREATED = 201,
393  onem2mHttpACCEPTED = 202,
394  onem2mHttpNON_AUTHORITATIVE_INFORMATION = 203,
395  onem2mHttpNO_CONTENT = 204,
396  onem2mHttpRESET_CONTENT = 205,
397  onem2mHttpPARTIAL_CONTENT = 206,
398  onem2mHttpMULTIPLE_CHOICES = 300,
399  onem2mHttpMOVED_PERMANENTLY = 301,
400  onem2mHttpFOUND = 302,
401  onem2mHttpSEE_OTHER = 303,
402  onem2mHttpNOT_MODIFIED = 304,
403  onem2mHttpUSE_PROXY = 305,
404  onem2mHttpTEMPORARY_REDIRECT = 307,
405  onem2mHttpBAD_REQUEST = 400,
406  onem2mHttpUNAUTHORIZED = 401,
407  onem2mHttpPAYMENT_REQUIRED = 402,
408  onem2mHttpFORBIDDEN = 403,
409  onem2mHttpNOT_FOUND = 404,
410  onem2mHttpMETHOD_NOT_ALLOWED = 405,
411  onem2mHttpNOT_ACCEPTABLE = 406,
412  onem2mHttpPROXY_AUTHENTICATION_REQUIRED = 407,
413  onem2mHttpREQUEST_TIMEOUT = 408,
414  onem2mHttpCONFLICT = 409,
415  onem2mHttpGONE = 410,
416  onem2mHttpLENGTH_REQUIRED = 411,
417  onem2mHttpPRECONDITION_FAILED = 412,
418  onem2mHttpREQUEST_ENTITY_TOO_LARGE = 413,
419  onem2mHttpREQUEST_URI_TOO_LONG = 414,
420  onem2mHttpUNSUPPORTED_MEDIA_TYPE = 415,
421  onem2mHttpREQUESTED_RANGE_NOT_SATISFIABLE = 416,
422  onem2mHttpEXPECTATION_FAILED = 417,
423  onem2mHttpUNPROCESSABLE_ENTITY = 422,
424  onem2mHttpTOO_MANY_REQUESTS = 429,
425  onem2mHttpINTERNAL_SERVER_ERROR = 500,
426  onem2mHttpNOT_IMPLEMENTED = 501,
427  onem2mHttpBAD_GATEWAY = 502,
428  onem2mHttpSERVICE_UNAVAILABLE = 503,
429  onem2mHttpGATEWAY_TIMEOUT = 504,
430  onem2mHttpHTTP_VERSION_NOT_SUPPORTED = 505,
431  onem2mCURLE_UNSUPPORTED_PROTOCOL = 1001,
432  onem2mCURLE_FAILED_INIT,
433  onem2mCURLE_URL_MALFORMAT,
434  onem2mCURLE_NOT_BUILT_IN,
435  onem2mCURLE_COULDNT_RESOLVE_PROXY,
436  onem2mCURLE_COULDNT_RESOLVE_HOST,
437  onem2mCURLE_COULDNT_CONNECT,
438  onem2mCURLE_WEIRD_SERVER_REPLY,
439  onem2mCURLE_REMOTE_ACCESS_DENIED,
440  onem2mCURLE_FTP_ACCEPT_FAILED,
441  onem2mCURLE_FTP_WEIRD_PASS_REPLY,
442  onem2mCURLE_FTP_ACCEPT_TIMEOUT,
443  onem2mCURLE_FTP_WEIRD_PASV_REPLY,
444  onem2mCURLE_FTP_WEIRD_227_FORMAT,
445  onem2mCURLE_FTP_CANT_GET_HOST,
446  onem2mCURLE_HTTP2,
447  onem2mCURLE_FTP_COULDNT_SET_TYPE,
448  onem2mCURLE_PARTIAL_FILE,
449  onem2mCURLE_FTP_COULDNT_RETR_FILE,
450  onem2mCURLE_OBSOLETE20,
451  onem2mCURLE_QUOTE_ERROR,
452  onem2mCURLE_HTTP_RETURNED_ERROR,
453  onem2mCURLE_WRITE_ERROR,
454  onem2mCURLE_OBSOLETE24,
455  onem2mCURLE_UPLOAD_FAILED,
456  onem2mCURLE_READ_ERROR,
457  onem2mCURLE_OUT_OF_MEMORY,
458  onem2mCURLE_OPERATION_TIMEDOUT,
459  onem2mCURLE_OBSOLETE29,
460  onem2mCURLE_FTP_PORT_FAILED,
461  onem2mCURLE_FTP_COULDNT_USE_REST,
462  onem2mCURLE_OBSOLETE32,
463  onem2mCURLE_RANGE_ERROR,
464  onem2mCURLE_HTTP_POST_ERROR,
465  onem2mCURLE_SSL_CONNECT_ERROR,
466  onem2mCURLE_BAD_DOWNLOAD_RESUME,
467  onem2mCURLE_FILE_COULDNT_READ_FILE,
468  onem2mCURLE_LDAP_CANNOT_BIND,
469  onem2mCURLE_LDAP_SEARCH_FAILED,
470  onem2mCURLE_OBSOLETE40,
471  onem2mCURLE_FUNCTION_NOT_FOUND,
472  onem2mCURLE_ABORTED_BY_CALLBACK,
473  onem2mCURLE_BAD_FUNCTION_ARGUMENT,
474  onem2mCURLE_OBSOLETE44,
475  onem2mCURLE_INTERFACE_FAILED,
476  onem2mCURLE_OBSOLETE46,
477  onem2mCURLE_TOO_MANY_REDIRECTS,
478  onem2mCURLE_UNKNOWN_OPTION,
479  onem2mCURLE_TELNET_OPTION_SYNTAX,
480  onem2mCURLE_OBSOLETE50,
481  onem2mCURLE_PEER_FAILED_VERIFICATION,
482  onem2mCURLE_GOT_NOTHING,
483  onem2mCURLE_SSL_ENGINE_NOTFOUND,
484  onem2mCURLE_SSL_ENGINE_SETFAILED,
485  onem2mCURLE_SEND_ERROR,
486  onem2mCURLE_RECV_ERROR,
487  onem2mCURLE_OBSOLETE57,
488  onem2mCURLE_SSL_CERTPROBLEM,
489  onem2mCURLE_SSL_CIPHER,
490  onem2mCURLE_SSL_CACERT,
491  onem2mCURLE_BAD_CONTENT_ENCODING,
492  onem2mCURLE_LDAP_INVALID_URL,
493  onem2mCURLE_FILESIZE_EXCEEDED,
494  onem2mCURLE_USE_SSL_FAILED,
495  onem2mCURLE_SEND_FAIL_REWIND,
496  onem2mCURLE_SSL_ENGINE_INITFAILED,
497  onem2mCURLE_LOGIN_DENIED,
498  onem2mCURLE_TFTP_NOTFOUND,
499  onem2mCURLE_TFTP_PERM,
500  onem2mCURLE_REMOTE_DISK_FULL,
501  onem2mCURLE_TFTP_ILLEGAL,
502  onem2mCURLE_TFTP_UNKNOWNID,
503  onem2mCURLE_REMOTE_FILE_EXISTS,
504  onem2mCURLE_TFTP_NOSUCHUSER,
505  onem2mCURLE_CONV_FAILED,
506  onem2mCURLE_CONV_REQD,
507  onem2mCURLE_SSL_CACERT_BADFILE,
508  onem2mCURLE_REMOTE_FILE_NOT_FOUND,
509  onem2mCURLE_SSH,
510  onem2mCURLE_SSL_SHUTDOWN_FAILED,
511  onem2mCURLE_AGAIN,
512  onem2mCURLE_SSL_CRL_BADFILE,
513  onem2mCURLE_SSL_ISSUER_ERROR,
514  onem2mCURLE_FTP_PRET_FAILED,
515  onem2mCURLE_RTSP_CSEQ_ERROR,
516  onem2mCURLE_RTSP_SESSION_ERROR,
517  onem2mCURLE_FTP_BAD_FILE_LIST,
518  onem2mCURLE_CHUNK_FAILED,
519  onem2mCURLE_NO_CONNECTION_AVAILABLE,
520  onem2mCURLE_SSL_PINNEDPUBKEYNOTMATCH,
521  onem2mCURLE_SSL_INVALIDCERTSTATUS,
522  onem2mCURLE_HTTP2_STREAM,
523  onem2mErrCantOpenServer = 2001,
524  onem2mErrServerAlreadyRunning
525  };
526 
530  typedef std::function<onem2mResponseStatusCode(std::string, std::string&, ::onem2m::notification*)> notificationCallbackFn;
531 
532  extern bool _debug;
533 
534  std::string _getHostName();
535 
536  void initialize ();
537 
538  void terminate ();
539 
540  void setProtocol( const onem2mProtocol );
541 
543 
544  void setTransport( const onem2mTransport );
545 
547 
548  void setCipherList( const std::string );
549 
551 
552  void setVerifyPeer( const bool );
553 
554  bool getVerifyPeer();
555 
556  void setVerifyHost( const bool );
557 
558  bool getVerifyHost();
559 
561 
563 
564  void setCaInfo( const std::string );
565 
567 
568  void setCaPath( const std::string );
569 
571 
572  void setSslCert( const std::string );
573 
575 
576  void setSslKey( const std::string );
577 
579 
580  void setKeyPasswd( const std::string );
581 
583 
584  void setPskIdentity( const std::string );
585 
587 
588  void setPskKey( const std::string );
589 
591 
592  void setHostName( const std::string name );
593 
594  void setFrom( const std::string newFrom );
595 
596  void setMaxAcceptSize( const size_t newMaxAcceptSize );
597 
598  size_t getMaxAcceptSize();
599 
601 
602  void setDebug( bool debugOut );
603 
604  std::unique_ptr< ::xml_schema::type > retrieveResource(const std::string& address, const std::string& requestId,
605  long& result,
606  ::xml_schema::integer& resObjType);
607 
608  std::unique_ptr< ::xml_schema::type > deleteResource(const std::string& address, const std::string& requestId,
609  long& result,
610  ::xml_schema::integer& resObjType);
611 
612  std::unique_ptr< ::xml_schema::type > createResource(const std::string& address, const std::string& requestId,
614  long& result,
615  ::xml_schema::integer& resObjType);
616 
617  std::unique_ptr< ::xml_schema::type > updateResource(const std::string& address, const std::string& requestId,
619  long& result,
620  ::xml_schema::integer& resObjType);
621 
622  std::unique_ptr< ::xml_schema::type > updateResource(const std::string& address, const std::string& requestId,
624  long& result,
625  ::xml_schema::integer& resObjType);
626 
627  std::unique_ptr< ::xml_schema::type > _send(const std::string& address, const std::string& requestId,
630  long& result, ::xml_schema::integer& resObjType);
631 
632  bool getHttpServerRunning();
633 
634  long startHttpServer( const std::vector<std::string>& addressRegex, long port, notificationCallbackFn callback );
635 
636  void stopHttpServer( );
637 
638 }
639 
640 
641 
642 
643 #endif
onem2mMotificationContentType
Definition: onem2m.hxx:288
std::string getKeyPasswd()
Definition: onem2m.cxx:501
Notify of a resource change.
Definition: onem2m.hxx:280
Resource Id.
Definition: onem2m.hxx:291
void setMaxAcceptSize(const size_t newMaxAcceptSize)
Definition: onem2m.cxx:284
Discover access control.
Definition: onem2m.hxx:267
onem2mProtocol getProtocol()
Definition: onem2m.cxx:208
Retrieve access control.
Definition: onem2m.hxx:263
std::string getSslKey()
Definition: onem2m.cxx:479
Unknown resource type or no resource type included.
Definition: onem2m.hxx:245
size_t getMaxAcceptSize()
Definition: onem2m.cxx:293
void setSslCert(const std::string)
Definition: onem2m.cxx:448
onem2mTransport getTransport()
Definition: onem2m.cxx:231
std::unique_ptr< ::xml_schema::type > updateResource(const std::string &address, const std::string &requestId, const ::xml_schema::type *resource, long &result,::xml_schema::integer &resObjType)
Definition: onem2m.cxx:626
std::string getSslCert()
Definition: onem2m.cxx:457
All atributes.
Definition: onem2m.hxx:289
void stopHttpServer()
Definition: onem2m.cxx:939
HTTP transport.
Definition: onem2m.hxx:319
Notify access control.
Definition: onem2m.hxx:266
void setHostName(const std::string name)
Definition: onem2m.cxx:243
HTTPS transport with PSK security.
Definition: onem2m.hxx:321
HTTPS transport with certificate-based security.
Definition: onem2m.hxx:320
::xsd::cxx::tree::type type
C++ type corresponding to the anyType XML Schema built-in type.
Definition: CDT-accessControlPolicy.hxx:121
void setPskKey(const std::string)
Definition: onem2m.cxx:534
XML protocol.
Definition: onem2m.hxx:311
std::string getPskIdentity()
Definition: onem2m.cxx:521
Class corresponding to the resource schema type.
Definition: CDT-commonTypes.hxx:6675
onem2mNotificationEventType
Definition: onem2m.hxx:298
void setPskIdentity(const std::string)
Definition: onem2m.cxx:512
onem2mResult
Definition: onem2m.hxx:388
onem2mTransport
Definition: onem2m.hxx:318
::xsd::cxx::tree::name< char, token > name
C++ type corresponding to the Name XML Schema built-in type.
Definition: CDT-accessControlPolicy.hxx:290
Modified attributes.
Definition: onem2m.hxx:290
void setDebug(bool debugOut)
Definition: onem2m.cxx:273
Delete access control.
Definition: onem2m.hxx:265
Delete a resource.
Definition: onem2m.hxx:279
Public interface for functions and classes in the OS-IoT library.
Definition: onem2m.hxx:237
long startHttpServer(const std::vector< std::string > &addressRegex, long port, notificationCallbackFn callback)
Definition: onem2m.cxx:891
std::string getSubjectAltNameAllowed()
Definition: onem2m.cxx:346
std::string getCaPath()
Definition: onem2m.cxx:434
void setFrom(const std::string newFrom)
Definition: onem2m.cxx:255
onem2mResponseStatusCode
Definition: onem2m.hxx:328
JSON protocol.
Definition: onem2m.hxx:312
std::function< onem2mResponseStatusCode(std::string, std::string &,::onem2m::notification *)> notificationCallbackFn
Definition: onem2m.hxx:530
Retrieve a resource.
Definition: onem2m.hxx:277
std::string getPskKey()
Definition: onem2m.cxx:543
onem2mResourceType
Definition: onem2m.hxx:244
::xsd::cxx::tree::string< char, simple_type > string
C++ type corresponding to the string XML Schema built-in type.
Definition: CDT-accessControlPolicy.hxx:272
std::string getCaInfo()
Definition: onem2m.cxx:412
Enumeration class corresponding to the resourceType schema type.
Definition: CDT-enumerationTypes.hxx:665
void terminate()
Definition: onem2m.cxx:182
std::unique_ptr< ::xml_schema::type > createResource(const std::string &address, const std::string &requestId,::xml_schema::type &resource, long &result,::xml_schema::integer &resObjType)
Definition: onem2m.cxx:600
void setKeyPasswd(const std::string)
Definition: onem2m.cxx:492
std::unique_ptr< ::xml_schema::type > deleteResource(const std::string &address, const std::string &requestId, long &result,::xml_schema::integer &resObjType)
Definition: onem2m.cxx:578
Update a resource.
Definition: onem2m.hxx:278
Value used to designate a notification operation, which is not a resource.
Definition: onem2m.hxx:254
void setVerifyHost(const bool)
Definition: onem2m.cxx:381
Valuse used to designate a listOfURIs object, which is not a resource.
Definition: onem2m.hxx:255
void setCaInfo(const std::string)
Definition: onem2m.cxx:403
onem2mAccesControlOperation
Definition: onem2m.hxx:261
void setSubjectAltNameAllowed(const std::string)
Definition: onem2m.cxx:337
Enumeration class corresponding to the operation schema type.
Definition: CDT-enumerationTypes.hxx:1000
void setCaPath(const std::string)
Definition: onem2m.cxx:425
Create access control.
Definition: onem2m.hxx:262
Update access control.
Definition: onem2m.hxx:264
void setTransport(const onem2mTransport)
Definition: onem2m.cxx:222
long long integer
C++ type corresponding to the integer XML Schema built-in type.
Definition: CDT-accessControlPolicy.hxx:206
bool getHttpServerRunning()
Definition: onem2m.cxx:813
void setProtocol(const onem2mProtocol)
Definition: onem2m.cxx:201
std::string getFrom()
Definition: onem2m.cxx:264
bool getVerifyHost()
Definition: onem2m.cxx:390
void initialize()
Definition: onem2m.cxx:157
void setSslKey(const std::string)
Definition: onem2m.cxx:470
onem2mOperation
Definition: onem2m.hxx:275
std::string getCipherList()
Definition: onem2m.cxx:324
void setVerifyPeer(const bool)
Definition: onem2m.cxx:359
std::unique_ptr< ::xml_schema::type > retrieveResource(const std::string &address, const std::string &requestId, long &result,::xml_schema::integer &resObjType)
Definition: onem2m.cxx:561
bool getVerifyPeer()
Definition: onem2m.cxx:368
onem2mProtocol
Definition: onem2m.hxx:310
All access control.
Definition: onem2m.hxx:268
void setCipherList(const std::string)
Definition: onem2m.cxx:315
Create a resource.
Definition: onem2m.hxx:276