- Timestamp:
- Nov 6, 2013 8:05:11 AM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/branches/projects/pjsua2/pjsip/include/pjsua2/types.hpp
r4639 r4644 1 1 /* $Id$ */ 2 2 /* 3 * Copyright (C) 20 08-2012Teluu Inc. (http://www.teluu.com)3 * Copyright (C) 2013 Teluu Inc. (http://www.teluu.com) 4 4 * 5 5 * This program is free software; you can redistribute it and/or modify … … 21 21 22 22 /** 23 * @file pjsua2/ ua.hpp24 * @brief PJSUA2 Base Agent Operation23 * @file pjsua2/types.hpp 24 * @brief PJSUA2 Base Types 25 25 */ 26 26 #include <pjsua2/config.hpp> … … 207 207 }; 208 208 209 //////////////////////////////////////////////////////////////////////////////210 211 /**212 * Credential information. Credential contains information to authenticate213 * against a service.214 */215 struct AuthCredInfo216 {217 /**218 * The authentication scheme (e.g. "digest").219 */220 string scheme;221 222 /**223 * Realm on which this credential is to be used. Use "*" to make224 * a credential that can be used to authenticate against any challenges.225 */226 string realm;227 228 /**229 * Authentication user name.230 */231 string username;232 233 /**234 * Type of data that is contained in the "data" field. Use 0 if the data235 * contains plain text password.236 */237 int dataType;238 239 /**240 * The data, which can be a plain text password or a hashed digest.241 */242 string data;243 244 /*245 * Digest AKA credential information. Note that when AKA credential246 * is being used, the \a data field of this #pjsip_cred_info is247 * not used, but it still must be initialized to an empty string.248 * Please see \ref PJSIP_AUTH_AKA_API for more information.249 */250 251 /** Permanent subscriber key. */252 string akaK;253 254 /** Operator variant key. */255 string akaOp;256 257 /** Authentication Management Field */258 string akaAmf;259 260 /** Default constructor */261 AuthCredInfo();262 263 /** Construct a credential with the specified parameters */264 AuthCredInfo(const string &scheme,265 const string &realm,266 const string &user_name,267 const int data_type,268 const string data);269 270 };271 272 273 //////////////////////////////////////////////////////////////////////////////274 275 /**276 * TLS transport settings, to be specified in TransportConfig.277 */278 struct TlsConfig279 {280 /**281 * Certificate of Authority (CA) list file.282 */283 string CaListFile;284 285 /**286 * Public endpoint certificate file, which will be used as client-287 * side certificate for outgoing TLS connection, and server-side288 * certificate for incoming TLS connection.289 */290 string certFile;291 292 /**293 * Optional private key of the endpoint certificate to be used.294 */295 string privKeyFile;296 297 /**298 * Password to open private key.299 */300 string password;301 302 /**303 * TLS protocol method from #pjsip_ssl_method.304 *305 * Default is PJSIP_SSL_UNSPECIFIED_METHOD (0), which in turn will306 * use PJSIP_SSL_DEFAULT_METHOD, which default value is307 * PJSIP_TLSV1_METHOD.308 */309 pjsip_ssl_method method;310 311 /**312 * Ciphers and order preference. The Endpoint::utilSslGetAvailableCiphers()313 * can be used to check the available ciphers supported by backend.314 * If the array is empty, then default cipher list of the backend315 * will be used.316 */317 IntVector ciphers;318 319 /**320 * Specifies TLS transport behavior on the server TLS certificate321 * verification result:322 * - If \a verifyServer is disabled, TLS transport will just notify323 * the application via #pjsip_tp_state_callback with state324 * PJSIP_TP_STATE_CONNECTED regardless TLS verification result.325 * - If \a verifyServer is enabled, TLS transport will be shutdown326 * and application will be notified with state327 * PJSIP_TP_STATE_DISCONNECTED whenever there is any TLS verification328 * error, otherwise PJSIP_TP_STATE_CONNECTED will be notified.329 *330 * In any cases, application can inspect #pjsip_tls_state_info in the331 * callback to see the verification detail.332 *333 * Default value is false.334 */335 bool verifyServer;336 337 /**338 * Specifies TLS transport behavior on the client TLS certificate339 * verification result:340 * - If \a verifyClient is disabled, TLS transport will just notify341 * the application via #pjsip_tp_state_callback with state342 * PJSIP_TP_STATE_CONNECTED regardless TLS verification result.343 * - If \a verifyClient is enabled, TLS transport will be shutdown344 * and application will be notified with state345 * PJSIP_TP_STATE_DISCONNECTED whenever there is any TLS verification346 * error, otherwise PJSIP_TP_STATE_CONNECTED will be notified.347 *348 * In any cases, application can inspect #pjsip_tls_state_info in the349 * callback to see the verification detail.350 *351 * Default value is PJ_FALSE.352 */353 bool verifyClient;354 355 /**356 * When acting as server (incoming TLS connections), reject incoming357 * connection if client doesn't supply a TLS certificate.358 *359 * This setting corresponds to SSL_VERIFY_FAIL_IF_NO_PEER_CERT flag.360 * Default value is PJ_FALSE.361 */362 bool requireClientCert;363 364 /**365 * TLS negotiation timeout to be applied for both outgoing and incoming366 * connection, in milliseconds. If zero, the SSL negotiation doesn't367 * have a timeout.368 *369 * Default: zero370 */371 unsigned msecTimeout;372 373 /**374 * QoS traffic type to be set on this transport. When application wants375 * to apply QoS tagging to the transport, it's preferable to set this376 * field rather than \a qosParam fields since this is more portable.377 *378 * Default value is PJ_QOS_TYPE_BEST_EFFORT.379 */380 pj_qos_type qosType;381 382 /**383 * Set the low level QoS parameters to the transport. This is a lower384 * level operation than setting the \a qosType field and may not be385 * supported on all platforms.386 *387 * By default all settings in this structure are disabled.388 */389 pj_qos_params qosParams;390 391 /**392 * Specify if the transport should ignore any errors when setting the QoS393 * traffic type/parameters.394 *395 * Default: PJ_TRUE396 */397 bool qosIgnoreError;398 399 public:400 /** Default constructor initialises with default values */401 TlsConfig();402 403 /** Convert to pjsip */404 pjsip_tls_setting toPj() const;405 406 /** Convert from pjsip */407 void fromPj(const pjsip_tls_setting &prm);408 };409 410 411 /**412 * Parameters to create a transport instance.413 */414 struct TransportConfig415 {416 /**417 * UDP port number to bind locally. This setting MUST be specified418 * even when default port is desired. If the value is zero, the419 * transport will be bound to any available port, and application420 * can query the port by querying the transport info.421 */422 unsigned port;423 424 /**425 * Specify the port range for socket binding, relative to the start426 * port number specified in \a port. Note that this setting is only427 * applicable when the start port number is non zero.428 *429 * Default value is zero.430 */431 unsigned portRange;432 433 /**434 * Optional address to advertise as the address of this transport.435 * Application can specify any address or hostname for this field,436 * for example it can point to one of the interface address in the437 * system, or it can point to the public address of a NAT router438 * where port mappings have been configured for the application.439 *440 * Note: this option can be used for both UDP and TCP as well!441 */442 string publicAddress;443 444 /**445 * Optional address where the socket should be bound to. This option446 * SHOULD only be used to selectively bind the socket to particular447 * interface (instead of 0.0.0.0), and SHOULD NOT be used to set the448 * published address of a transport (the public_addr field should be449 * used for that purpose).450 *451 * Note that unlike public_addr field, the address (or hostname) here452 * MUST correspond to the actual interface address in the host, since453 * this address will be specified as bind() argument.454 */455 string boundAddress;456 457 /**458 * This specifies TLS settings for TLS transport. It is only be used459 * when this transport config is being used to create a SIP TLS460 * transport.461 */462 TlsConfig tlsConfig;463 464 /**465 * QoS traffic type to be set on this transport. When application wants466 * to apply QoS tagging to the transport, it's preferable to set this467 * field rather than \a qosParam fields since this is more portable.468 *469 * Default is QoS not set.470 */471 pj_qos_type qosType;472 473 /**474 * Set the low level QoS parameters to the transport. This is a lower475 * level operation than setting the \a qosType field and may not be476 * supported on all platforms.477 *478 * Default is QoS not set.479 */480 pj_qos_params qosParams;481 482 public:483 /** Default constructor initialises with default values */484 TransportConfig();485 486 /** Convert from pjsip */487 void fromPj(const pjsua_transport_config &prm);488 489 /** Convert to pjsip */490 pjsua_transport_config toPj() const;491 };492 493 /**494 * This structure describes transport information returned by495 * Endpoint::transportGetInfo() function.496 */497 struct TransportInfo498 {499 /** PJSUA transport identification. */500 TransportId id;501 502 /** Transport type. */503 pjsip_transport_type_e type;504 505 /** Transport type name. */506 string typeName;507 508 /** Transport string info/description. */509 string info;510 511 /** Transport flags (see #pjsip_transport_flags_e). */512 unsigned flags;513 514 /** Local/bound address. */515 SocketAddress localAddress;516 517 /** Published address (or transport address name). */518 SocketAddress localName;519 520 /** Current number of objects currently referencing this transport. */521 unsigned usageCount;522 523 /** Construct from pjsip */524 TransportInfo(const pjsua_transport_info &info);525 526 };527 528 //////////////////////////////////////////////////////////////////////////////529 530 /**531 * This structure describes an incoming SIP message. It corresponds to the532 * pjsip_rx_data structure in PJSIP library.533 */534 struct SipRxData535 {536 /**537 * A short info string describing the request, which normally contains538 * the request method and its CSeq.539 */540 string info;541 542 /**543 * The whole message data as a string, containing both the header section544 * and message body section.545 */546 string wholeMsg;547 548 /**549 * Source IP address of the message.550 */551 string srcIp;552 553 /**554 * Source port number of the message.555 */556 unsigned srcPort;557 558 /**559 * Construct from PJSIP's pjsip_rx_data560 */561 void fromPj(pjsip_rx_data &rdata);562 };563 564 565 //////////////////////////////////////////////////////////////////////////////566 567 /**568 * SIP media type containing type and subtype. For example, for569 * "application/sdp", the type is "application" and the subtype is "sdp".570 */571 struct SipMediaType572 {573 /** Media type. */574 string type;575 576 /** Media subtype. */577 string subType;578 };579 580 /**581 * Simple SIP header.582 */583 struct SipHeader584 {585 /**586 * Header name.587 */588 string hName;589 590 /**591 * Header value.592 */593 string hValue;594 595 /**596 * Initiaize from PJSIP header.597 */598 void fromPj(const pjsip_hdr *) throw(Error);599 600 /**601 * Convert to PJSIP header.602 */603 pjsip_generic_string_hdr &toPj() const;604 605 private:606 /** Interal buffer for conversion to PJSIP header */607 mutable pjsip_generic_string_hdr pjHdr;608 };609 610 611 /** Array of strings */612 typedef std::vector<SipHeader> SipHeaderVector;613 614 /**615 * This describes each multipart part.616 */617 struct SipMultipartPart618 {619 /**620 * Optional headers to be put in this multipart part.621 */622 SipHeaderVector headers;623 624 /**625 * The MIME type of the body part of this multipart part.626 */627 SipMediaType contentType;628 629 /**630 * The body part of tthis multipart part.631 */632 string body;633 };634 635 /** Array of multipart parts */636 typedef std::vector<SipMultipartPart> SipMultipartPartVector;637 638 /**639 * Additional options when sending outgoing SIP message. This corresponds to640 * pjsua_msg_data structure in PJSIP library.641 */642 struct SipTxOption643 {644 /**645 * Optional remote target URI (i.e. Target header). If NULL, the target646 * will be set to the remote URI (To header). At the moment this field647 * is only used when sending initial INVITE and MESSAGE requests.648 */649 string targetUri;650 651 /**652 * Additional message headers to be included in the outgoing message.653 */654 SipHeaderVector headers;655 656 /**657 * MIME type of the message body, if application specifies the messageBody658 * in this structure.659 */660 string contentType;661 662 /**663 * Optional message body to be added to the message, only when the664 * message doesn't have a body.665 */666 string msgBody;667 668 /**669 * Content type of the multipart body. If application wants to send670 * multipart message bodies, it puts the parts in multipartParts and set671 * the content type in multipartContentType. If the message already672 * contains a body, the body will be added to the multipart bodies.673 */674 SipMediaType multipartContentType;675 676 /**677 * Array of multipart parts. If application wants to send multipart678 * message bodies, it puts the parts in \a parts and set the content679 * type in \a multipart_ctype. If the message already contains a body,680 * the body will be added to the multipart bodies.681 */682 SipMultipartPartVector multipartParts;683 684 };685 686 209 687 210 } // namespace pj
Note: See TracChangeset
for help on using the changeset viewer.