/*===========================================================================
                    IMPORTANT NOTICE

                  OEM DISTRIBUTION ONLY

FILE:  OEMDSS.h

SERVICES:  OEM DSS backwards compatibility layer

GENERAL DESCRIPTION:
	Definitions, typedefs, etc. for newer DSS functions that do not exist in older distributions

        Copyright © 2003 QUALCOMM Incorporated.
               All Rights Reserved.
            QUALCOMM Proprietary/GTDR
===========================================================================*/

#ifndef OEMDSS_H
#define OEMDSS_H

#include "dssocket.h"           // for struct sockaddr, etc.

#if defined(__cplusplus)
extern "C" {
#endif



/*===========================================================================
  ===========================================================================
  The definitions below allow OEMSock.c to compile with DMSS releases
  prior to 5100/NT3503.
  ===========================================================================
  ===========================================================================*/
#if !defined(OEM_PROVIDES_SERVER_SOCKETS)

#define DS_ENOPROTOOPT 131 /* The option is unknown at the level indicated */
#define DS_EMSGSIZE       130           /* The message is too large.       */
#define DS_EMSGTRUNC      134  /* msg truncated, supplied buffer too small */

/*---------------------------------------------------------------------------
                      Asynchronous Socket Events
---------------------------------------------------------------------------*/
#define DS_ACCEPT_EVENT 0x08        /* associated with an accetable socket */


/*===========================================================================

FUNCTION DSS_LISTEN()

DESCRIPTION

  For TCP, this starts a passive open for connections.  Upon a
  sucessful connection, the socket callback function is invoked
  asserting DS_ACCEPT_EVENT as TRUE.  The application should respond
  with a call to dss_accept(). If a connection is recieved and there
  are no free queue slots the new connection is rejected
  (ECONNREFUSED).  The backlog queue is for ALL unaccepted sockets
  (half-open, or completely established).

  A listening UDP doesn't make sense, and as such isn't supported.
  DS_EOPNOTSUPP is returned.

  The sockfd parameter is a created (dss_socket) and bound (dss_bind)
  socket that will become the new listening socket.  The backlog
  parameter indiates the maximum length for the queue of pending
  sockets.  If backlog is larger than the maximum, it will be 
  reduced to the maximum (see DSS_SOMAXCONN).

  The argument dss_error should point to a memory location in which
  error conditions can be recorded.

DEPENDENCIES

  Network subsystem must be established and available.

  The sockfd should get a valid socket descriptor (implying a
  previously successful call to dss_socket) This socket should be
  bound to a specific port number (implying a previously successful
  call to dss_bind) .

RETURN VALUE

  Returns DSS_SUCCESS on success.  If the backlog was truncated
  DS_EFAULT will be set in errno, but the call will still be
  successful.

  On error, return DSS_ERROR and places the error condition value in
  *dss_errno.

  dss_errno Values
  ----------------
  DS_EWOULDBLOCK      operation would block (PJ: I don't think this CAN happen)
  DS_EBADF            invalid socket descriptor is specfied
  DS_EOPNOTSUPP       The socket is not capable of listening (UDP)
  DS_EFAULT           backlog parameter is invalid
  DS_ENETDOWN         network subsystem unavailable
  DS_NOMEM            not enough memory to establish backlog connections. 
  DS_EINVAL           Socket already open, closed, unbound or not one 
                      you can listen on. 

SIDE EFFECTS 
  For TCP, initiates passive open for new connections.

===========================================================================*/
extern sint15 dss_listen
(
  sint15 sockfd,                                      /* Socket descriptor */
  sint15 backlog,                      /* Number of connections to backlog */
  sint15 *dss_errno                               /* error condition value */
);

/*===========================================================================

FUNCTION DSS_ACCEPT()

DESCRIPTION

  The accept function is used on listening sockets to respond when
  DS_ACCEPT_EVENT is asserted.  The first backlog queued connection is
  removed from the queue, and bound to a new connected socket (as if
  you called dss_socket).  The newly created socket is in the
  connected state.  The listening socket is unaffect the queue size is
  maintained (ie. there is not need to call listen again.)

  The argument sockfd is the file descriptor of the listening socket

  The argument remote addr is a pointer to a struct sockaddr.  This
  structure is populated with the address information for the remote
  end of the new connection. addrlen should initially contain the
  length of the struct sockaddr passed in.  The length of the real
  address is placed in this location when the struct is populated.

  The argument dss_error should point to a memory location in which
  error conditions can be recorded.

DEPENDENCIES

  Network subsystem must be established and available.

  The sockfd should get a valid socket descriptor (implying a
  previously successful call to dss_socket) This socket should be
  bound to a specific port number (implying a previously successful
  call to dss_bind).  The socket should be listening (implying a
  previously successful call to dss_listen).

RETURN VALUE
  Returns the socket descriptor of the new socket on success.

  On error, return DSS_ERROR and places the error condition value in
  *dss_errno.

  dss_errno Values
  ----------------
  DS_EWOULDBLOCK      operation would block 
  DS_EBADF            invalid socket descriptor is specfied
  DS_EOPNOTSUPP       The socket is not of type SOCK_STREAM 
  DS_EINVAL           Socket is not listening. 
  DS_EFAULT           The addr parameter is bogus.
  DS_ENETDOWN         network subsystem unavailable
  DS_NOMEM            not enough memory to establish backlog connections. 

SIDE EFFECTS 

  The head backlog item from the queue of the listening socket is
  removed from that queue.

===========================================================================*/
extern sint15 dss_accept 
(
  sint15 sockfd,                                      /* Socket descriptor */
  struct sockaddr *remoteaddr,                       /* new remote address */
  uint16 *addrlen,                                   /* length of servaddr */
  sint15 *dss_errno                               /* error condition value */
);

#endif // !defined(OEM_PROVIDES_SERVER_SOCKETS)



/*===========================================================================
  ===========================================================================
  The definitions below allow OEMSock.c to compile with DMSS releases
  prior to 6050/DP3110.
  ===========================================================================
  ===========================================================================*/
#if !defined(AEE_SIMULATOR) && !defined(T_MSM6050)  && !defined(T_MSM6250)

enum
{
  DSS_SO_SILENT_CLOSE =  2,        /* bool: close() call causes conn reset */
};

/*===========================================================================

FUNCTION DSS_SETSOCKOPT

DESCRIPTION
  Set the options associated with a socket. This fuction expects the 
  following parameters:
  
DEPENDENCIES
  None. 
  
PARAMETERS  
  int sockfd        -     Socket file descriptor.
  int level         -     Socket option level. 
  int optname,      -     Option name. 
  void *optval      -     Pointer to the option value.
  uint32 *optlen    -     Pointer to the size of the option value.  
  sint15 *errno     -     Error condition value.     


RETURN VALUE
  On error, return DSS_ERROR and places the error condition value in *errno.

  Errno Values
  ------------
  DS_EBADF                invalid socket descriptor is specfied
  DS_ENOPROTOOPT          the option is unknown at the level indicated
  DS_EINVAL               invalid option name or invalid option value
  DS_EFAULT               Invalid buffer or argument

SIDE EFFECTS
  None.

===========================================================================*/
extern sint15 dss_setsockopt
(
  int sockfd,                            /* socket descriptor              */
  int level,                             /* socket option level            */
  int optname,                           /* option name                    */
  void *optval,                          /* value of the option            */
  uint32 *optlen,                        /* size of the option value       */
  sint15 *dss_errno                       /* error condition value          */
);

/*===========================================================================
FUNCTION DSS_GETSOCKOPT

DESCRIPTION
  Return an option associated with a socket. This fuction expects the 
  following parameters:
  
DEPENDENCIES
  None. 

PARAMETERS  
  int sockfd        -     Socket file descriptor.
  int level         -     Socket option level. 
  int optname,      -     Option name. 
  void *optval      -     Pointer to the option value.
  uint32 *optlen    -     Pointer to the size of the option value.  
  sint15 *errno     -     Error condition value.     

RETURN VALUE
  optlen is a value-result parameter, initially containing the size of 
  the buffer pointed to by optval, and modified on return to indicate the  
  actual  size  of the value returned. On error, return DSS_ERROR and places 
  the error condition value in *errno.

  Errno Values
  ------------
  DS_EBADF                invalid socket descriptor is specfied
  DS_ENOPROTOOPT          the option is unknown at the level indicated
  DS_EINVAL               invalid option name or invalid option value  
  DS_EFAULT               Invalid buffer or argument  

SIDE EFFECTS
  None.

===========================================================================*/
extern sint15 dss_getsockopt
(
  int sockfd,                            /* socket descriptor              */
  int level,                             /* socket option level            */                  
  int optname,                           /* option name                    */
  void *optval,                          /* value of the option            */
  uint32 *optlen,                        /* size of the option value       */
  sint15 *dss_errno                      /* error condition value          */
);

#endif // !defined(AEE_SIMULATOR) && !defined(T_MSM6050)



/*===========================================================================
  ===========================================================================
  The definitions below allow OEMSock.c to compile with DMSS releases
  prior to 6100/30505.
  ===========================================================================
  ===========================================================================*/
#if !defined(AEE_SIMULATOR) && !defined(T_MSM6100) && !defined(T_MSM6250)


#include "psglobal.h"           // for ip_addr_type
#include "ip.h"                 // for ip4a

/*---------------------------------------------------------------------------
TYPEDEF PS_IFACE_NAME_ENUM_TYPE

DESCRIPTION
  List of interface names and groups
---------------------------------------------------------------------------*/
typedef enum
{
  /* Group Names - Note: this is a mask which uses the bottom 15 bits */
  ANY_IFACE_GROUP    = 0x0000,
  ANY_DEFAULT_GROUP  = 0x0001,
  WWAN_GROUP         = 0x0002,
  RM_GROUP           = 0x0004,
  
  /* Interface Names - Note: these values are sequential */
  IFACE_MASK         = 0x8000,
  CDMA_SN_IFACE      = 0x8001,
  CDMA_AN_IFACE      = 0x8002,
  UMTS_IFACE         = 0x8003,
  SIO_IFACE          = 0x8004,
  LO_IFACE           = 0x8800

} ps_iface_name_enum_type;

/*---------------------------------------------------------------------------
TYPEDEF PS_IFACE_STATE_ENUM_TYPE

DESCRIPTION
  Enum for states of an interface.
---------------------------------------------------------------------------*/
typedef enum
{
  IFACE_DISABLED   = 0,
  IFACE_DOWN       = 1,
  IFACE_COMING_UP  = 2,
  IFACE_ROUTEABLE  = 3,          /* packet can be routed to this interface */
  IFACE_UP         = 4,          /* data can originate over this interface */
  IFACE_GOING_DOWN = 5
} ps_iface_state_enum_type;


/*---------------------------------------------------------------------------
TYPEDEF PHYS_LINK_STATE_TYPE

DESCRIPTION
  Physical link state enum - what is the physical link doing
---------------------------------------------------------------------------*/
typedef enum
{
  PHYS_LINK_DOWN       = 0,
  PHYS_LINK_COMING_UP  = 1,
  PHYS_LINK_UP         = 2,
  PHYS_LINK_GOING_DOWN = 3

} phys_link_state_type;

typedef struct
{
  ps_iface_name_enum_type  name;
  uint32                   instance;
} dss_iface_name_and_instance_type;

typedef enum
{
  DSS_APP_ID  = 0,
  DSS_SOCK_FD = 1
} dss_id_type;

typedef struct
{
  dss_id_type type;
  union
  {
    sint15 app_id;
    sint15 sockfd;
  } info;
} dss_id_info_type;

/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

                      REGIONAL DATA DECLARATIONS

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
/*---------------------------------------------------------------------------
  Definition of various interface control operations. Please do NOT change 
  the values of the existing enumerated types when adding new ones (to ensure
  that object code released with previous versions of the code do not break).
  Each of the following control operations have associated tyepdef (with 
  corresponding names) that are passed in or returned for get/set operations. 
  Note that all GET operations are assigned even numbers and SET operations 
  are assigned odd numbers. Also ensure that symetric operations are 
  grouped.  
---------------------------------------------------------------------------*/
typedef enum
{
  /*-------------------------------------------------------------------------
  
                              COMMON IOCTLS
                              
    The following operations are common to all interfaces. 
  -------------------------------------------------------------------------*/
  DSS_IFACE_IOCTL_MIN                     = -1,
  DSS_IFACE_IOCTL_GET_IPV4_ADDR           = 0, /* Get IPV4 addr of iface   */
  DSS_IFACE_IOCTL_GET_IPV4_PRIM_DNS_ADDR  = 2, /* Get Primary DNS (IPV4) addr 
                                                                  of iface */
  DSS_IFACE_IOCTL_GET_IPV4_SECO_DNS_ADDR  = 4, /* Get Secondary DNS (IPV4) 
                                                             addr of iface */
  DSS_IFACE_IOCTL_GET_MTU                 = 6, /* Get MTU of iface         */
  DSS_IFACE_IOCTL_GET_STATE               = 8, /* Get state of iface       */
  DSS_IFACE_IOCTL_GET_PHYS_LINK_STATE     = 10,/* Get physical link state  */
  DSS_IFACE_IOCTL_REG_EVENT_CB            = 12,/* Register callback for 
                                                  events. Note that app can 
                                                  have only one callback per 
                                                  interface for each event */
  DSS_IFACE_IOCTL_DEREG_EVENT_CB          = 13,/* Deregister event callback*/
  DSS_IFACE_IOCTL_GET_ALL_IFACES          = 14,/* Get all enabled ifaces. 
                                                  Note for that this IOCTL,
                                                  a NULL id_ptr has to be 
                                                  passed as a parameter    */   
  DSS_IFACE_IOCTL_REG_IP_FILTER           = 15,/* Register IP filter       */
  DSS_IFACE_IOCTL_DEREG_IP_FILTER         = 16,/* Deregister IP filter     */


  /*-------------------------------------------------------------------------
    The following operations are common, but implementation is specific to
    a particular iface. Some may not even be supported by a particular iface. 
  -------------------------------------------------------------------------*/
  DSS_IFACE_IOCTL_GO_ACTIVE               = 101,/* Go active from dormant  */
  DSS_IFACE_IOCTL_GO_NULL                 = 105,/* Go NULL                 */
  

  /*-------------------------------------------------------------------------
    IOCTLs which are interface specific should be enumerated below this.
    Note that the enuerated values from 0 - 199 are reserved for the common
    IOCTLs. All interface specific IOCTLs should use values greater than 199. 
    It is recommended that each interface have a certain range of values 
    reserved. This would ensure that all the interface specific operations
    are grouped together. For intance, CDMA2000 could use value b/w 200 and
    399, WCDMA 400 to 599 etc.
  -------------------------------------------------------------------------*/
  /*-------------------------------------------------------------------------
                                
                                707 IOCTLS
                                
    The following operations are specific to 707 (1x) interface. Start 200.
  -------------------------------------------------------------------------*/
  DSS_IFACE_IOCTL_707_GET_MDR             = 200,/* 1x QCMDR value          */
  DSS_IFACE_IOCTL_707_SET_MDR             = 201,/* 1x QCMDR value          */
  DSS_IFACE_IOCTL_707_GET_DORM_TIMER      = 202,/* 1x dorm timer value     */
  DSS_IFACE_IOCTL_707_SET_DORM_TIMER      = 203,/* 1x dorm timer value     */
  DSS_IFACE_IOCTL_707_GET_RLP_ALL_CURR_NAK= 204,/* 1x RLP curr NAK policy  */
  DSS_IFACE_IOCTL_707_SET_RLP_ALL_CURR_NAK= 205,/* 1x RLP curr NAK policy  */
  DSS_IFACE_IOCTL_707_GET_RLP_ALL_DEF_NAK = 206,/* 1x RLP  default NAK     */
  DSS_IFACE_IOCTL_707_SET_RLP_ALL_DEF_NAK = 207,/* 1x RLP  default NAK     */
  DSS_IFACE_IOCTL_707_GET_RLP_ALL_NEG_NAK = 208,/* 1x RLP  negotiated NAK  */
  DSS_IFACE_IOCTL_707_GET_RLP_QOS_NA_PRI  = 210,/* 1x QOS nonassured prio  */
  DSS_IFACE_IOCTL_707_SET_RLP_QOS_NA_PRI  = 211,/* 1x QOS nonassured prio  */
  DSS_IFACE_IOCTL_707_SDB_SUPPORT_QUERY   = 212,/* 1x SDB possible query   */
  DSS_IFACE_IOCTL_707_ENABLE_HOLDDOWN     = 215,/* 1x enable/disable
                                                   holddown timer          */

  /*-------------------------------------------------------------------------

                              UMTS IOCTLS
                                
    The following operations are specific to UMTS interface.Start from 300.
  -------------------------------------------------------------------------*/


  /*-------------------------------------------------------------------------

                              MORE COMMON STUFF
                              
  -------------------------------------------------------------------------*/
  DSS_IFACE_IOCTL_MAX,
  DSS_IFACE_IOCTL_NAME_FORCE_32_BIT       = 0x7FFFFFFF /* Force 32bit enum */
} dss_iface_ioctl_type;

/*---------------------------------------------------------------------------
                                
                                COMMON DATA STRUCTURES
                                
              The following data structs are for common ioctls.
---------------------------------------------------------------------------*/

/*---------------------------------------------------------------------------
  Definition of iface names.
---------------------------------------------------------------------------*/
typedef enum
{
  DSS_IFACE_IOCTL_CDMA_SN,
  DSS_IFACE_IOCTL_CDMA_AN,
  DSS_IFACE_IOCTL_UMTS,
  DSS_IFACE_IOCTL_SIO,
  DSS_IFACE_IOCTL_IFACE_FORCE_32_BIT = 0x7FFFFFFF /* Force 32bit enum type */
} dss_iface_ioctl_name_enum_type;

/*---------------------------------------------------------------------------
  Definition of identifying struct.  
---------------------------------------------------------------------------*/
typedef struct
{
  dss_iface_ioctl_name_enum_type  name;
  uint32                          instance;
} dss_iface_ioctl_id_type;

/*---------------------------------------------------------------------------
  Definition of iface events.
---------------------------------------------------------------------------*/
typedef enum
{
  DSS_IFACE_IOCTL_MIN_EV,
  DSS_IFACE_IOCTL_DOWN_EV,
  DSS_IFACE_IOCTL_UP_EV,
  DSS_IFACE_IOCTL_PHYS_LINK_DOWN_EV,
  DSS_IFACE_IOCTL_PHYS_LINK_UP_EV,
  DSS_IFACE_IOCTL_ADDR_CHANGED_EV,
  DSS_IFACE_IOCTL_EVENT_MAX,
  DSS_IFACE_IOCTL_EVENT_FORCE_32_BIT = 0x7FFFFFFF /* Force 32bit enum type */
} dss_iface_ioctl_event_enum_type; 

/*---------------------------------------------------------------------------
  Data type used for Phys link State (DSS_IFACE_IOCTL_PHYS_LINK_STATE)
---------------------------------------------------------------------------*/
typedef phys_link_state_type dss_iface_ioctl_phys_link_state_type;

/*---------------------------------------------------------------------------
  Data types used for registering/deregistering for event callbacks 
  (DSS_IFACE_IOCTL_REG_EVENT_CB/DSS_IFACE_IOCTL_DEREG_EVENT_CB)
---------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------
  Event info for DSS_IFACE_IOCTL_DOWN_EV and DSS_IFACE_IOCTL_UP_EV
---------------------------------------------------------------------------*/
typedef ps_iface_state_enum_type dss_iface_ioctl_event_info_type;

/*---------------------------------------------------------------------------
  Event info for DSS_IFACE_IOCTL_PHYS_LINK_DOWN_EV and 
  DSS_IFACE_IOCTL_PHYS_LINK_UP_EV
---------------------------------------------------------------------------*/
typedef phys_link_state_type dss_iface_ioctl_phys_link_event_info_type;

/*---------------------------------------------------------------------------
  Event info for DSS_IFACE_IOCTL_ADDR_CHANGED_EV
---------------------------------------------------------------------------*/
typedef ip_addr_type dss_iface_ioctl_addr_change_event_info_type;

typedef union
{
  dss_iface_ioctl_event_info_type             iface_state_info;
  dss_iface_ioctl_phys_link_event_info_type   phys_link_state_info;
  dss_iface_ioctl_addr_change_event_info_type addr_change_info;
} dss_iface_ioctl_event_info_union_type;

/*---------------------------------------------------------------------------
  Typedef for event callback function
  (DSS_IFACE_IOCTL_REG_EVENT_CB/ DSS_IFACE_IOCTL_DEREG_EVENT_CB)
---------------------------------------------------------------------------*/
typedef void (*dss_iface_ioctl_event_cb)
(
  dss_iface_ioctl_event_enum_type          event,
  dss_iface_ioctl_event_info_union_type    event_info,
  void                                     *user_data,
  sint15                                   app_id,
  ps_iface_name_enum_type                  name,
  uint32                                   instance 
);

/*---------------------------------------------------------------------------
  Typedef for struct used with DSS_IFACE_IOCTL_REG_EVENT_CB and
  DSS_IFACE_IOCTL_DEREG_EVENT_CB. Note that the application must specify a 
  valid APP_ID when registering/deregistering for event callbacks.
---------------------------------------------------------------------------*/
typedef struct 
{
  dss_iface_ioctl_event_cb        event_cb;
  dss_iface_ioctl_event_enum_type event;
  void                            *user_data_ptr;
  sint15                          app_id;
} dss_iface_ioctl_ev_cb_type;


/*---------------------------------------------------------------------------
  Data type used for DSS_IFACE_IOCTL_GO_ACTIVE and DSS_IFACE_IOCTL_GO_NULL 
  (Note that apps do not have to define an arg of this type.
   They can just pass in Null).
---------------------------------------------------------------------------*/
typedef void dss_iface_ioctl_null_arg_type;

/*---------------------------------------------------------------------------
  Data type used for 707 QCMDR value
  (DSS_IFACE_IOCTL_707_GET/SET_MDR)
---------------------------------------------------------------------------*/
typedef unsigned int dss_iface_ioctl_707_mdr_type;

/*---------------------------------------------------------------------------
  Data type used for 707 RLP3 NAK policies (current, default, negotiated)
  (DSS_IFACE_IOCTL_707_GET/SET_RLP_ALL_CURR_NAK)
  (DSS_IFACE_IOCTL_707_GET/SET_RLP_ALL_DEF_NAK)
  (DSS_IFACE_IOCTL_707_GET_RLP_ALL_NEG_NAK)
  IOCTL_707_MAX_NAK_ROUNDS should be same as DSRLP_MAX_NAK_ROUNDS. Duplicate
  definition to avoid exposing dsrlp.h  by including here.
---------------------------------------------------------------------------*/
#define IOCTL_707_MAX_NAK_ROUNDS 3

typedef struct
{
  byte rscb_index;
  byte nak_rounds_fwd;
  byte naks_per_round_fwd[IOCTL_707_MAX_NAK_ROUNDS];
  byte nak_rounds_rev;
  byte naks_per_round_rev[IOCTL_707_MAX_NAK_ROUNDS];
} dss_iface_ioctl_707_rlp_opt_type;

/*--------------------------------------------------------------------------
  Data type used for 707 SDB support query.
---------------------------------------------------------------------------*/
typedef struct
{
  uint32 flags;       /* Same flag as used in socket write to specify SDB
                         (Eg: MSG_USE_SDB_REACH, MSG_USE_SDB_ACH, etc)     */
  boolean can_do_sdb; /* On return from ioctl, this boolean field will say
                         whether SDB supported or not                      */
} dss_iface_ioctl_707_sdb_support_query_type;

#define DS_ESHUTDOWN      136 /* can't send after shutting down write-half */

/*---------------------------------------------------------------------------
  The values for the 'how' argument of the shutdown() call. Specifies what
  action to perform:
---------------------------------------------------------------------------*/
enum
{
  DSS_SHUT_RD   = 0,                          /* disallow further receives */
  DSS_SHUT_WR   = 1,                             /* disallow further sends */
  DSS_SHUT_RDWR = 2          /* disallow further receives as well as sends */
};

enum
{
  DSS_SO_RCVBUF       =  3,        /* set the receive window size          */
};

enum
{
  DSS_SOL_SOCKET = 2,               /* socket level                        */
};

/*===========================================================================
FUNCTION DSS_GETSOCKNAME

DESCRIPTION
  Returns the local address assigned to the specified socket.
  
DEPENDENCIES
  None. 

PARAMETERS  
  sockfd    -  socket file descriptor
  addr      -  local address currently assigned to the socket 
  addrlen   -  address length. This parameter is initialized to indicate
               the amount of space pointed by addr and on return, it 
               contains the actual size of the address returned.
  dss_errno -  error number

RETURN VALUE
  Returns DSS_SUCCESS upon successful completion and places the socket 
  address and the address length in addr and addrlen parameters, resp.

  On error, returns DSS_ERROR and places the error number in dss_errno.

  Errno Values
  ------------
  DS_EBADF                invalid socket descriptor is specfied
  DS_EFAULT               addr parameter points to an invalid memory 
                          location

SIDE EFFECTS
  None.

===========================================================================*/
extern sint15 dss_getsockname
(
  sint15           sockfd,                  /* socket descriptor           */
  struct sockaddr* addr,                    /* address of the socket       */
  uint16*          addrlen,                 /* address length              */
  sint15*          dss_errno                /* error number                */
);

/*===========================================================================
FUNCTION DSS_GETPEERNAME

DESCRIPTION
  Returns the address of the peer connected to the specified socket.
  
DEPENDENCIES
  None. 

PARAMETERS  
  sockfd    -  socket file descriptor
  addr      -  address of the peer connected with the socket 
  addrlen   -  address length. This parameter is initialized to indicate
               the amount of space pointed by addr and on return, it 
               contains the actual size of the address returned.
  dss_errno -  error number

RETURN VALUE
  Returns DSS_SUCCESS upon successful completion and places the peer 
  address and the address length in addr and addrlen parameters, resp.

  On error, returns DSS_ERROR and places the error number in dss_errno.

  Errno Values
  ------------
  DS_EBADF                invalid socket descriptor is specfied
  DS_EFAULT               addr parameter points to an invalid memory 
                          location
  DS_ENOTCONN             the socket is not connected

SIDE EFFECTS
  None.

===========================================================================*/
extern sint15 dss_getpeername
(
  sint15           sockfd,                  /* socket descriptor           */
  struct sockaddr* addr,                    /* address of the socket       */
  uint16*          addrlen,                 /* address length              */
  sint15*          dss_errno                /* error number                */
);

/*===========================================================================
FUNCTION DSS_GET_IFACE_ID()

DESCRIPTION
  This function is used to get the interface name and instance of a specific
  interface. The interface can be specified using either an app_id or a 
  sockfd. Note that the interface would be the one that the app/socket is
  currently using.

DEPENDENCIES
  None.

PARAMETERS
  dss_id_info_type id - Specifies whether an app_id or sockfd is being 
    as an identifier.
  dss_iface_ioctl_id_type *iface_id - Output parameter which contains the 
    name and instance of the iface associated with specified id.
 
RETURN VALUE
  0 on success.
  -1 on failure.

SIDE EFFECTS
  None.
===========================================================================*/
extern int dss_get_iface_id
(
  dss_id_info_type id,
  dss_iface_ioctl_id_type *iface_id 
);

// static callback from OEMTAPI.c
extern void OEMDSS_OnCallStatus(void);

/*===========================================================================
FUNCTION DSS_IFACE_IOCTL()

DESCRIPTION
  This function dstermines the ps_iface_ptr associated with the passed in
  identifier (App ID). It then calls ps_iface_ioctl().

DEPENDENCIES
  None.

PARAMETERS

  dss_iface_ioctl_id_type   - Interface ID on which the specified operations 
                              is to be performed
                          
  dss_iface_ioctl_type      - The operation name
  
  void*                     - Pointer to operation specific structure
  
  sint15*                   - Error code returned in case of failure (Error 
                              values are those defined in dserrno.h)
                              
                              DS_EBADF - Returned by dss_iface_ioctl() if the
                              specified id_ptr is invalid (i.e. id_ptr does 
                              not map to a valid ps_iface_ptr).
                              
                              DS_EINVAL - Returned by dss_iface_ioctl() when 
                              the specified IOCTL does not belong to the 
                              common set of IOCTLs and there is no IOCTL mode
                              handler registered for the specified interface.
                              
                              DS_EOPNOTSUPP - Returned by the lower level 
                              IOCTL mode handler when specified IOCTL is not 
                              supported by the interface. For instance, this 
                              would be returned by interfaces that do not 
                              support a certain "iface specific common IOCTL"
                              (i.e. these are common IOCTLs, but the 
                              implementation is mode specific, for example, 
                              "GET_MDR").
                              
                              DS_EFAULT - This error code is returned if the 
                              specified arguments for the IOCTL are incorrect 
                              or if dss_iface_ioctl() or a mode handler 
                              encounters an error while executing the IOCTL.                            
                              
                              DS_NOMEMORY - This error code is returned if we
                              run out of buffers during execution.

RETURN VALUE
  0 - on success
  -1 - on failure

SIDE EFFECTS
  None.

===========================================================================*/
extern int dss_iface_ioctl
( 
  dss_iface_ioctl_id_type  *id_ptr,
  dss_iface_ioctl_type     ioctl_name,
  void                     *argval_ptr,
  sint15                   *dss_errno
);

/*===========================================================================
FUNCTION DSS_SHUTDOWN

DESCRIPTION
  Shuts down the connection of the specified socket depending on the
  'how' parameter as follows:
   
  DSS_SHUT_RD:   Disallow subsequent calls to recv function
  DSS_SHUT_WR:   Disallow subsequent calls to send function
  DSS_SHUT_RDWR: Disallow subseuqnet calls to both recv and send functions
  
DEPENDENCIES
  None. 

PARAMETERS  
  sockfd    -  socket file descriptor
  how       -  action to be performed
  dss_errno -  error number

RETURN VALUE
  Returns DSS_SUCCESS upon successful completion.

  On error, returns DSS_ERROR and places the error number in dss_errno.

  Errno Values
  ------------
  DS_EBADF                invalid socket descriptor is specfied
  DS_ENOTCONN             the socket is not connected

SIDE EFFECTS
  None.

===========================================================================*/
extern sint15 dss_shutdown
(
  sint15           sockfd,                  /* socket descriptor           */
  uint16           how,                     /* what action to perform      */
  sint15*          dss_errno                /* error number                */
);

#define IP_ADDR_V4(a) a
#define IP_ADDR_IS_VALID(a) TRUE

#else // !defined(AEE_SIMULATOR) && !defined(T_MSM6100) && !defined(T_MSM6250) 

#define IP_ADDR_V4(a) a.addr.v4
#define IP_ADDR_IS_VALID(a) ((a).type != IP_ADDR_INVALID)

#endif // !defined(AEE_SIMULATOR) && !defined(T_MSM6100) && !defined(T_MSM6250) 



/*===========================================================================
  ===========================================================================
  The definitions below allow OEMSock.c to compile with DMSS releases
  prior to 6100/4040 and with DMSS release 6050/3320.  DSS_MAX_SYS_APPS was 
  defined in 6100 somewhere between releases 30505 and 4040.  PF_INET6 was defined 
  somewhere between 6050/3110 and 6050/3320 and was defined in 6100 somewhere 
  between releases 30505 and 4040.
  ===========================================================================
  ===========================================================================*/
#if !defined(DSS_MAX_SYS_APPS) && !defined(PF_INET6)

enum 
{
  DSS_SO_LINGER       =  4,        /* linger on close                      */
};

#endif // !defined(DSS_MAX_SYS_APPS) && !defined(PF_INET6)

#if !defined(DSS_MAX_SYS_APPS) 

/*---------------------------------------------------------------------------
  The data type used for SO_LINGER socket option. Note that l_linger is in
  ms, not in seconds as on UNIX systems
---------------------------------------------------------------------------*/
typedef struct
{
  int l_onoff;                                     /* linger active or not */
  int l_linger;                   /* how many milli-secondss to linger for */
} dss_so_linger_type;

#endif // !defined(DSS_MAX_SYS_APPS)

#if !defined(MAX_SYSTEM_IFACES)

/*---------------------------------------------------------------------------
  MAX_SYSTEM_IFACES - the maximum number of interfaces in the system.
  2 - CDMA SN IFACE (1 for pkt, 1 for async)
  1 - CDMA AN IFACE  
  3 - UMTS IFACE
  2 - SIO IFACE (1 for CDMA, 1 for UMTS)  
  1 - LO IFACE  
  1 - IPSEC IFACE
---------------------------------------------------------------------------*/
#define MAX_SYSTEM_IFACES 10

/*---------------------------------------------------------------------------
  DSS_IFACE_IOCTL_GET_ALL_IFACES parameter type
  -  (Note for this IOCTL, a NULL id_ptr has to be passed as a parameter).
---------------------------------------------------------------------------*/
typedef struct
{
  unsigned int            number_of_ifaces;
  dss_iface_ioctl_id_type ifaces[MAX_SYSTEM_IFACES];
} dss_iface_ioctl_all_ifaces_type;

#endif // !defined(MAX_SYSTEM_IFACES)



/*===========================================================================
  ===========================================================================
  The definitions below allow OEMSock.c to compile with DMSS releases
  prior to 6100/5015.  DSS_IFACE_GET_ID3 was defined in 6100 somewhere
  between releases 4040 and 5015.
  ===========================================================================
  ===========================================================================*/
#if !defined(DSS_IFACE_GET_ID3)

/*---------------------------------------------------------------------------
  opaque interface id
---------------------------------------------------------------------------*/

typedef uint32 dss_iface_id_type;

/*---------------------------------------------------------------------------
  Invalid iface_id: does not identify any valid iface
---------------------------------------------------------------------------*/
#define DSS_IFACE_INVALID_ID  0

#define DSS_IFACE_GET_ID3(iface_name, iface_inst, phys_link_inst)  \
  ( (((uint32)iface_name & 0x0000FFFF) << 16) |                    \
    (((uint32)iface_inst & 0x000000FF) << 8) |                     \
    ((uint32)phys_link_inst & 0x000000FF) )

static __inline dss_iface_id_type oemdss_get_iface_id(sint15 appid)
{
   static dss_iface_ioctl_id_type iface_ioctl_id;
   dss_id_info_type id;

   id.type = DSS_APP_ID;
   id.info.app_id = appid;

   if (DSS_SUCCESS != dss_get_iface_id(id, &iface_ioctl_id)) {
      return DSS_IFACE_INVALID_ID;
   }

   return DSS_IFACE_GET_ID3(iface_ioctl_id.name, iface_ioctl_id.instance, 0);
}

/*---------------------------------------------------------------------------
  DSS_IFACE_IOCTL_GET_ALL_IFACES parameter type
  -  (Note for this IOCTL, a NULL id_ptr has to be passed as a parameter).
---------------------------------------------------------------------------*/
typedef struct
{
  unsigned int      number_of_ifaces;
  dss_iface_id_type ifaces[MAX_SYSTEM_IFACES];
} oemdss_iface_ioctl_all_ifaces_type;

static __inline int oemdss_iface_ioctl
( 
  dss_iface_id_type        iface_id,
  dss_iface_ioctl_type     ioctl_name,
  void                     *argval_ptr,
  sint15                   *dss_errno
)
{
   if (DSS_IFACE_IOCTL_GET_ALL_IFACES == ioctl_name) {
      dss_iface_ioctl_all_ifaces_type iface_info;
      int ret;

      ret = dss_iface_ioctl(0,
                            ioctl_name,
                            &iface_info,
                            dss_errno);
      if (DSS_SUCCESS == ret) {
         oemdss_iface_ioctl_all_ifaces_type* pIFaceInfo = (oemdss_iface_ioctl_all_ifaces_type*)argval_ptr;
         int i;

         pIFaceInfo->number_of_ifaces = iface_info.number_of_ifaces;
         for (i = 0; i < iface_info.number_of_ifaces; ++i) {
            pIFaceInfo->ifaces[i] = DSS_IFACE_GET_ID3(iface_info.ifaces[i].name, iface_info.ifaces[i].instance, 0);
         }
      }

      return ret;
   } else {
      static dss_iface_ioctl_id_type iface_ioctl_id;

      iface_ioctl_id.name = (iface_id >> 16) & 0x0000FFFF;
      iface_ioctl_id.instance = (iface_id >> 8) & 0x000000FF;
       
      return dss_iface_ioctl(&iface_ioctl_id,
                             ioctl_name,
                             argval_ptr,
                             dss_errno);
   }
}

#else // !defined(DSS_IFACE_GET_ID3)

/*===========================================================================
  ===========================================================================
  The definitions below allow OEMSock.c to compile with later variations of
  dss_get_iface_id().
  ===========================================================================
  ===========================================================================*/
#if !defined(DSS_GET_IFACE_ID_VERS) || (DSS_GET_IFACE_ID_VERS < 3)

static __inline dss_iface_id_type oemdss_get_iface_id(sint15 appid)
{
   dss_id_info_type id;

   id.type = DSS_APP_ID;
   id.info.app_id = appid;

   return dss_get_iface_id(id);
}

#else // !defined(DSS_GET_IFACE_ID_VERS) || (DSS_GET_IFACE_ID_VERS < 3)

#define oemdss_get_iface_id dss_get_iface_id

#endif // !defined(DSS_GET_IFACE_ID_VERS) || (DSS_GET_IFACE_ID_VERS < 3)

#define oemdss_iface_ioctl dss_iface_ioctl

#define oemdss_iface_ioctl_all_ifaces_type dss_iface_ioctl_all_ifaces_type

#endif // !defined(DSS_IFACE_GET_ID3)


/*===========================================================================
  ===========================================================================
  The definitions below allow OEMSock.c to compile with DMSS releases
  prior to 6100/5150.  DSS_MIN_RCVBUF was defined in 6100 somewhere
  between releases 5015 and 5150.
  ===========================================================================
  ===========================================================================*/
#if !defined(DSS_MIN_RCVBUF)

/*---------------------------------------------------------------------------
  Range values for various socket options
---------------------------------------------------------------------------*/
#define DSS_MIN_RCVBUF (536)
#define DSS_MAX_RCVBUF (18 * 1024)
#define DSS_MIN_SNDBUF (536)
#define DSS_MAX_SNDBUF (18 * 1024)

enum 
{
  DSS_SO_SNDBUF       =  5,        /* set/get the sndbuf queue size        */
  DSS_TCP_MAXSEG      =  6,        /* set/get the TCP maximum segement size*/
  DSS_SO_SDB_ACK_CB   =  7,        /* call a cb upon recv'ing SDB data ack */
  DSS_TCP_NODELAY     =  8,        /* Disable Nagle's algorithm            */
  DSS_SO_KEEPALIVE    =  9,        /* Send keepalive probes?               */
};

enum
{
  DSS_IPPROTO_TCP = 3,               /* TCP protocol level                  */
};

#endif // !defined(DSS_MIN_RCVBUF)

#if !defined(MSG_EXPEDITE)

/*---------------------------------------------------------------------------
  Flags passed to dss_sendto() call for SDB. Non-SDB related flags are 
  defined in dssocket.h. Any time a SDB related flags is added here, OR it 
  with the existing flags in MSG_VALID_BITS macro definition in dssocki.c 
  so that the reserved bit mask can be properly built.

  SDB flags will cause short data burst to be used if the mobile is not on
  traffic. Don't set any bit if one doesn't want SDB and traffic is to be 
  brought up. Set both bits if one doesn't care which channel is used for
  SDB transmission, else set the appropriate bit.
---------------------------------------------------------------------------*/
#define MSG_EXPEDITE      0x00000001   /* use ACH/REACH/TCH                */
#define MSG_FAST_EXPEDITE 0x00000002   /* use     REACH/TCH                */

/*---------------------------------------------------------------------------
  Enum to indicate the SDB ack status code to the application. The pkt mgr
  receives the status from CM and maps it to the this enum to be returned
  to the application. Changes to CM/Pkt mgr may necessitate modifying this
  enum definition.
---------------------------------------------------------------------------*/
typedef enum dss_sdb_ack_status_enum_type
{
  DSS_SDB_ACK_NONE = -1,                         /* completed successfully */
  DSS_SDB_ACK_OK = 0,                            /* completed successfully */
  DSS_SDB_ACK_HOLD_ORIG_RETRY_TIMEOUT = 1,      /* hold orig retry timeout */
  DSS_SDB_ACK_HOLD_ORIG = 2,   /* cannot process because hold orig is true */
  DSS_SDB_ACK_NO_SRV = 3,                                    /* no service */
  DSS_SDB_ACK_ABORT = 4,                                          /* abort */
  DSS_SDB_ACK_NOT_ALLOWED_IN_AMPS = 5,       /* cannot send in analog mode */
  DSS_SDB_ACK_NOT_ALLOWED_IN_HDR = 6,           /* cannot send in HDR call */
  DSS_SDB_ACK_L2_ACK_FAILURE = 7,              /* failure receiving L2 ack */
  DSS_SDB_ACK_OUT_OF_RESOURCES = 8,          /* e.g., out of memory buffer */
  DSS_SDB_ACK_ACCESS_TOO_LARGE = 9,   /* msg too large to be sent over acc */
  DSS_SDB_ACK_DTC_TOO_LARGE = 10,     /* msg too large to be sent over DTC */
  DSS_SDB_ACK_OTHER = 11,          /* any status response other than above */
  DSS_SDB_ACK_ACCT_BLOCK = 12,   /* Access blocked based on service option */
  DSS_SDB_ACK_FORCE_32_BIT = 0x7FFFFFFF     /* Force the enum to be 32-bit */
} dss_sdb_ack_status_enum_type;

/*---------------------------------------------------------------------------
  The structure containing information about the sdb ack status. This info 
  is returned to the socket application in the sdb ack callback if the sdb 
  ack callback socket option is set.
---------------------------------------------------------------------------*/
typedef struct dss_sdb_ack_status_info_type
{
  uint32                       overflow;
  dss_sdb_ack_status_enum_type status;
} dss_sdb_ack_status_info_type;

#endif // !defined(MSG_EXPEDITE)

/*===========================================================================
  ===========================================================================
  The definitions below allow OEMSock.c to compile with DMSS releases
  prior to 6500/3030.  DSS_GET_IFACE_ID_BY_POLICY_VERS was defined in 6500 by
  release 3030.
  ===========================================================================
  ===========================================================================*/
#if !defined(DSS_GET_IFACE_ID_BY_POLICY_VERS)

/*---------------------------------------------------------------------------
  Definition of iface names
---------------------------------------------------------------------------*/
typedef enum
{
  DSS_IFACE_CDMA_SN      = CDMA_SN_IFACE,
  DSS_IFACE_CDMA_AN      = CDMA_AN_IFACE,
#ifdef FEATURE_DATA_BCMCS
  DSS_IFACE_CDMA_BCAST   = CDMA_BCAST_IFACE,
#endif
  DSS_IFACE_UMTS         = UMTS_IFACE,
  DSS_IFACE_SIO          = SIO_IFACE,
  DSS_IFACE_LO           = LO_IFACE,
  DSS_IFACE_WWAN         = WWAN_GROUP,
  DSS_IFACE_ANY_DEFAULT  = ANY_DEFAULT_GROUP,
  DSS_IFACE_ANY          = ANY_IFACE_GROUP,
  DSS_IFACE_RM           = RM_GROUP
} dss_iface_name_enum_type;

typedef enum
{
  DSS_IFACE_ID = 0,
  DSS_IFACE_NAME = 1
} dss_iface_id_kind_enum_type;

/*---------------------------------------------------------------------------
  dss_iface_id_type will be treated as opaque and typedef'ed to int
  16 bits for iface name, 8 bits for instance and 8 for phys link
  the user will get the iface_id by supplying iface and instance to a 
  function that will return dss_iface_id_type. an attempt to get the
  iface_id for "ANY" iface will return error.
---------------------------------------------------------------------------*/

typedef struct
{
  dss_iface_id_kind_enum_type kind;
  union
  {
    dss_iface_id_type id;
    dss_iface_name_enum_type name;
  } info;
} dss_iface_type;

/*---------------------------------------------------------------------------
                       Network policy data structures.
---------------------------------------------------------------------------*/

typedef enum
{
  DSS_IFACE_POLICY_SPECIFIED = 0,  
  DSS_IFACE_POLICY_UP_ONLY   = 1,
  DSS_IFACE_POLICY_UP_SPEC   = 2 
} dss_iface_policy_flags_enum_type;

typedef struct
{
  dss_iface_policy_flags_enum_type policy_flag; /* Desired policy behavior */ 
  dss_iface_type                   iface;                 /* Desired IFACE */
  boolean                          ipsec_disabled;  /* Is IPSEC disabled ? */
  int                              family;   /* ipv4 or ipv6 or don't care */
  boolean                          is_routeable; /* Is interface routeable?*/
  struct 
  {
    int pdp_profile_num;
  } umts;                              /* UMTS specific policy information */
  struct 
  {
    int cookie;
  } dss_netpolicy_private;         /* Private cookie for internal purposes */
} dss_net_policy_info_type;

static __inline void dss_init_net_policy_info
(
  dss_net_policy_info_type * policy_info_ptr       /* policy info structure */
)
{
}

static __inline sint15 dss_set_app_net_policy
(
  sint15 appid,                                          /* Application id */
  dss_net_policy_info_type * policy_info_ptr,     /* policy info structure */
  sint15 * dss_errno                                       /* error number */
)
{
   return DSS_SUCCESS;
}

#endif // !defined(DSS_GET_IFACE_ID_BY_POLICY_VERS)

/*===========================================================================
  ===========================================================================
  The definitions below allow OEMSock.c to compile with DSS_VERSION
  prior to 50
  ===========================================================================
  ===========================================================================*/
#if ((!defined DSS_VERSION) || (DSS_VERSION<50))

enum 
{
  DSS_TCP_DELAYED_ACK =  12,       /* Enable delayed ack                   */
  DSS_TCP_SACK        =  13,       /* Enable SACK                          */
  DSS_TCP_TIME_STAMP  =  14,       /* Enable TCP time stamp option         */
};

#endif // ((!defined DSS_VERSION) || (DSS_VERSION<50))

/*===========================================================================
  ===========================================================================
  The definitions below allow OEMSock.c to compile with DSS_VERSION
  prior to 70
  ===========================================================================
  ===========================================================================*/
#if ((!defined DSS_VERSION) || (DSS_VERSION<70))

enum 
{
  /* Register for a Mobile Terminated event callback */
  DSS_IFACE_IOCTL_MT_REG_CB = DSS_IFACE_IOCTL_MAX,
  /* Deregister for a Mobile Terminated event callback */
  DSS_IFACE_IOCTL_MT_DEREG_CB = DSS_IFACE_IOCTL_MAX
};

/*---------------------------------------------------------------------------
  Mobile Terminated handle type.
---------------------------------------------------------------------------*/
typedef uint32 dss_iface_ioctl_mt_handle_type;

/*---------------------------------------------------------------------------
  Register callback through dss_iface_ioctl(DSS_IFACE_IOCTL_MT_REG_CB)
---------------------------------------------------------------------------*/
typedef struct 
{
  sint15                                app_id;
  dss_iface_ioctl_event_cb              event_cb;
  void                                 *user_data_ptr;
  dss_iface_ioctl_mt_handle_type       *handle;
} dss_iface_ioctl_mt_reg_cb_type; 

/*---------------------------------------------------------------------------
  De-register callback through dss_iface_ioctl(DSS_IFACE_IOCTL_MT_DEREG_CB)
---------------------------------------------------------------------------*/
typedef struct 
{
  sint15                                app_id;
  dss_iface_ioctl_mt_handle_type        handle;
} dss_iface_ioctl_mt_dereg_cb_type;

#endif // ((!defined DSS_VERSION) || (DSS_VERSION<70))


#if defined(__cplusplus)
}
#endif

#endif /* OEMDSS_H */