original files of m241

This commit is contained in:
neelimap
2026-07-30 11:19:44 +05:30
parent 170c2b3f3a
commit afc7070c1f
12254 changed files with 7655111 additions and 0 deletions
@@ -0,0 +1,665 @@
/* ipdiameter.h - Diameter head file */
/*
* Copyright (c) 2007 Wind River Systems, Inc.
*
* The right to copy, distribute or otherwise make use of this software
* may be licensed only pursuant to the terms of an applicable Wind River
* license agreement. No license to Wind River intellectual property rights
* is granted herein. All rights not licensed by Wind River are reserved
* by Wind River.
*/
/*
modification history
--------------------
01p,24apr09,tlu Update the Diameter version number to 2 as per
requirement from draft-ietf-dime-rfc3588bis-XXX
01o,20mar09,tlu Add re-auth field to request structure
01n,10mar09,tlu Fix Linux build warning
01m,11feb09,tlu Added definition for reserved bits in command flags
01l,12jan09,tlu Added Diameter EAP appl ID
01k,24apr08,ggz Added ipdiameter_set_wfd function
01j,25mar08,ggz Added prototypes for failover functions
01i,17apr08,tlu Add compile condition to call ipcom mutex utilities directly
for VxWorks, and call recursive semaphore for Linux
01h,01oct07,tlu Port to Linux
01g,08aug07,tlu Add TLS support
01f,01aug07,tlu Add session ID seed and node specific open function
01e,19jul07,tlu Move ipdiameter_avp_check() from application APIs to Diameter
internal APIs
01d,10jul07,tlu Add local node TCP listening port as a configuration parameter
01c,27jun07,tlu Add grouped AVP functions as application APIs
01b,19jun07,tlu Add AVP flags and vendor_id to ipdiameter_avp_add_** functions
01a,05apr07,tlu Created.
*/
#ifndef IPDIAMETER_H
#define IPDIAMETER_H
/*
****************************************************************************
* INCLUDE FILES
****************************************************************************
*/
#include <ipcom_tags.h>
#include <ipcom_type.h>
#include <ipcom_sock.h>
#include <ipcom_sock6.h>
#include <ipcom_list.h>
#include <ipcom_tmo2.h>
#ifdef IPSSL
#include <openssl/ssl.h>
#else
typedef char SSL;
typedef char SSL_CTX;
#endif /* IPSSL */
#include "ipdiameter_config.h"
#include <ipdiameter_constant.h>
#include <ipdiameter_session.h>
#include <ipdiameter_peer.h>
#include <ipdiameter_tls.h>
#include <ipdiameter_routing.h>
#ifdef __cplusplus
extern "C" {
#endif
/*
****************************************************************************
* DEFINES
****************************************************************************
*/
#define IPDIAMETER_ENABLE_REENTRANT
/* Syslog priority and facility. */
#undef IPCOM_SYSLOG_PRIORITY
#define IPCOM_SYSLOG_PRIORITY IPDIAMETER_SYSTEM_PRIORITY
#undef IPCOM_SYSLOG_FACILITY
#define IPCOM_SYSLOG_FACILITY IPCOM_LOG_IPDIAMETER
#define IPDIAMETER_LEAVE(xerrval) do { retval = xerrval; goto leave; } while(0)
#define IPDIAMETER_ERROUT(xerrval) do { retval = xerrval; goto errout; } while(0)
#define IPDIAMETER_AUTH_APP_ID(id) ((id == DIAMETER_NASREQ) || \
(id == DIAMETER_MIP) || \
(id == DIAMETER_EAP))
#define IPDIAMETER_ACCT_APP_ID(id) ((id == DIAMETER_Base_Accounting) || \
(id == DIAMETER_Credit_Control))
#define IPDIAMETER_VALID_APP_ID(id) ((id == DIAMETER_Common_Message) || \
(id == DIAMETER_NASREQ) || \
(id == DIAMETER_MIP) || \
(id == DIAMETER_Base_Accounting) || \
(id == DIAMETER_Credit_Control) || \
(id == DIAMETER_EAP) || \
(id == DIAMETER_Relay))
#define IPDIAMETER_VALID_COMMAND_CODE(code) ((code >= DIAMETER_CODE_MIN) && \
(code <= DIAMETER_CODE_MAX))
#define IPDIAMETER_MSEC(interval) (interval * 1000)
/*
****************************************************************************
* Public TYPES
****************************************************************************
*/
/*
*===========================================================================
* Ipdiameter_server
*===========================================================================
*/
/* Ipdiameter_server server types: 'server_type' */
typedef enum
{
DIAMETER_ACCESS_SERVER = 1,
DIAMETER_ACCOUNTING_SERVER,
DIAMETER_FULL_SERVER
} Ipdiameter_server_type;
typedef struct Ipdiameter_server_struct
{
union Ip_sockaddr_union server_addr; /* Server IPv4/v6 socket address union */
Ipdiameter_server_type server_type;
/* secret to be shared between the DIAMETER client and this server */
Ip_u8 shared_secret[IPDIAMETER_MAX_SECRET_SIZE];
/* length of the shared secret */
Ip_u32 shared_secret_len;
/* server's realm and hostname */
char realm[IPDIAMETER_MAX_FQDN_SIZE];
char hostname[IPDIAMETER_MAX_FQDN_SIZE];
}
Ipdiameter_server;
/*
*===========================================================================
* Ipdiameter_header
*===========================================================================
*/
#define IPDIAMETER_HDRSIZE 20
#define IPDIAMETER_VERSION 1
#define IPDIAMETER_R_FLAG 0x80
#define IPDIAMETER_P_FLAG 0x40
#define IPDIAMETER_E_FLAG 0x20
#define IPDIAMETER_T_FLAG 0x10
#define IPDIAMETER_RES_FLAG 0x0F /* Reserved bits */
typedef struct Ipdiameter_header_struct
{
/* DIAMETER packet header. */
Ip_u8 version;
Ip_u8 length[3];
Ip_u8 flags;
Ip_u8 code[3];
Ip_u32 appl_id;
Ip_u32 hbh_id;
Ip_u32 e2e_id;
Ip_u8 avp[1]; /* variable number/length attribute field. */
}
Ipdiameter_header;
/*
*===========================================================================
* Ipdiameter_AVP_header
*===========================================================================
*/
#define DIAMETER_AVP_V_FLAG 0x80
#define DIAMETER_AVP_M_FLAG 0x40
#define DIAMETER_AVP_P_FLAG 0x20
typedef struct Ipdiameter_AVP_header_struct
{
/* DIAMETER packet AVP header. */
Ip_u32 code;
Ip_u8 flags;
Ip_u8 length[3];
Ip_u32 vendor_id; /* optional field, present if V bit flag is set */
Ip_u8 data[1]; /* variable number/length data field, must be
multiple of 4 octets in length. */
}
Ipdiameter_AVP_header;
/*
*===========================================================================
* Ipdiameter_request
*===========================================================================
* The Ipdiameter_request structure is used for diameter applications to pass
* service specific request information and supply the user callback function
*/
/* pwd_type */
#define IPDIAMETER_No_Password 0
#define IPDIAMETER_PAP_Password 1
#define IPDIAMETER_CHAP_Password 2
typedef struct Ipdiameter_request_struct
{
void *cookie; /* handle for user callback. */
Ip_u32 unique; /* unique ID for each request to avoid spamming. */
/* will be used as the hop-by-hop id, and
end-to-end id at the request originating node */
Ip_err status; /* IPCOM_SUCCESS or IPCOM_ERR_FAILED. */
char session_id[IPDIAMETER_MAX_SESSION_ID_SIZE];
/* session id associated with the request. */
/* a string ends with "\0" */
/* session id should be formed as
local_host_FQDN;unique_ID
(refer to RFC 3588, section 8.8) */
Ip_u32 appl_id; /* Applicaiton ID, see RFC 3588, section 2.4 */
Ip_u32 pwd_type; /* password type: IPDIAMETER_PAP_Password,
IPDIAMETER_CHAP_Password,
IPDIAMETER_No_Password */
char pwd[IPDIAMETER_MAX_PASSWORD_SIZE]; /* password */
Ip_u32 pwd_len; /* length of password */
Ip_u8 chap_ident; /* CHAP response ID */
Ip_u8 pad[3]; /* Unused, padding for alignment reasons */
Ip_bool perform_re_auth;
/* whether to perform subseqent re-auth. */
/* (refer to draft-ietf-dime-rfc3588bits-xx,
section 8.3) */
/* Request event callback function pointer. */
Ip_err (*event_callback) (int event,
struct Ipdiameter_request_struct *request,
struct Ipdiameter_header *request_packet,
struct Ipdiameter_header *response_packet,
struct Ipdiameter_server *server) ;
/*
* The following server information is only required and has effect for
* the first request in a session. Do NOT fill Destination-Host and
* Destination-Realm AVPs in the Dimaeter packets for any subseqent
* requests in the session.
*/
Ip_s8 selected_server;
/* Application selected server */
/* -1 means application didn't select any server */
/* if set,Destination-Host and Destination-Realm */
/* AVPs must match if they are present in the */
/* Diameter packet. */
Ip_u8 num_servers; /* Number of valid entries in 'serv_list' below. */
/* User MUST supply at least one server, and no */
/* more than IPDIAMETER_MAX_SPECIFIED_SERVERS */
Ipdiameter_server serv_list[IPDIAMETER_MAX_SPECIFIED_SERVERS];
}
Ipdiameter_request;
/*
****************************************************************************
* LOCAL TYPES
****************************************************************************
*/
/*
*===========================================================================
* IPDIAMETER data
*===========================================================================
*/
typedef struct Ipdiameter_data_struct
{
Ip_bool opened;
#ifdef IPDIAMETER_ENABLE_REENTRANT
Ipcom_mutex code_mutex; /* Mutex to protect IPDIAMETER global data. */
#endif
/* session ID seed */
Ip_u64 session_id_seed;
/* Timer related configurable parameters in seconds */
Ip_u16 session_timeout;
Ip_u16 auth_lifetime;
Ip_u16 auth_grace_period;
Ip_u16 peer_reconn_interval;
Ip_u16 max_reconn_attemp;
Ip_u16 watchdog_timeout;
Ip_u16 req_retx_interval;
Ip_u16 max_req_retx;
/* local host/node info */
union Ip_sockaddr_union addr;
char host_id[IPDIAMETER_MAX_FQDN_SIZE];
char realm_id[IPDIAMETER_MAX_FQDN_SIZE];
Ipdiameter_peer_type node_type;
Ip_u16 tcp_port;
/* supported application list */
Ip_u32 appl_ids[IPDIAMETER_MAX_APPL_IDS];
Ip_u32 num_appls;
/* vendor ID */
Ip_u32 vendor_id;
/* whether to terminate a session when receiving an ASR */
Ip_bool ASR_comply;
/* TLS related data */
Ip_bool tls_enabled;
char *certfile;
char *keyfile;
char *keypasswd;
char *cacertfile;
char *rootdir;
SSL_CTX *ssl_ctx;
/* Priority queue with all timeouts */
Ipcom_pqueue *tmo_head;
/* Diameter node TCP listening socket */
#ifdef IPCOM_USE_INET
/* Diameter node IPv4 TCP socket descriptor.
* Set to IP_INVALID_SOCKET if request shall not talk to IPv4 servers. */
Ip_fd fd;
#endif
#ifdef IPCOM_USE_INET6
/* Diameter node IPv6 TCP socket descriptor.
* Set to IP_INVALID_SOCKET if request shall not talk to IPv6 servers. */
Ip_fd fd6;
#endif
/* Current sessions */
Ip_u32 session_num; /* number of sessions. */
Ipcom_list session_head;
/* peer list */
Ip_u32 peer_num; /* number of peers. */
Ipcom_list peer_head;
/* select fd list */
Ip_u32 fd_num; /* number of fds */
Ipcom_list fd_head;
/* the process that currently holds the semaphore and taken counter */
Ip_pid_t pid;
Ip_u8 s_counter;
/* route entry list */
Ip_u32 route_num; /* number of route entries. */
Ipcom_list route_head;
/* policy entry list */
Ip_u32 policy_num; /* number of policy entries. */
Ipcom_list policy_head;
/* Close and exit functions, node specific open function */
Ip_err (*close) (void);
Ip_err (*exit) (void);
Ip_err (*open) (void);
/* MIP4 HAR callback function */
void (*user_callback) (Ip_u32 code,
Ipdiameter_header *packet,
Ipdiameter_peer_entry *peer,
void *opaque_callback_data);
void *opaque_callback_data;
/* Syslog output memory. */
char buf[48];
}
Ipdiameter_data;
/*
*===========================================================================
* Ipdiameter_request_entry
*===========================================================================
*/
/* One for each request. Will be removed from request list (and thus no longer
* known to the protocol) once an answer has been received, or all servers
* have been tried.
*/
typedef struct Ipdiameter_request_entry_struct
{
Ipcom_list request_list;
/* seconds since the latest request packet was sent out */
Ip_time_t request_start_time;
/* timeout handler for request retransmission */
Ipcom_tmo2 retx_tmo;
Ip_u16 num_retx;
#ifdef IPDIAMETER_ENABLE_REENTRANT
Ipcom_mutex code_mutex; /* Mutex to protect request data. */
#endif
/* a diameter application request */
Ip_bool user_request;
/* the process that currently holds the semaphore and taken counter */
Ip_pid_t pid;
Ip_u8 s_counter;
Ipdiameter_session *session; /* session associated with request */
Ipdiameter_peer_entry *peer; /* peer associated with request */
Ipdiameter_agent_pending_packet_entry *agent_pkt_entry; /* pending packet entry. */
Ipdiameter_request request; /* User request structure. */
Ipdiameter_header hdr; /* DIAMETER packet.*/
}
Ipdiameter_request_entry;
/*
****************************************************************************
* Application APIs
****************************************************************************
*/
IP_PUBLIC Ipdiameter_header * ipdiameter_request_pkt_malloc(Ip_u32 length);
IP_PUBLIC Ip_err ipdiameter_request_pkt_free(Ipdiameter_header *packet);
IP_PUBLIC Ipdiameter_header * ipdiameter_answer_pkt_malloc(Ip_u32 length);
IP_PUBLIC Ip_err ipdiameter_answer_pkt_free(Ipdiameter_header *packet);
IP_PUBLIC void ipdiameter_set_hdr_code(Ip_u32 *packet, Ip_u32 code);
IP_PUBLIC Ip_u32 ipdiameter_get_hdr_code(Ip_u32 *packet);
IP_PUBLIC Ip_u32 ipdiameter_get_unique_id(void);
IP_PUBLIC Ip_err ipdiameter_get_session_id(char *session_id, Ip_u32 appl_id);
IP_PUBLIC Ip_err ipdiameter_get_avp(Ipdiameter_header *hdr, Ip_u32 avp_code,
Ip_u32 *data_length, Ip_u8 **data);
IP_PUBLIC Ip_err ipdiameter_avp_add_array(Ipdiameter_header *hdr,
Ip_u32 avp_code, Ip_u8 avp_flags, Ip_u32 *vendor_id,
Ip_u8 *data, Ip_u32 data_length);
IP_PUBLIC Ip_err ipdiameter_avp_add_u32(Ipdiameter_header *hdr, Ip_u32 avp_code,
Ip_u8 avp_flags, Ip_u32 *vendor_id, Ip_u32 data);
IP_PUBLIC Ip_err ipdiameter_avp_add_origin_host(Ipdiameter_header *message);
IP_PUBLIC Ip_err ipdiameter_avp_add_origin_realm(Ipdiameter_header *message);
IP_PUBLIC Ip_err ipdiameter_avp_add_host_address(Ipdiameter_header *message);
IP_PUBLIC Ip_err ipdiameter_avp_add_ip_address(Ipdiameter_header *message,
Ip_u32 avp_code, Ip_u8 avp_flags, Ip_u32 *vendor_id,
union Ip_sockaddr_union addr);
IP_PUBLIC Ip_err ipdiameter_avp_add_NAS_identifier(Ipdiameter_header *message);
IP_PUBLIC Ip_err ipdiameter_avp_get_session_id(Ipdiameter_header *message,
char *session_id);
IP_PUBLIC Ip_err ipdiameter_avp_change_u32(Ipdiameter_header *hdr,
Ip_u32 avp_code, Ip_u32 data);
IP_PUBLIC void * ipdiameter_avp_get_next(Ipdiameter_header *hdr, Ip_u8 *avp);
IP_PUBLIC Ip_err ipdiameter_grouped_avp_add_array(Ipdiameter_AVP_header *hdr,
Ip_u32 avp_code, Ip_u8 avp_flags, Ip_u32 *vendor_id,
Ip_u8 *data, Ip_u32 data_length);
IP_PUBLIC Ip_err ipdiameter_grouped_avp_add_u32(Ipdiameter_AVP_header *hdr,
Ip_u32 avp_code, Ip_u8 avp_flags, Ip_u32 *vendor_id,
Ip_u32 data);
IP_PUBLIC Ip_err ipdiameter_grouped_avp_get_avp(Ip_u8 *gavp_block,
Ip_u32 gavp_block_size, Ip_u32 avp_code,
Ip_u32 *data_length, Ip_u8 **data);
IP_PUBLIC void * ipdiameter_grouped_avp_get_next(Ip_u8 *gavp_block,
Ip_u32 gavp_block_size, Ip_u8 *avp);
IP_PUBLIC Ip_err ipdiameter_peer_pkt_send(Ipdiameter_peer_entry *peer,
Ipdiameter_header *package);
/*
****************************************************************************
* GLOBAL FUNCTIONS
****************************************************************************
*/
IP_PUBLIC Ip_err ipdiameter_common_create(Ipdiameter_peer_type node_type);
IP_PUBLIC Ip_err ipdiameter_common_open(void);
IP_PUBLIC Ip_err ipdiameter_common_start(char *proc_name);
IP_PUBLIC Ip_err ipdiameter_common_stop(void);
IP_PUBLIC Ip_err ipdiameter_common_close(void);
IP_PUBLIC Ip_err ipdiameter_common_exit(void);
IP_PUBLIC const char *ipdiameter_version(void);
IP_PUBLIC Ip_err ipdiameter_node_add_session(Ipdiameter_session *session);
IP_PUBLIC void ipdiameter_node_remove_session(Ipdiameter_session *session);
IP_PUBLIC Ip_err ipdiameter_node_add_peer(Ipdiameter_peer_entry *peer);
IP_PUBLIC void ipdiameter_node_remove_peer(Ipdiameter_peer_entry *peer);
IP_PUBLIC Ip_err ipdiameter_select_add_fd(Ip_fd fd, Ipdiameter_peer_entry *peer);
IP_PUBLIC Ip_err ipdiameter_select_del_fd(Ip_fd fd);
IP_PUBLIC void ipdiameter_set_wfd(Ip_fd fd);
IP_PUBLIC void ipdiameter_node_show_peer(void);
IP_PUBLIC void ipdiameter_node_show_session(void);
IP_PUBLIC void ipdiameter_node_show_config(void);
IP_PUBLIC void ipdiameter_node_show_route(void);
IP_PUBLIC void ipdiameter_node_show_policy(void);
IP_PUBLIC Ip_err ipdiameter_avp_check(Ipdiameter_header *hdr,
Ipdiameter_request_entry *reqent, Ip_u8 *errattr);
IP_PUBLIC void ipdiameter_set_hdr_length(Ip_u32 *packet, Ip_u32 length);
IP_PUBLIC Ip_u32 ipdiameter_get_hdr_length(Ip_u32 *packet);
IP_PUBLIC void ipdiameter_set_avp_length(Ip_u32 *avp, Ip_u32 length);
IP_PUBLIC Ip_u32 ipdiameter_get_avp_length(Ip_u32 *avp);
IP_PUBLIC Ip_bool ipdiameter_check_request_pending(Ipdiameter_request_entry *reqent);
IP_PUBLIC void ipdiameter_reqent_free(Ipdiameter_request_entry *reqent);
IP_PUBLIC Ipdiameter_request_entry *
ipdiameter_request_entry_find(Ipdiameter_header *hdr,
union Ip_sockaddr_union *from_addr);
IP_PUBLIC void ipdiameter_reqent_set_session(Ipdiameter_request_entry *reqent,
Ipdiameter_session *session);
IP_PUBLIC void ipdiameter_reqent_set_peer(Ipdiameter_request_entry *reqent,
Ipdiameter_peer_entry *peer);
IP_PUBLIC void ipdiameter_reqent_copy_req(Ipdiameter_request_entry *reqent,
Ipdiameter_request *request);
IP_PUBLIC Ip_err ipdiameter_pkt_send(Ip_fd fd, SSL *ssl,
Ipdiameter_header *package);
IP_PUBLIC Ip_err ipdiameter_request_pkt_send(Ipdiameter_request_entry *reqent,
Ip_bool start_timer);
IP_PUBLIC Ip_err ipdiameter_session_pkt_send(Ipdiameter_session *session,
Ipdiameter_header *package);
IP_PUBLIC Ip_err ipdiameter_send_ASA(Ipdiameter_session *session, Ip_fd fd,
SSL *ssl, Ipdiameter_header *ASR_package,
Ip_u32 result_code);
IP_PUBLIC Ip_err ipdiameter_send_STR(Ipdiameter_session *session, Ip_u32 cause);
IP_PUBLIC Ip_err ipdiameter_send_CER(Ipdiameter_peer_entry *peer);
IP_PUBLIC Ip_err ipdiameter_send_CEA(Ipdiameter_peer_entry *peer,
Ipdiameter_header *CER_package, Ip_u32 result_code);
IP_PUBLIC Ip_err ipdiameter_send_DWR(Ipdiameter_peer_entry *peer);
IP_PUBLIC Ip_err ipdiameter_send_DWA(Ipdiameter_peer_entry *peer,
Ipdiameter_header *DWR_package, Ip_u32 result_code);
IP_PUBLIC Ip_err ipdiameter_send_DPR(Ipdiameter_peer_entry *peer, Ip_u32 cause);
IP_PUBLIC Ip_err ipdiameter_send_DPA(Ipdiameter_peer_entry *peer,
Ipdiameter_header *DPR_package, Ip_u32 result_code);
IP_PUBLIC Ip_err ipdiameter_send_RAA(Ipdiameter_session *session, Ip_fd fd,
SSL *ssl, Ipdiameter_header *RAR_package,
Ip_u32 result_code);
IP_PUBLIC Ip_err ipdiameter_avp_add_appl_ids(Ipdiameter_header *message);
IP_PUBLIC Ip_err ipdiameter_ctrl_recv(Ip_fd fd);
IP_PUBLIC Ip_err ipdiameter_recv(Ip_fd fd, Ipdiameter_peer_entry *peer);
IP_PUBLIC Ip_err ipdiameter_read(Ip_fd fd, void *buf, Ip_size_t len,
Ipdiameter_peer_entry *peer);
IP_PUBLIC char * ipdiameter_addr_to_str(union Ip_sockaddr_union *addr);
IP_PUBLIC char * ipdiameter_errname(Ip_err err);
IP_PUBLIC void ipdiameter_pkt_set_starttime(Ipdiameter_header *package);
IP_PUBLIC Ip_err ipdiameter_pkt_start_timer(Ipdiameter_header *package);
IP_PUBLIC Ip_err ipdiameter_set_server(Ipdiameter_session *session);
IP_PUBLIC void ipdiameter_reset_tried_servers(Ipdiameter_session *session);
IP_PUBLIC Ip_bool ipdiameter_inaddr_equal(union Ip_sockaddr_union *addr1,
union Ip_sockaddr_union *addr2);
IP_PUBLIC void ipdiameter_attr_add_message_auth(Ipdiameter_request_entry
*reqent);
IP_PUBLIC void ipdiameter_password_insert(Ipdiameter_request_entry *reqent);
IP_PUBLIC void ipdiameter_print_pkt(Ipdiameter_header *packet);
IP_PUBLIC void ipdiameter_print_peer(Ipdiameter_peer_entry *peer);
IP_PUBLIC void ipdiameter_print_session(Ipdiameter_session *session);
IP_PUBLIC void ipdiameter_print_request(Ipdiameter_request *request);
IP_PUBLIC void ipdiameter_print_reqent(Ipdiameter_request_entry *reqent);
IP_PUBLIC void ipdiameter_print_route(Ipdiameter_route_entry *route);
IP_PUBLIC Ip_bool ipdiameter_routing_packet(Ipdiameter_header *packet,
Ipdiameter_peer_entry *peer);
IP_PUBLIC Ip_bool ipdiameter_rerouting_packet(Ipdiameter_header *packet,
Ipdiameter_peer_entry *peer);
IP_PUBLIC void ipdiameter_print_policy(Ipdiameter_policy_entry *policy);
IP_PUBLIC Ipdiameter_request_entry
*ipdiameter_agent_request_entry_find( Ipdiameter_peer_entry *peer,
Ipdiameter_header *hdr);
IP_PUBLIC Ip_bool
ipdiameter_agent_packet_response( Ipdiameter_request_entry *entry,
Ipdiameter_header *hdr);
IP_PUBLIC void ipdiameter_lck(void);
IP_PUBLIC void ipdiameter_unlck(void);
IP_PUBLIC void ipdiameter_request_lck(Ipdiameter_request_entry *reqent);
IP_PUBLIC void ipdiameter_request_unlck(Ipdiameter_request_entry *reqent);
#ifdef IPDIAMETER_ENABLE_REENTRANT
#ifdef IP_PORT_VXWORKS
#define IPDIAMETER_LOCK() ipcom_mutex_lock(ipdiameter.code_mutex)
#define IPDIAMETER_UNLOCK() ipcom_mutex_unlock(ipdiameter.code_mutex)
#define IPDIAMETER_REQUEST_LOCK(request) ipcom_mutex_lock(request->code_mutex)
#define IPDIAMETER_REQUEST_UNLOCK(request) ipcom_mutex_unlock(request->code_mutex)
#else /* !IP_PORT_VXWORKS, Linux recursive semaphore */
#define IPDIAMETER_LOCK() ipdiameter_lck()
#define IPDIAMETER_UNLOCK() ipdiameter_unlck()
#define IPDIAMETER_REQUEST_LOCK(request) ipdiameter_request_lck(request)
#define IPDIAMETER_REQUEST_UNLOCK(request) ipdiameter_request_unlck(request)
#endif /* IP_PORT_VXWORKS */
#else
#define IPDIAMETER_LOCK() IP_NOOP
#define IPDIAMETER_UNLOCK() IP_NOOP
#define IPDIAMETER_REQUEST_LOCK(request) IP_NOOP
#define IPDIAMETER_REQUEST_UNLOCK(request) IP_NOOP
#endif
#ifdef __cplusplus
}
#endif
#endif /* #ifndef IPDIAMETER_H */
/*
****************************************************************************
* END OF FILE
****************************************************************************
*/
@@ -0,0 +1,189 @@
/* ipdiameter_client.h - IPNet Diameter client header file */
/*
* Copyright (c) 2007 Wind River Systems, Inc.
*
* The right to copy, distribute or otherwise make use of this software
* may be licensed only pursuant to the terms of an applicable Wind River
* license agreement. No license to Wind River intellectual property rights
* is granted herein. All rights not licensed by Wind River are reserved
* by Wind River.
*/
/*
modification history
--------------------
01c,01aug07,tlu Add client specific open function
01b,13jun07,tlu Update after code review
01a,09apr07,tlu Created.
*/
#ifndef IPDIAMETER_CLIENT_H
#define IPDIAMETER_CLIENT_H
/*
****************************************************************************
* DESCRIPTION
****************************************************************************
* Header file for Diameter client
*/
/*
****************************************************************************
* INCLUDE FILES
****************************************************************************
*/
#include <ipcom_type.h>
#include "ipdiameter.h"
#ifdef __cplusplus
extern "C" {
#endif
/*
****************************************************************************
* Application APIs
****************************************************************************
*/
/*
*===========================================================================
* ipdiameter_access_request
*===========================================================================
* Description: Send out an access request message
* Parameters:
* Returns: IPCOM_SUCCESS or error code.
*
*/
IP_PUBLIC Ip_err ipdiameter_access_request(Ipdiameter_header *packet,
Ipdiameter_request *request, Ip_u8 *errattr);
/*
*===========================================================================
* ipdiameter_register_access_function
*===========================================================================
* Description: Register a user callback function
* Parameters:
* Returns:
*
*/
void ipdiameter_register_access_function(Ip_u32 code,
void (*callback) (Ip_u32 code,
Ipdiameter_header *packet,
Ipdiameter_peer_entry *peer,
void *opaque_callback_data),
void *opaque_callback_data);
/*
*===========================================================================
* ipdiameter_deregister_access_function
*===========================================================================
* Description: Deregister a user callback function
* Parameters:
* Returns:
*
*/
void ipdiameter_deregister_access_function(Ip_u32 code);
/*
****************************************************************************
* PUBLIC FUNCTIONS
****************************************************************************
*/
/*
*===========================================================================
* ipdiameterc_create
*===========================================================================
* Description: Initialize IPDIAMETER client global data 'ipdiameter'
* Parameters: .
* Returns: IPCOM_SUCCESS or error code.
*
*/
IP_PUBLIC Ip_err ipdiameterc_create(void);
/*
*===========================================================================
* ipdiameterc_exit
*===========================================================================
* Description: Release, i.e. free, temporary IPDIAMETER dynamic memory.
* Parameters: .
* Returns: .
*
*/
IP_PUBLIC Ip_err ipdiameterc_exit(void);
/*
*===========================================================================
* ipdiameterc_close
*===========================================================================
* Description: Close an opened IPDIAMETER.
* Parameters: .
* Returns: IPCOM_ERR_ALREADY_CLOSED - Failed to close since not open.
* IPCOM_SUCCESS - Success.
*
*/
IP_PUBLIC Ip_err ipdiameterc_close(void);
/*
*===========================================================================
* ipdiameterc_open
*===========================================================================
* Description: Open IPDIAMETER client: read in client specific
* configuration parameters.
* Parameters: .
* Returns: IPCOM_ERR_INVALID_CONFIG - invalid config parameters.
* IPCOM_SUCCESS - Success.
*
*/
IP_PUBLIC Ip_err ipdiameterc_open(void);
/*
*===========================================================================
* ipdiameterc_start
*===========================================================================
* Description: Start IPDIAMETER daemon.
* Parameters: .
* Returns: IPCOM_ERR_ALREADY_CLOSED - Failed to start the daemon.
* IPCOM_SUCCESS - Success.
*
*/
IP_PUBLIC Ip_err ipdiameterc_start(void);
/*
*===========================================================================
* ipdiameterc_stop
*===========================================================================
* Description: Stop IPDIAMETER daemon.
* Parameters: .
* Returns: IPCOM_ERR_NOT_STARTED - Failed to stop the daemon.
* IPCOM_SUCCESS - Success.
*
*/
IP_PUBLIC Ip_err ipdiameterc_stop(void);
#ifdef __cplusplus
}
#endif
#endif /*#ifndef IPDIAMETER_CLIENT_H*/
/*
****************************************************************************
* END OF FILE
****************************************************************************
*/
@@ -0,0 +1,619 @@
/* ipdiameter_constant.h - IPNet Diameter constants defining head file */
/*
* Copyright (c) 2007 Wind River Systems, Inc.
*
* The right to copy, distribute or otherwise make use of this software
* may be licensed only pursuant to the terms of an applicable Wind River
* license agreement. No license to Wind River intellectual property rights
* is granted herein. All rights not licensed by Wind River are reserved
* by Wind River.
*/
/*
modification history
--------------------
01j,19feb10,tlu Add VLAN attributes definition from RFC 4675
01i,12feb09,tlu Add/redefine some error codes from
draft-ietf-dime-rfc3588bis-xx
01h,09feb09,tlu Add callback event for RAR
01g,26nov08,tlu Add EAP appl id, command codes, and AVP codes
01f,18dec07,tlu Add a constant for maximum WD time outs
01e,04jul07,tlu Add MIP4 command codes and AVP codes
01d,27jun07,tlu Add Diameter Credit-Control application ID
01c,20jun07,tlu Add Re-Auth-Request-Type AVP value code
01b,13jun07,tlu Update after code inspection
01a,18apr07,tlu Created.
*/
#ifndef IPDIAMETER_CONSTANT_H
#define IPDIAMETER_CONSTANT_H
/*
****************************************************************************
* INCLUDE FILES
****************************************************************************
*/
/*
**************************************************************************
* DEFINES
****************************************************************************
*/
/* Diameter port */
#define IPDIAMETER_PORT 3868
/* Size of secret shared between DIAMETER nodes */
#define IPDIAMETER_MAX_SECRET_SIZE 64
/* Max size of user password. */
#define IPDIAMETER_MAX_PASSWORD_SIZE 128
/* Max size of a diameter message AVPs. */
#define IPDIAMETER_MAX_AVP_SIZE 1420
/* Max size of a FQDN */
#define IPDIAMETER_MAX_FQDN_SIZE 255
/* Max size a session ID (in the form of FQDN;unique_id) */
#define IPDIAMETER_MAX_SESSION_ID_SIZE 260
/* Max size of a diameter package. */
#define IPDIAMETER_MAX_PKT_SIZE 1440
/* Max authentication size */
#define IPDIAMETER_AUTH_SIZE 16
/* Max CHAP password length */
#define IPDIAMETER_CHAP_LEN 16
/* NULL string */
#define IPDIAMETER_NULL_STRING "\0"
/* Default session timeout value in seconds */
#define IPDIAMETER_SESSION_TIMEOUT 30
/* Default authorization lifetime value in seconds */
#define IPDIAMETER_AUTH_LIFETIME 360
/* Default authorization grace period value in seconds */
#define IPDIAMETER_AUTH_GRACE_PERIOD 30
/* Default peer reconnection interval in seconds */
#define IPDIAMETER_PEER_RECONN_INTERVAL 30
/* Default max peer reconnection attempts */
#define IPDIAMETER_MAX_PEER_RECONN_ATTEMPT 10
/* Default request retransmission interval in seconds */
#define IPDIAMETER_REQ_RETX_INTERVAL 10
/* Default max request retransmission attempts */
#define IPDIAMETER_MAX_REQ_RETX 3
/* Maximum opened sockets */
#define IPDIAMETER_MAX_FDS 20
/* Maximum peers */
#define IPDIAMETER_MAX_PEERS 20
/* Maximum sessions */
#define IPDIAMETER_MAX_SESSIONS 30
/* Maximum supported applications */
#define IPDIAMETER_MAX_APPL_IDS 10
/* Maximum servers a user can specify */
#define IPDIAMETER_MAX_SPECIFIED_SERVERS 3
/* Maximum route entries for a Diameter node */
#define IPDIAMETER_MAX_ROUTE_ENTRIES 512
/* Maximum WD time outs */
#define IPDIAMETER_MAX_WD_TIMEOUT 2
/* IPDIAMETER product name */
#define IPDIAMETER_PRODUCT_NAME "WR Diameter"
/*
*===========================================================================
* DIAMETER header command codes
*===========================================================================
*/
#define DIAMETER_CODE_MIN 0
#define DIAMETER_CODE_MAX 16777213
#define DIAMETER_CODE_Abort_Session_Request 274
#define DIAMETER_CODE_Abort_Session_Answer 274
#define DIAMETER_CODE_Accounting_Request 271
#define DIAMETER_CODE_Accounting_Answer 271
#define DIAMETER_CODE_Capabilities_Exchange_Request 257
#define DIAMETER_CODE_Capabilities_Exchange_Answer 257
#define DIAMETER_CODE_Device_Watchdog_Request 280
#define DIAMETER_CODE_Device_Watchdog_Answer 280
#define DIAMETER_CODE_Disconnect_Peer_Request 282
#define DIAMETER_CODE_Disconnect_Peer_Answer 282
#define DIAMETER_CODE_Re_Auth_Request 258
#define DIAMETER_CODE_Re_Auth_Answer 258
#define DIAMETER_CODE_Session_Termination_Request 275
#define DIAMETER_CODE_Session_Termination_Answer 275
/* Diameter MIP4 Application, RFC4004 */
#define DIAMETER_CODE_AA_Mobile_Node_Request 260
#define DIAMETER_CODE_AA_Mobile_Node_Answer 260
#define DIAMETER_CODE_Home_Agent_MIP_Request 262
#define DIAMETER_CODE_Home_Agent_MIP_Answer 262
/* Diameter EAP Application, RFC4072 */
#define DIAMETER_CODE_EAP_Request 268
#define DIAMETER_CODE_EAP_Answer 268
/* RADIUS packet header codes */
#define IPRADIUS_CODE_Access_Request 1
#define IPRADIUS_CODE_Access_Accept 2
#define IPRADIUS_CODE_Access_Reject 3
#define IPRADIUS_CODE_Accounting_Request 4
#define IPRADIUS_CODE_Accounting_Response 5
#define IPRADIUS_CODE_Access_Challenge 11
/*
*===========================================================================
* DIAMETER application Identifier
*===========================================================================
*/
#define DIAMETER_Common_Message 0
#define DIAMETER_NASREQ 1
#define DIAMETER_MIP 2
#define DIAMETER_Base_Accounting 3
#define DIAMETER_Credit_Control 4
#define DIAMETER_EAP 5
#define DIAMETER_Relay 0xffffffff
/*
*===========================================================================
* DIAMETER AVP codes
*===========================================================================
* Refer to RFC 3588, section 4.5
*/
#define DIAMETER_AVP_CODE_MIN 1
#define DIAMETER_AVP_CODE_MAX 486
#define DIAMETER_AVP_CODE_Acct_Interim_Interval 85
#define DIAMETER_AVP_CODE_Accounting_Realtime_Reqired 483
#define DIAMETER_AVP_CODE_Acct_Multi_Session_Id 50
#define DIAMETER_AVP_CODE_Accounting_Record_Number 485
#define DIAMETER_AVP_CODE_Accounting_Record_Type 480
#define DIAMETER_AVP_CODE_Accounting_Session_Id 44
#define DIAMETER_AVP_CODE_Accounting_Sub_Session_Id 287
#define DIAMETER_AVP_CODE_Acct_Application_Id 259
#define DIAMETER_AVP_CODE_Auth_Application_Id 258
#define DIAMETER_AVP_CODE_Auth_Request_Type 274
#define DIAMETER_AVP_CODE_Authorization_Lifetime 291
#define DIAMETER_AVP_CODE_Auth_Grace_Period 276
#define DIAMETER_AVP_CODE_Auth_Session_State 277
#define DIAMETER_AVP_CODE_Re_Auth_Request_Type 285
#define DIAMETER_AVP_CODE_Class 25
#define DIAMETER_AVP_CODE_Destination_Host 293
#define DIAMETER_AVP_CODE_Destination_Realm 283
#define DIAMETER_AVP_CODE_Disconnect_Cause 273
#define DIAMETER_AVP_CODE_E2E_Sequence 300
#define DIAMETER_AVP_CODE_Error_Message 281
#define DIAMETER_AVP_CODE_Error_Reporting_Host 294
#define DIAMETER_AVP_CODE_Event_Timestamp 55
#define DIAMETER_AVP_CODE_Experimental_Result 297
#define DIAMETER_AVP_CODE_Experimental_Result_Code 298
#define DIAMETER_AVP_CODE_Failed_AVP 279
#define DIAMETER_AVP_CODE_Firmware_Revision 267
#define DIAMETER_AVP_CODE_Host_IP_Address 257
#define DIAMETER_AVP_CODE_Inband_Security_Id 299
#define DIAMETER_AVP_CODE_Multi_Round_Time_Out 272
#define DIAMETER_AVP_CODE_Origin_Host 264
#define DIAMETER_AVP_CODE_Origin_Realm 296
#define DIAMETER_AVP_CODE_Origin_State_Id 278
#define DIAMETER_AVP_CODE_Product_Name 269
#define DIAMETER_AVP_CODE_Proxy_Host 280
#define DIAMETER_AVP_CODE_Proxy_Info 284
#define DIAMETER_AVP_CODE_Proxy_State 33
#define DIAMETER_AVP_CODE_Redirect_Host 292
#define DIAMETER_AVP_CODE_Redirect_Host_Usage 261
#define DIAMETER_AVP_CODE_Redirect_Max_Cache_Time 262
#define DIAMETER_AVP_CODE_Result_Code 268
#define DIAMETER_AVP_CODE_Route_Record 282
#define DIAMETER_AVP_CODE_Session_Id 263
#define DIAMETER_AVP_CODE_Session_Timeout 27
#define DIAMETER_AVP_CODE_Session_Binding 270
#define DIAMETER_AVP_CODE_Session_Server_Failover 271
#define DIAMETER_AVP_CODE_Supported_Vendor_Id 265
#define DIAMETER_AVP_CODE_Termination_Cause 295
#define DIAMETER_AVP_CODE_User_Name 1
#define DIAMETER_AVP_CODE_Vendor_Id 266
#define DIAMETER_AVP_CODE_Vendor_Specific_App_Id 260
/* Diameter MIP4 AVP codes, RFC 4004 */
#define DIAMETER_AVP_CODE_MIP_Reg_Request 320
#define DIAMETER_AVP_CODE_MIP_Reg_Reply 321
#define DIAMETER_AVP_CODE_MIP_MN_AAA_Auth 322
#define DIAMETER_AVP_CODE_MIP_Mobile_Node_Address 333
#define DIAMETER_AVP_CODE_MIP_Home_Agent_Address 334
#define DIAMETER_AVP_CODE_MIP_Candidate_Home_Agent_Host 336
#define DIAMETER_AVP_CODE_MIP_Feature_Vector 337
#define DIAMETER_AVP_CODE_MIP_Auth_Input_Data_Length 338
#define DIAMETER_AVP_CODE_MIP_Authenticator_Length 339
#define DIAMETER_AVP_CODE_MIP_Authenticator_Offset 340
#define DIAMETER_AVP_CODE_MIP_MN_AAA_SPI 341
#define DIAMETER_AVP_CODE_MIP_Fileter_Rule 342
#define DIAMETER_AVP_CODE_MIP_FA_Challenge 344
#define DIAMETER_AVP_CODE_MIP_Originating_Foreign_AAA 347
#define DIAMETER_AVP_CODE_MIP_Home_Agent_Host 348
#define DIAMETER_AVP_CODE_MIP_FA_to_HA_SPI 318
#define DIAMETER_AVP_CODE_MIP_FA_to_MN_SPI 319
#define DIAMETER_AVP_CODE_MIP_HA_to_FA_SPI 323
#define DIAMETER_AVP_CODE_MIP_MN_to_FA_MSA 325
#define DIAMETER_AVP_CODE_MIP_FA_to_MN_MSA 326
#define DIAMETER_AVP_CODE_MIP_FA_to_HA_MSA 328
#define DIAMETER_AVP_CODE_MIP_HA_to_FA_MSA 329
#define DIAMETER_AVP_CODE_MIP_MN_to_HA_MSA 331
#define DIAMETER_AVP_CODE_MIP_HA_to_MN_MSA 332
#define DIAMETER_AVP_CODE_MIP_Nonce 335
#define DIAMETER_AVP_CODE_MIP_Session_Key 343
#define DIAMETER_AVP_CODE_MIP_Algorithm_Type 345
#define DIAMETER_AVP_CODE_MIP_Replay_Mode 346
#define DIAMETER_AVP_CODE_MIP_MSA_Lifetime 367
/* Diameter EAP AVP codes, RFC 4072 */
#define DIAMETER_AVP_CODE_EAP_Payload 462
#define DIAMETER_AVP_CODE_EAP_Reissued_Payload 463
#define DIAMETER_AVP_CODE_EAP_Master_Session_Key 464
#define DIAMETER_AVP_CODE_EAP_Key_Name 102
#define DIAMETER_AVP_CODE_EAP_Accounting_Auth_Method 465
/* Diameter Network Access Server Appl, RFC 4005 */
#define DIAMETER_AVP_CODE_Originating_Line_Info 94
#define DIAMETER_AVP_CODE_Tunneling 401
/*
*===========================================================================
* Radius Attribute tags
*===========================================================================
*/
#define RADIUS_ATTR_User_Name 1
#define RADIUS_ATTR_User_Password 2
#define RADIUS_ATTR_CHAP_Password 3
#define RADIUS_ATTR_NAS_IP_Address 4
#define RADIUS_ATTR_NAS_Port 5
#define RADIUS_ATTR_Service_Type 6
#define RADIUS_ATTR_Framed_Protocol 7
#define RADIUS_ATTR_Framed_IP_Address 8
#define RADIUS_ATTR_Framed_IP_Netmask 9
#define RADIUS_ATTR_Framed_Routing 10
#define RADIUS_ATTR_Filter_Id 11
#define RADIUS_ATTR_Framed_MTU 12
#define RADIUS_ATTR_Framed_Compression 13
#define RADIUS_ATTR_Login_IP_Host 14
#define RADIUS_ATTR_Login_Service 15
#define RADIUS_ATTR_Login_TCP_Port 16
#define RADIUS_ATTR_unassigned_17 17
#define RADIUS_ATTR_Reply_Message 18
#define RADIUS_ATTR_Callback_Number 19
#define RADIUS_ATTR_Callback_Id 20
#define RADIUS_ATTR_unassigned_21 21
#define RADIUS_ATTR_Framed_Route 22
#define RADIUS_ATTR_Framed_IPX_Network 23
#define RADIUS_ATTR_State 24
#define RADIUS_ATTR_Class 25
#define RADIUS_ATTR_Vendor_Specific 26
#define RADIUS_ATTR_Session_Timeout 27
#define RADIUS_ATTR_Idle_Timeout 28
#define RADIUS_ATTR_Termination_Action 29
#define RADIUS_ATTR_Called_Station_Id 30
#define RADIUS_ATTR_Calling_Station_Id 31
#define RADIUS_ATTR_NAS_Identifier 32
#define RADIUS_ATTR_Proxy_State 33
#define RADIUS_ATTR_Login_LAT_Service 34
#define RADIUS_ATTR_Login_LAT_Node 35
#define RADIUS_ATTR_Login_LAT_Group 36
#define RADIUS_ATTR_Framed_AppleTalk_Link 37
#define RADIUS_ATTR_Framed_AppleTalk_Network 38
#define RADIUS_ATTR_Framed_AppleTalk_Zone 39
#define RADIUS_ATTR_Acct_Status_Type 40
#define RADIUS_ATTR_Acct_Delay_Time 41
#define RADIUS_ATTR_Acct_Input_Octets 42
#define RADIUS_ATTR_Acct_Output_Octets 43
#define RADIUS_ATTR_Acct_Session_Id 44
#define RADIUS_ATTR_Acct_Authentic 45
#define RADIUS_ATTR_Acct_Session_Time 46
#define RADIUS_ATTR_Acct_Input_Packets 47
#define RADIUS_ATTR_Acct_Output_Packets 48
#define RADIUS_ATTR_Acct_Terminate_Cause 49
#define RADIUS_ATTR_Acct_Multi_Session_Id 50
#define RADIUS_ATTR_Acct_Link_Count 51
#define RADIUS_ATTR_Acct_Input_Gigawords 52
#define RADIUS_ATTR_Acct_Output_Gigawords 53
#define RADIUS_ATTR_unassigned_54 54
#define RADIUS_ATTR_Event_Timestamp 55
/* RADIUS VLAN attributes, RFC 4675 */
#define RADIUS_ATTR_Egress_VLANID 56
#define RADIUS_ATTR_Ingress_Filters 57
#define RADIUS_ATTR_Egress_VLAN_Name 58
#define RADIUS_ATTR_User_Priority_Table 59
#define RADIUS_ATTR_CHAP_Challenge 60
#define RADIUS_ATTR_NAS_Port_Type 61
#define RADIUS_ATTR_Port_Limit 62
#define RADIUS_ATTR_Login_LAT_Port 63
#define RADIUS_ATTR_Tunnel_Type 64
#define RADIUS_ATTR_Tunnel_Medium_Type 65
#define RADIUS_ATTR_Tunnel_Client_Endpoint 66
#define RADIUS_ATTR_Tunnel_Server_Endpoint 67
#define RADIUS_ATTR_Acct_Tunnel_Connection 68
#define RADIUS_ATTR_Tunnel_Password 69
#define RADIUS_ATTR_ARAP_Password 70
#define RADIUS_ATTR_ARAP_Features 71
#define RADIUS_ATTR_ARAP_Zone_Access 72
#define RADIUS_ATTR_ARAP_Security 73
#define RADIUS_ATTR_ARAP_Security_Data 74
#define RADIUS_ATTR_Password_Retry 75
#define RADIUS_ATTR_Prompt 76
#define RADIUS_ATTR_Connect_Info 77
#define RADIUS_ATTR_Configuration_Token 78
#define RADIUS_ATTR_EAP_Message 79
#define RADIUS_ATTR_Message_Authenticator 80
#define RADIUS_ATTR_Tunnel_Private_Group_ID 81
#define RADIUS_ATTR_Tunnel_Assignment_ID 82
#define RADIUS_ATTR_Tunnel_Preference 83
#define RADIUS_ATTR_ARAP_Challenge_Response 84
#define RADIUS_ATTR_Acct_Interim_Interval 85
#define RADIUS_ATTR_Acct_Tunnel_Packets_Lost 86
#define RADIUS_ATTR_NAS_Port_Id 87
#define RADIUS_ATTR_Framed_Pool 88
#define RADIUS_ATTR_unassigned_89 89
#define RADIUS_ATTR_Tunnel_Client_Auth_ID 90
#define RADIUS_ATTR_Tunnel_Server_Auth_ID 91
#define RADIUS_ATTR_NAS_IPv6_Address 95
#define RADIUS_ATTR_Framed_Interface_Id 96
#define RADIUS_ATTR_Framed_IPv6_Prefix 97
#define RADIUS_ATTR_Login_IPv6_Host 98
#define RADIUS_ATTR_Framed_IPv6_Route 99
#define RADIUS_ATTR_Framed_IPv6_Pool 100
/* other attribute constants */
#define RADIUS_TUNNEL_MEDIUM_TYPE_IPV4 1
/* RFC 3580, section 3.31, tunnel attribute constants */
#define RADIUS_TUNNEL_TYPE_VLAN 13
#define RADIUS_TUNNEL_MEDIUM_TYPE_8021X 802
#define DIAMETER_REAUTH_REQ_TYPE_AUTHORIZE_ONLY 0
#define DIAMETER_REAUTH_REQ_TYPE_AUTHORIZE_AUTHENTICATE 1
#define DIAMETER_REQ_TYPE_AUTHENTICATE_ONLY 1
#define DIAMETER_REQ_TYPE_AUTHORIZE_ONLY 2
#define DIAMETER_REQ_TYPE_AUTHORIZE_AUTHENTICATE 3
/*
*===========================================================================
* Service Type values
*===========================================================================
* Refer to RFC 4005, section 6.1
*/
#define SERVICE_TYPE_Login 1
#define SERVICE_TYPE_Framed 2
#define SERVICE_TYPE_Callback_Login 3
#define SERVICE_TYPE_Callback_Framed 4
#define SERVICE_TYPE_Outbound 5
#define SERVICE_TYPE_Administrative 6
#define SERVICE_TYPE_NAS_Prompt 7
#define SERVICE_TYPE_Authenticate_Only 8
#define SERVICE_TYPE_Callback_NAS_Prompt 9
#define SERVICE_TYPE_Call_Check 10
#define SERVICE_TYPE_Callback_Administrative 11
#define SERVICE_TYPE_Voice 12
#define SERVICE_TYPE_Fax 13
#define SERVICE_TYPE_Modem_Relay 14
#define SERVICE_TYPE_IAPP_Register 15
#define SERVICE_TYPE_IAPP_AP_Check 16
#define SERVICE_TYPE_Authorize_Only 17
/*
*===========================================================================
* Framed Compression values
*===========================================================================
* Refer to RFC 4005, section 6.10.4
*/
#define FRAMED_COMPRESSION_NONE 0
#define FRAMED_COMPRESSION_VJ 1
#define FRAMED_COMPRESSION_IPX 2
#define FRAMED_COMPRESSION_Stac_LZS 3
/*
*===========================================================================
* Framed Protocol values
*===========================================================================
* Refer to RFC 4005, section 6.10.1
*/
#define FRAMED_PROTOCOL_PPP 1
#define FRAMED_PROTOCOL_SLIP 2
#define FRAMED_PROTOCOL_ARAP 3
#define FRAMED_PROTOCOL_Gandalf 4
#define FRAMED_PROTOCOL_IPX 5
#define FRAMED_PROTOCOL_X75 6
/*
*===========================================================================
* Framed Routing values
*===========================================================================
* Refer to RFC 4005, section 6.10.2
*/
#define FRAMED_ROUTING_NONE 0
#define FRAMED_ROUTING_SEND 1
#define FRAMED_ROUTING_LST 2
#define FRAMED_ROUTING_SEND_LST 3
/*
*===========================================================================
* DIAMETER return codes
*===========================================================================
* Refer to RFC 3588, section 7.1
*/
/* Informational */
#define DIAMETER_MULTI_ROUND_AUTH 1001
/* Success */
#define DIAMETER_SUCCESS 2001
#define DIAMETER_LIMITED_SUCCESS 2002
/* Protocol Errors */
/* DIAMETER_COMMAND_UNSUPPORTED is redefined from
draft-ietf-dime-rfc3588bis-xx
#define DIAMETER_COMMAND_UNSUPPORTED 3001
*/
#define DIAMETER_UNABLE_TO_DELIVER 3002
#define DIAMETER_REALM_NOT_SERVED 3003
#define DIAMETER_TOO_BUSY 3004
#define DIAMETER_LOOP_DETECTED 3005
#define DIAMETER_REDIRECT_INDICATION 3006
#define DIAMETER_APPLICATION_UNSUPPORTED 3007
/* DIAMETER_INVALID_HDR_BITS, DIAMETER_INVALID_AVP_BITS, and
DIAMETER_UNKNOWN_PEER are redefined from
draft-ietf-dime-rfc3588bis-xx
#define DIAMETER_INVALID_HDR_BITS 3008
#define DIAMETER_INVALID_AVP_BITS 3009
#define DIAMETER_UNKNOWN_PEER 3010
*/
/* The following are added from draft-ietf-dime-rfc3588bis-xx */
#define DIAMETER_INVALID_BIT_IN_HEADER 3011
#define DIAMETER_INVALID_MESSAGE_LENGTH 3012
/* Transient Failures */
#define DIAMETER_AUTHENTICATION_REJECTED 4001
#define DIAMETER_OUT_OF_SPACE 4002
#define ELECTION_LOST 4003
/* Permanent Failures */
#define DIAMETER_AVP_UNSUPPORTED 5001
#define DIAMETER_UNKNOWN_SESSION_ID 5002
#define DIAMETER_AUTHORIZATION_REJECTED 5003
#define DIAMETER_INVALID_AVP_VALUE 5004
#define DIAMETER_MISSING_AVP 5005
#define DIAMETER_RESOURCES_EXCEEDED 5006
#define DIAMETER_CONTRADICTING_AVPS 5007
#define DIAMETER_AVP_NOT_ALLOWED 5008
#define DIAMETER_AVP_OCCURS_TOO_MANY_TIMES 5009
#define DIAMETER_NO_COMMON_APPLICATION 5010
#define DIAMETER_UNSUPPORTED_VERSION 5011
#define DIAMETER_UNABLE_TO_COMPLY 5012
/* DIAMETER_INVALID_BIT_IN_HEADER is redefined from
draft-ietf-dime-rfc3588bis-xx
#define DIAMETER_INVALID_BIT_IN_HEADER 5013
*/
#define DIAMETER_INVALID_AVP_LENGTH 5014
/* DIAMETER_INVALID_MESSAGE_LENGTH is redefined from
draft-ietf-dime-rfc3588bis-xx
#define DIAMETER_INVALID_MESSAGE_LENGTH 5015
*/
#define DIAMETER_INVALID_AVP_BIT_COMBO 5016
#define DIAMETER_NO_COMMON_SECURITY 5017
/* The following are added from draft-ietf-dime-rfc3588bis-xx */
#define DIAMETER_UNKNOWN_PEER 5018
#define DIAMETER_COMMAND_UNSUPPORTED 5019
#define DIAMETER_INVALID_HDR_BITS 5020
#define DIAMETER_INVALID_AVP_BITS 5021
/*
*===========================================================================
* C-API error values
*===========================================================================
*/
#define IPDIAMETER_ERROR_BASE 0
#define IPDIAMETER_ERR_UNSUPPORTED_TAG (IPDIAMETER_ERROR_BASE+0)
#define IPDIAMETER_ERR_UNKNOWN_PACKET_CODE (IPDIAMETER_ERROR_BASE+1)
#define IPDIAMETER_ERR_TOO_MANY_OUTSTANDING_REQUESTS (IPDIAMETER_ERROR_BASE+2)
#define IPDIAMETER_ERR_INVAL_PKT_ID (IPDIAMETER_ERROR_BASE+3)
#define IPDIAMETER_ERR_BAD_AUTHENTICATION (IPDIAMETER_ERROR_BASE+4)
#define IPDIAMETER_ERR_BAD_ATTRIBUTE (IPDIAMETER_ERROR_BASE+5)
#define IPDIAMETER_ERR_NO_SESSION (IPDIAMETER_ERROR_BASE+6)
#define IPDIAMETER_ERR_SECRET_TOO_LONG (IPDIAMETER_ERROR_BASE+7)
#define IPDIAMETER_ERR_INVAL_PWD_LEN (IPDIAMETER_ERROR_BASE+8)
#define IPDIAMETER_ERR_NO_SERVER_RESPONSE (IPDIAMETER_ERROR_BASE+9)
#define IPDIAMETER_ERR_INVAL_INTERIM_ACCT_INTERVAL (IPDIAMETER_ERROR_BASE+10)
#define IPDIAMETER_ERR_SECRET_TOO_SHORT (IPDIAMETER_ERROR_BASE+11)
#define IPDIAMETER_ERR_MISSING_CHAP_ATTR (IPDIAMETER_ERROR_BASE+12)
#define IPDIAMETER_ERR_INVAL_PWD_TYPE (IPDIAMETER_ERROR_BASE+13)
#define IPDIAMETER_ERR_NO_SERVER (IPDIAMETER_ERROR_BASE+14)
#define IPDIAMETER_ERR_DISCARDED_PACKET (IPDIAMETER_ERROR_BASE+15)
#define IPDIAMETER_ERR_DUPLICATE_INDEX (IPDIAMETER_ERROR_BASE+16)
#define IPDIAMETER_ERR_UNSUPPORTED_PACKET_CODE (IPDIAMETER_ERROR_BASE+17)
#define IPDIAMETER_ERR_CLOSED (IPDIAMETER_ERROR_BASE+18)
/*
*===========================================================================
* Diamter application event_callback() events
*===========================================================================
*/
#define IPDIAMETER_EVENT_ACCESS_ACCEPT 1 /* Received access accept. */
#define IPDIAMETER_EVENT_ACCESS_REJECT 2 /* Received access reject. */
#define IPDIAMETER_EVENT_ACCESS_CHALLENGE 3 /* Received access challenge. */
#define IPDIAMETER_EVENT_ACCOUNTING_RESPONSE 4 /* Received accounting response. */
#define IPDIAMETER_EVENT_ACCESS_TIMEOUT 5 /* Access request timeout. */
#define IPDIAMETER_EVENT_ACCESS_CANCELLED 6 /* Access request was cancelled. */
#define IPDIAMETER_EVENT_ACCOUNTING_TIMEOUT 7 /* Accounting request timeout. */
#define IPDIAMETER_EVENT_ACCOUNTING_CANCELLED 8 /* Accounting request was cancelled. */
#define IPDIAMETER_EVENT_ACCOUNTING_REQUEST 9 /* Sending accounting request. */
#define IPDIAMETER_EVENT_USER_DISCON 10 /* Disconnect user/device */
#define IPDIAMETER_EVENT_ASR 11 /* Received abort session req */
#define IPDIAMETER_EVENT_SESSION_DISCON 12 /* Session disconnected */
#define IPDIAMETER_EVENT_SESSION_DEL 13 /* Session deleted */
#define IPDIAMETER_EVENT_RAR 14 /* Received re-auth-req */
#endif /* #ifndef IPDIAMETER__CONSTANT_H */
/*
****************************************************************************
* END OF FILE
****************************************************************************
*/
@@ -0,0 +1,526 @@
/* ipdiameter_eap.h - Diameter EAP head file */
/*
* Copyright (c) 2007 Wind River Systems, Inc.
*
* The right to copy, distribute or otherwise make use of this software
* may be licensed only pursuant to the terms of an applicable Wind River
* license agreement. No license to Wind River intellectual property rights
* is granted herein. All rights not licensed by Wind River are reserved
* by Wind River.
*/
/*
modification history
--------------------
01e,20mar09,tlu Add re-auth field to Diameter EAP request structure
01d,12mar09,tlu Modified EAP callback function prototyping
01c,14jan09,tlu Added DER structure deallocation function
01b,09dec08,tlu Added auth cookie and callback function prototype
01a,03dec08,tlu Created.
*/
#ifndef IPDIAMETER_EAP_H
#define IPDIAMETER_EAP_H
/*
****************************************************************************
* INCLUDE FILES
****************************************************************************
*/
#include <ipcom_tags.h>
#include <ipcom_type.h>
#include <ipcom_sock.h>
#include <ipcom_sock6.h>
#include <ipcom_list.h>
#include <ipcom_tmo2.h>
#include "ipdiameter_config.h"
#include <ipdiameter_constant.h>
#include <ipdiameter.h>
/*
****************************************************************************
* DEFINES
****************************************************************************
*/
#ifdef __cplusplus
extern "C" {
#endif
/*
****************************************************************************
* Public TYPES
****************************************************************************
*/
/*
*===========================================================================
* Ipdiameter_tunneling
*===========================================================================
* This defines grouped tunneling AVP structure.
*/
typedef struct Ipdiameter_tunneling_struct
{
/* Tunnel-Type (must have) */
Ip_bool set_tunnel_type;
Ip_u32 tunnel_type;
/* Tunnel-Medium-Type (must have) */
Ip_bool set_tunnel_medium_type;
Ip_u32 tunnel_medium_type;
/* Tunnel-Client-Endpoint (must have) */
char *client_endpoint;
/* Tunnel-Server-Endpoint (must have) */
char *server_endpoint;
/* Tunnel-Preference (must have) */
Ip_bool set_tunnel_preference;
Ip_u32 tunnel_preference;
/* Tunnel-Client-Auth-Id (must have) */
char *client_auth_id;
/* Tunnel-Server-Auth-Id (must have) */
char *server_auth_id;
/* Tunnel-Assignment-Id (must have) */
char *assignment_id;
/* Tunnel-Password (must have) */
char *password;
/* Tunnel-Private-Group-Id (must have) */
char *private_group_id;
} Ipdiameter_tunneling;
/*
*===========================================================================
* Ipdiameter_customized_avp
*===========================================================================
* This defines customized AVP structure.
*/
typedef struct Ipdiameter_customized_avp_struct
{
Ipcom_list avp_list;
Ip_u8 flag; /* AVP flags */
Ip_u16 code; /* AVP code */
Ip_bool set_vendor_id;
Ip_u32 vendor_id; /* AVP vendor id: optional field,
present if V bit flag is set */
Ip_bool grouped_avp; /* Is a grouped AVP or not */
Ip_u8 *buf; /* AVP data: variable number/length
data field, must be multiple of
4 octets in length. */
} Ipdiameter_customized_avp;
/*
*===========================================================================
* Ipdiameter_eap_der
*===========================================================================
*/
typedef struct Ipdiameter_eap_der_struct
{
/* session-id (must have) */
char session_id[IPDIAMETER_MAX_SESSION_ID_SIZE];
/* dest-realm (optional in DER structure). If present, set */
/* the selected server in Diameter request structure to */
/* match this value */
char dest_realm[IPDIAMETER_MAX_FQDN_SIZE];
/* dest-host (optional). Same comment for dest-realm */
char dest_hostname[IPDIAMETER_MAX_FQDN_SIZE];
/* port-limit (optional) */
Ip_bool set_port_limit;
Ip_u32 port_limit;
/* user-name (optional) */
char user_name[IPDIAMETER_MAX_FQDN_SIZE];
/* eap-payload (must have) */
Ip_u16 eap_payload_length;
Ip_u8 *eap_payload;
/* eap-key-name (optional) */
char *eap_key_name;
/* service-type (optional) */
Ip_bool set_service_type;
Ip_u32 service_type;
/* state (optional) */
char *state;
/* authorization-lifetime (optinal) */
Ip_bool set_authorization_lifetime;
Ip_u32 authorization_lifetime;
/* auth-grace-period (optinal) */
Ip_bool set_auth_grace_period;
Ip_u32 auth_grace_period;
/* auth-session-state (optinal) */
Ip_bool set_auth_session_state;
Ip_u32 auth_session_state;
/* callback-number (optional) */
char *callback_number;
/* called-station-id (optional) */
char *called_station_id;
/* calling-station-id (optional) */
char *calling_station_id;
/* originating-line-info (optinal) */
char *originating_line_info;
/* connect-info (optinal) */
char *connect_info;
/* framed-compression (optional) */
Ip_bool set_framed_compression;
Ip_u32 framed_compression;
/* framed-interface-id (optional) */
Ip_bool set_framed_interface_id;
Ip_u64 framed_interface_id;
/* Framed-IP-Address (optional) */
char *framed_ip_address;
/* Framed-IPv6-Prefix (optional) */
char *framed_ipv6_prefix;
/* Framed-IP-Netmask (optional) */
char *framed_ip_netmask;
/* Framed-MTU (optional) */
Ip_bool set_framed_mtu;
Ip_u32 framed_mtu;
/* Framed-Protocol (optional) */
Ip_bool set_framed_protocol;
Ip_u32 framed_protocol;
/* grouped AVP -- Tunneling (optional) */
Ip_bool set_tunneling;
Ipdiameter_tunneling tunneling;
/* customized AVPs (optional) */
Ip_bool set_customized_avp;
Ipcom_list customized_avp_head;
}
Ipdiameter_eap_der;
/*
*===========================================================================
* Ipdiameter_eap_dea
*===========================================================================
*/
typedef struct Ipdiameter_eap_dea_struct
{
/* hop-by-hop id (must have) in Diameter header, RFC 3588, section 3 */
Ip_u32 hbh_id;
/* end-to-end id (must have) in Diameter header, RFC 3588, section 3 */
Ip_u32 e2e_id;
/* session-id (must have) */
char session_id[IPDIAMETER_MAX_SESSION_ID_SIZE];
/* user-name (optional) */
char user_name[IPDIAMETER_MAX_FQDN_SIZE];
/* eap-payload (optional) */
Ip_u16 eap_payload_length;
Ip_u8 *eap_payload;
/* eap-reissued-payload (optional) */
Ip_u16 eap_reissued_payload_length;
Ip_u8 *eap_reissued_payload;
/* eap-master_session_key (optional) */
char eap_master_session_key[IPDIAMETER_MAX_SESSION_ID_SIZE];
/* eap-key-name (optional) */
char *eap_key_name;
/* multi-round-time-out (optional) */
Ip_bool set_multi_round_time_out;
Ip_u32 multi_round_time_out;
/* accounting-eap-auth-method (optional) */
Ip_bool set_accounting_auth_method;
Ip_u64 accounting_auth_method;
/* service-type (optional) */
Ip_bool set_service_type;
Ip_u32 service_type;
/* class (optional) */
char *class_value;
/* configuration-token (optional) */
char *configuration_token;
/* acct-interim-interval (optional) */
Ip_bool set_acct_interim_interval;
Ip_u32 acct_interim_interval;
/* error-message (optional) */
char *error_message;
/* error-reporting-host (optional) */
char *error_reporting_host;
/* idle-timeout (optional) */
Ip_bool set_idle_timeout;
Ip_u32 idle_timeout;
/* authorization-lifetime (optional) */
Ip_bool set_authorization_lifetime;
Ip_u32 authorization_lifetime;
/* auth-grace-period (optional) */
Ip_bool set_auth_grace_period;
Ip_u32 auth_grace_period;
/* auth-session-state (optional) */
Ip_bool set_auth_session_state;
Ip_u32 auth_session_state;
/* re-auth-request-type (optional) */
Ip_bool set_re_auth_request_type;
Ip_u32 re_auth_request_type;
/* session-timeout (optional) */
Ip_bool set_session_timeout;
Ip_u32 session_timeout;
/* state (optional) */
char *state;
/* reply-message (optional) */
char *reply_message;
/* filter-id (optional) */
char *filter_id;
/* port-limit (optional) */
Ip_bool set_port_limit;
Ip_u32 port_limit;
/* callback-id (optional) */
char *callback_id;
/* callback-number (optional) */
char *callback_number;
/* framed-appletalk-link (optional) */
Ip_bool set_framed_appletalk_link;
Ip_u32 framed_appletalk_link;
/* framed-appletalk-network (optional) */
Ip_bool set_framed_appletalk_network;
Ip_u32 framed_appletalk_network;
/* framed-appletalk-zone (optional) */
char *framed_appletalk_zone;
/* framed-compression (optional) */
Ip_bool set_framed_compression;
Ip_u32 framed_compression;
/* framed-interface-id (optional) */
Ip_bool set_framed_interface_id;
Ip_u32 framed_interface_id;
/* framed-ip-address (optional) */
char *framed_ip_address;
/* framed-ipv6-prefix (optional) */
char *framed_ipv6_prefix;
/* framed-ipv6-pool (optional) */
char *framed_ipv6_pool;
/* framed-ipv6-route (optional) */
char *framed_ipv6_route;
/* framed-ip-netmask (optional) */
char *framed_ip_netmask;
/* framed-route (optional) */
char *framed_route;
/* framed-pool (optional) */
char *framed_pool;
/* framed-IPX-network (optional) */
Ip_bool set_framed_ipx_network;
Ip_u32 framed_ipx_network;
/* framed-MTU (optional) */
Ip_bool set_framed_mtu;
Ip_u32 framed_mtu;
/* framed-protocol (optional) */
Ip_bool set_framed_protocol;
Ip_u32 framed_protocol;
/* framed-routing (optional) */
Ip_bool set_framed_routing;
Ip_u32 framed_routing;
/* grouped AVP -- Tunneling (optional) */
Ip_bool set_tunneling;
Ipdiameter_tunneling tunneling;
/* customized AVPs (optional) */
Ip_bool set_customized_avp;
Ipcom_list customized_avp_head;
}
Ipdiameter_eap_dea;
/*
*===========================================================================
* Ipdiameter_eap_auth_cookie
*===========================================================================
*/
typedef Ip_err (*Ipdiameter_eap_callback_func_t)
(int event,
void *eap_context,
struct Ipdiameter_request_struct *req,
struct Ipdiameter_header *request_pkt,
struct Ipdiameter_header *reply_pkt);
typedef struct Ipdiameter_eap_auth_cookie_struct
{
/* EAP context associated with the request */
void *eap_context;
/* Result code from the request */
Ip_err retval;
/* EAP callback function */
Ipdiameter_eap_callback_func_t callback;
}
Ipdiameter_eap_auth_cookie;
/*
*===========================================================================
* Ipdiameter_eap_request
*===========================================================================
* Diameter EAP request structure for EAP authenticator to pass in service
* specific request information and supply the EAP callback function
*/
typedef struct Ipdiameter_eap_request_struct
{
/* EAP context associated with the request */
void *eap_context;
/* EAP callback function */
Ipdiameter_eap_callback_func_t callback;
/* Password information */
Ip_u32 pwd_type; /* password type:
IPDIAMETER_PAP_Password,
IPDIAMETER_CHAP_Password,
IPDIAMETER_No_Password */
char pwd[IPDIAMETER_MAX_PASSWORD_SIZE]; /* password */
Ip_u32 pwd_len; /* length of password */
Ip_u8 chap_ident; /* CHAP response ID */
Ip_u8 pad[3]; /* Unused, padding for alignment reasons */
/* server initiated re-auth request */
Ip_bool perform_re_auth;
/* whether to perform subseqent re-auth. */
/* (refer to draft-ietf-dime-rfc3588bits-xx,
section 8.3) */
/* DER data info to format DER package */
Ipdiameter_eap_der *der_data;
/*
* The following server information is only required and has effect for
* the first request in a session. Do NOT fill Destination-Host and
* Destination-Realm AVPs in the Dimaeter packets for any subseqent
* requests in the session.
*/
Ip_s8 selected_server;
/* Application selected server */
/* -1 means application didn't select any server */
/* if set,Destination-Host and Destination-Realm */
/* AVPs must match if they are present in the */
/* Diameter packet. */
Ip_u8 num_servers;
/* Number of valid entries in 'serv_list' below. */
/* User MUST supply at least one server, and no */
/* more than IPDIAMETER_MAX_SPECIFIED_SERVERS */
Ipdiameter_server serv_list[IPDIAMETER_MAX_SPECIFIED_SERVERS];
}
Ipdiameter_eap_request;
/*
****************************************************************************
* GLOBAL FUNCTIONS
****************************************************************************
*/
/*
****************************************************************************
* Application APIs
****************************************************************************
*/
IP_PUBLIC Ip_err ipdiameter_eap_access_request(
Ipdiameter_eap_request *diameter_eap_req);
IP_PUBLIC void ipdiameter_eap_free_DER(Ipdiameter_eap_der *der_data);
#ifdef __cplusplus
}
#endif
#endif /* #ifndef IPDIAMETER_EAP_H */
/*
****************************************************************************
* END OF FILE
****************************************************************************
*/
@@ -0,0 +1,149 @@
/* ipdiameter_pagent.h - Diameter proxy agent header file */
/*
* Copyright (c) 2007 Wind River Systems, Inc.
*
* The right to copy, distribute or otherwise make use of this software
* may be licensed only pursuant to the terms of an applicable Wind River
* license agreement. No license to Wind River intellectual property rights
* is granted herein. All rights not licensed by Wind River are reserved
* by Wind River.
*/
/*
modification history
--------------------
01c,12nov07,tlu Add open() function for proxy agent
01b,09nov07,tlu Remove unnecessary APIs
01a,16jul07,cwu Created.
*/
#ifndef IPDIAMETER_PAGENT_H
#define IPDIAMETER_PAGENT_H
/*
****************************************************************************
* DESCRIPTION
****************************************************************************
* Header file for Diameter proxy agent
*/
/*
****************************************************************************
* INCLUDE FILES
****************************************************************************
*/
#include <ipcom_type.h>
#include "ipdiameter.h"
/*
****************************************************************************
* Application APIs
****************************************************************************
*/
#ifdef __cplusplus
extern "C" {
#endif
/*
****************************************************************************
* PUBLIC FUNCTIONS
****************************************************************************
*/
/*
*===========================================================================
* ipdiameterp_create
*===========================================================================
* Description: Initialize IPDIAMETER proxy agent global data 'ipdiameter'
* Parameters: .
* Returns: IPCOM_SUCCESS or error code.
*
*/
IP_PUBLIC Ip_err ipdiameterp_create(void);
/*
*===========================================================================
* ipdiameterp_exit
*===========================================================================
* Description: Release, i.e. free, temporary IPDIAMETER dynamic memory.
* Parameters: .
* Returns: .
*
*/
IP_PUBLIC Ip_err ipdiameterp_exit(void);
/*
*===========================================================================
* ipdiameterp_close
*===========================================================================
* Description: Close an opened IPDIAMETER.
* Parameters: .
* Returns: IPCOM_ERR_ALREADY_CLOSED - Failed to close since not open.
* IPCOM_SUCCESS - Success.
*
*/
IP_PUBLIC Ip_err ipdiameterp_close(void);
/*
*===========================================================================
* ipdiameterp_open
*===========================================================================
* Description: Open IPDIAMETER proxy agent: read in proxy agent specific
* configuration parameters.
* Parameters: .
* Returns: IPCOM_ERR_INVALID_CONFIG - invalid config parameters.
* IPCOM_SUCCESS - Success.
*
*/
IP_PUBLIC Ip_err ipdiameterp_open(void);
/*
*===========================================================================
* ipdiameterp_start
*===========================================================================
* Description: Start IPDIAMETER daemon.
* Parameters: .
* Returns: IPCOM_ERR_ALREADY_CLOSED - Failed to start the daemon.
* IPCOM_SUCCESS - Success.
*
*/
IP_PUBLIC Ip_err ipdiameterp_start(void);
/*
*===========================================================================
* ipdiameterp_stop
*===========================================================================
* Description: Stop IPDIAMETER daemon.
* Parameters: .
* Returns: IPCOM_ERR_NOT_STARTED - Failed to stop the daemon.
* IPCOM_SUCCESS - Success.
*
*/
IP_PUBLIC Ip_err ipdiameterp_stop(void);
#ifdef __cplusplus
}
#endif
#endif /*#ifndef IPDIAMETER_PAGENT_H*/
/*
****************************************************************************
* END OF FILE
****************************************************************************
*/
@@ -0,0 +1,416 @@
/* ipdiameter_peer.h - IPNet Diameter peer head file */
/*
* Copyright (c) 2007 Wind River Systems, Inc.
*
* The right to copy, distribute or otherwise make use of this software
* may be licensed only pursuant to the terms of an applicable Wind River
* license agreement. No license to Wind River intellectual property rights
* is granted herein. All rights not licensed by Wind River are reserved
* by Wind River.
*/
/*
modification history
--------------------
01j,04feb09,tlu Remove peer R_RCV_CEA and I_RCV_CER events
01i,17apr08,tlu Add compile condition to call ipcom mutex utilities directly
for VxWorks, and call recursive semaphore for Linux
01h,07dec07,tlu Rename ipdiameter_peer_add_session_pkt() to
ipdiameter_peer_add_tx_pending_pkt() for agent handling
01g,21nov07,tlu Add realm based peer route selection
01f,09oct07,tlu Port to Linux
01e,24sep07,tlu Add function to reset a peer state to CLOSED
01d,14aug07,tlu Add peer failure handling
01c,08aug07,tlu Add TLS support
01b,27jun07,tlu Add application IDs to peer entry structure
01a,03may07,tlu Created.
*/
#ifndef IPDIAMETER_PEER_H
#define IPDIAMETER_PEER_H
/*
****************************************************************************
* INCLUDE FILES
****************************************************************************
*/
#include <ipcom_tags.h>
#include <ipcom_type.h>
#include <ipcom_sock.h>
#include <ipcom_sock6.h>
#include <ipcom_list.h>
#include <ipcom_tmo2.h>
#ifdef IPSSL
#include <openssl/ssl.h>
#endif /* IPSSL */
#include <ipdiameter_config.h>
#include <ipdiameter_constant.h>
/*
****************************************************************************
* DEFINES
****************************************************************************
*/
#define IPDIAMETER_ENABLE_REENTRANT
#define IPDIAMETER_MAX_PEER_PENDING_PKTS 100
#define IPDIAMETER_DYNAMIC_PEER_EXPIRATION 30
#define IPDIAMETER_PEER_MAX_FAILS 5
/*
*===========================================================================
* Peer state machine events
*===========================================================================
* refer to RFC 3588, section 5.6 and 5.6.2
*/
typedef enum
{
DIAMETER_PEER_EV_START = 1,
DIAMETER_PEER_EV_R_CONN_CER,
DIAMETER_PEER_EV_I_RCV_CONN_ACK,
DIAMETER_PEER_EV_I_RCV_CONN_NACK,
DIAMETER_PEER_EV_TIMEOUT,
DIAMETER_PEER_EV_R_RCV_CER,
DIAMETER_PEER_EV_I_RCV_CEA,
DIAMETER_PEER_EV_I_RCV_NON_CEA,
DIAMETER_PEER_EV_I_PEER_DISC,
DIAMETER_PEER_EV_R_PEER_DISC,
DIAMETER_PEER_EV_R_RCV_DPR,
DIAMETER_PEER_EV_I_RCV_DPR,
DIAMETER_PEER_EV_R_RCV_DPA,
DIAMETER_PEER_EV_I_RCV_DPA,
DIAMETER_PEER_EV_WIN_ELECTION,
DIAMETER_PEER_EV_SEND_MESSAGE,
DIAMETER_PEER_EV_R_RCV_MESSAGE,
DIAMETER_PEER_EV_I_RCV_MESSAGE,
DIAMETER_PEER_EV_STOP,
DIAMETER_PEER_EV_R_RCV_DWR,
DIAMETER_PEER_EV_I_RCV_DWR,
DIAMETER_PEER_EV_R_RCV_DWA,
DIAMETER_PEER_EV_I_RCV_DWA
} Ipdiameter_peer_events;
/*
*===========================================================================
* Peer states
*===========================================================================
* refer to RFC 3588, section 5.6
*/
typedef enum
{
DIAMETER_PEER_STATE_FAILED = 0,
DIAMETER_PEER_STATE_CLOSED,
DIAMETER_PEER_STATE_WAIT_CONN_ACK,
DIAMETER_PEER_STATE_WAIT_I_CEA,
DIAMETER_PEER_STATE_WAIT_CONN_ACK_ELECT,
DIAMETER_PEER_STATE_WAIT_RETURNS,
DIAMETER_PEER_STATE_R_OPEN,
DIAMETER_PEER_STATE_I_OPEN,
DIAMETER_PEER_STATE_CLOSING
} Ipdiameter_peer_state;
/*
*===========================================================================
* Peer types
*===========================================================================
*/
typedef enum
{
DIAMETER_PEER_UNKNOWN = 0,
DIAMETER_PEER_ACCESS_SERVER,
DIAMETER_PEER_ACCOUNTING_SERVER,
DIAMETER_PEER_FULL_SERVER,
DIAMETER_PEER_CLIENT,
DIAMETER_PEER_RELAY_AGENT,
DIAMETER_PEER_REDIRECT_AGENT,
DIAMETER_PEER_PROXY_AGENT,
DIAMETER_PEER_TRANSLATION_AGENT
} Ipdiameter_peer_type;
/*
*===========================================================================
* Peer disconnect causes
*===========================================================================
* refer to RFC 3588, section 5.4.3
*/
typedef enum
{
DIAMETER_PEER_REBOOTING = 0,
DIAMETER_PEER_BUSY,
DIAMETER_PEER_DO_NOT_WANT_TO_TALK_TO_YOU
} Ipdiameter_peer_disconnect_cause;
/*
****************************************************************************
* TYPES
****************************************************************************
*/
#ifdef __cplusplus
extern "C" {
#endif
/*
*===========================================================================
* Ipdiameter_peer
*===========================================================================
* This is user interface structure to add/delete the peers
*/
typedef struct Ipdiameter_peer_struct
{
union Ip_sockaddr_union peer_addr; /* Peer IPv4/v6 socket address union. */
/* Peer node information */
Ipdiameter_peer_type node_type;
char realm[IPDIAMETER_MAX_FQDN_SIZE];
/* This parameter is optional */
char hostname[IPDIAMETER_MAX_FQDN_SIZE];
/* static or dynamic, IP_TRUE if a dynamic entry */
Ip_bool dynamic;
/* tls enabled */
Ip_bool tls;
/* the socket used to send/receive data with the peer */
#ifdef IPCOM_USE_INET
/* Diameter peer IPv4 TCP socket descriptor.
* Set to IP_INVALID_SOCKET if shall not talk to IPv4 peer. */
Ip_fd fd;
#endif
#ifdef IPCOM_USE_INET6
/* Diameter peer IPv6 TCP socket descriptor.
* Set to IP_INVALID_SOCKET if shall not talk to IPv6 peer. */
Ip_fd fd6;
#endif
/* peer state */
Ipdiameter_peer_state state;
/* security parameters */
Ip_tag conf[1]; /* None available, included for future compability. */
}
Ipdiameter_peer;
/*
*===========================================================================
* Ipdiameter_peer_entry
*===========================================================================
* refer to RFC 3588, section 5
*/
struct Ipdiameter_header;
typedef struct Ipdiameter_peer_entry_struct
{
Ipcom_list peer_list;
/* seconds since this peer was added */
Ip_time_t start_time;
/* timeout handler for reconnection attempt */
Ipcom_tmo2 reconn_tmo;
Ip_u16 num_reconn;
/* timeout handler for watchdog timeout */
Ipcom_tmo2 watchdog_tmo;
Ip_bool wd_responded;
Ip_u16 num_fail;
/* timeout handler for dynamic peer expiration */
Ipcom_tmo2 expire_tmo;
union Ip_sockaddr_union peer_addr; /* Peer IPv4/v6 socket address union. */
/* the socket used to send/receive data with the peer */
#ifdef IPCOM_USE_INET
/* Diameter peer IPv4 TCP socket descriptor.
* Set to IP_INVALID_SOCKET if shall not talk to IPv4 peer. */
Ip_fd fd;
#endif
#ifdef IPCOM_USE_INET6
/* Diameter peer IPv6 TCP socket descriptor.
* Set to IP_INVALID_SOCKET if shall not talk to IPv6 peer. */
Ip_fd fd6;
#endif
Ipdiameter_peer_type node_type;
char realm[IPDIAMETER_MAX_FQDN_SIZE];
char hostname[IPDIAMETER_MAX_FQDN_SIZE];
/* peer state */
Ipdiameter_peer_state state;
/* failure counter */
Ip_u16 fail_counter;
/* static or dynamic, IP_TRUE if a dynamic entry */
Ip_bool dynamic;
/* expiration time, valid only for a dynamic entry */
Ip_time_t expiration_time;
/* connection initiator or responder */
Ip_bool initiator;
/* tls enabled */
Ip_bool tls;
SSL *ssl;
/* peer capabilities */
Ip_u32 appl_ids[IPDIAMETER_MAX_APPL_IDS];
Ip_u32 num_appls;
/* the process that currently holds the semaphore and taken counter */
Ip_pid_t pid;
Ip_u8 s_counter;
/* security parameters */
#ifdef IPDIAMETER_ENABLE_REENTRANT
Ipcom_mutex code_mutex; /* Mutex to protect IPDIAMETER peer data. */
#endif
/* requests associated with this peer: of type CER, DPR, and DWR */
Ip_u32 request_num; /* number of requests. */
Ipcom_list request_head;
/* pending session packages to be transmitted */
Ip_u32 package_num;
struct Ipdiameter_header *packages[IPDIAMETER_MAX_PEER_PENDING_PKTS];
}
Ipdiameter_peer_entry;
/*
****************************************************************************
* GLOBAL FUNCTIONS
****************************************************************************
*/
struct Ipdiameter_request_entry;
IP_PUBLIC Ip_err ipdiameter_peer_fsm(Ipdiameter_peer_entry *peer,
struct Ipdiameter_header *hdr, int event);
IP_PUBLIC Ipdiameter_peer_entry *ipdiameter_create_peer(Ipdiameter_peer *peer);
IP_PUBLIC Ip_err ipdiameter_delete_peer(union Ip_sockaddr_union *peer_addr);
IP_PUBLIC Ip_err ipdiameter_mod_peer(union Ip_sockaddr_union *peer_addr);
IP_PUBLIC Ipdiameter_peer_entry *
ipdiameter_find_peer(union Ip_sockaddr_union *peer_addr);
IP_PUBLIC Ipdiameter_peer_entry *
ipdiameter_find_peer_host(Ip_u8 *host_id);
IP_PUBLIC void ipdiameter_peer_add_req(Ipdiameter_peer_entry *peer,
struct Ipdiameter_header *request);
IP_PUBLIC void ipdiameter_peer_remove_req(Ipdiameter_peer_entry *peer,
struct Ipdiameter_request_entry *reqent);
IP_PUBLIC struct Ipdiameter_request_entry *
ipdiameter_peer_find_req(Ipdiameter_peer_entry *peer, Ip_u32 hbh_id);
#ifdef IPCOM_USE_INET
IP_PUBLIC Ip_fd ipdiameter_peer_tcp4socket(void);
#endif
#ifdef IPCOM_USE_INET6
IP_PUBLIC Ip_fd ipdiameter_peer_tcp6socket(void);
#endif
IP_PUBLIC Ip_err ipdiameter_peer_init_conn_req(Ipdiameter_peer_entry *peer);
IP_PUBLIC Ip_err ipdiameter_peer_cleanup(Ipdiameter_peer_entry *peer);
IP_PUBLIC Ip_err ipdiameter_peer_error(Ipdiameter_peer_entry *peer);
IP_PUBLIC Ip_bool ipdiameter_peer_elect(Ipdiameter_peer_entry *peer);
IP_PUBLIC Ip_err ipdiameter_peer_disc(Ipdiameter_peer_entry *peer);
IP_PUBLIC Ip_err ipdiameter_peer_reject(Ipdiameter_peer_entry *peer);
IP_PUBLIC Ip_err ipdiameter_peer_send_msg(Ipdiameter_peer_entry *peer);
IP_PUBLIC Ip_err ipdiameter_peer_process_msg(Ipdiameter_peer_entry *peer);
IP_PUBLIC Ip_err ipdiameter_peer_resp_accept(Ipdiameter_peer_entry *peer);
IP_PUBLIC void ipdiameter_peer_set_state(Ipdiameter_peer_entry *peer,
Ipdiameter_peer_state state);
IP_PUBLIC Ip_u32 ipdiameter_peer_process_CER(Ipdiameter_peer_entry *peer,
struct Ipdiameter_header *hdr);
IP_PUBLIC Ip_err ipdiameter_peer_process_CEA(Ipdiameter_peer_entry *peer,
struct Ipdiameter_header *hdr);
IP_PUBLIC Ip_u32 ipdiameter_peer_process_DWR(Ipdiameter_peer_entry *peer,
struct Ipdiameter_header *hdr);
IP_PUBLIC Ip_err ipdiameter_peer_process_DWA(Ipdiameter_peer_entry *peer,
struct Ipdiameter_header *hdr);
IP_PUBLIC Ip_err ipdiameter_peer_start_reconn_timer(Ipdiameter_peer_entry *peer);
IP_PUBLIC Ip_err ipdiameter_peer_reconn_timeout(Ipdiameter_peer_entry *peer);
IP_PUBLIC Ip_err ipdiameter_peer_start_wd_timer(Ipdiameter_peer_entry *peer);
IP_PUBLIC char *ipdiameter_peer_type(Ipdiameter_peer_type type);
IP_PUBLIC char *ipdiameter_peer_state(Ipdiameter_peer_state state);
IP_PUBLIC char *ipdiameter_peer_appl(Ip_u32 appl_id);
IP_PUBLIC Ip_err ipdiameter_peer_add_tx_pending_pkt(Ipdiameter_peer_entry *peer,
struct Ipdiameter_header *package);
IP_PUBLIC Ipdiameter_peer_entry *
ipdiameter_peer_realm_route(char *realm);
IP_PUBLIC Ipdiameter_peer_entry *
ipdiameter_peer_proxy_route(void);
IP_PUBLIC void ipdiameter_peer_lck(Ipdiameter_peer_entry *peer);
IP_PUBLIC void ipdiameter_peer_unlck(Ipdiameter_peer_entry *peer);
#ifdef IPDIAMETER_ENABLE_REENTRANT
#ifdef IP_PORT_VXWORKS
#define IPDIAMETER_PEER_LOCK(peer) ipcom_mutex_lock(peer->code_mutex)
#define IPDIAMETER_PEER_UNLOCK(peer) ipcom_mutex_unlock(peer->code_mutex)
#else /* !IP_PORT_VXWORKS, Linux recursive semaphore */
#define IPDIAMETER_PEER_LOCK(peer) ipdiameter_peer_lck(peer)
#define IPDIAMETER_PEER_UNLOCK(peer) ipdiameter_peer_unlck(peer)
#endif /* IP_PORT_VXWORKS */
#else
#define IPDIAMETER_PEER_LOCK(peer) IP_NOOP
#define IPDIAMETER_PEER_UNLOCK(peer) IP_NOOP
#endif
#ifdef __cplusplus
}
#endif
#endif /* #ifndef IPDIAMETER_PEER_H */
/*
****************************************************************************
* END OF FILE
****************************************************************************
*/
@@ -0,0 +1,244 @@
/* ipdiameter_routing.h - Diameter routing defining head file */
/*
* Copyright (c) 2007 Wind River Systems, Inc.
*
* The right to copy, distribute or otherwise make use of this software
* may be licensed only pursuant to the terms of an applicable Wind River
* license agreement. No license to Wind River intellectual property rights
* is granted herein. All rights not licensed by Wind River are reserved
* by Wind River.
*/
/*
modification history
--------------------
01h,25mar08,ggz Additional buffer IPDIAMETER_ADDITIONAL_BUFFER for result AVP
01g,03mar08,ggz Added next hop server to pending packet structure for rerouting
01f,17apr08,tlu Add compile condition to call ipcom mutex utilities directly
for VxWorks, and call recursive semaphore for Linux
01e,31jan08,ggz Added recursive locks for routing and policy enforcment
01d,26jan08,ggz Moved public header function declarations from c file into header file
01c,24jan08,tlu Added policy structure
01b,18jan08,ggz Added prototype ipdiameter_proxy_process_protocol_errors
01a,16july07,cwu Created.
*/
#ifndef IPDIAMETER_ROUTING_H
#define IPDIAMETER_ROUTING_H
/*
****************************************************************************
* INCLUDE FILES
****************************************************************************
*/
#include "ipdiameter_constant.h"
#include "ipdiameter_peer.h"
#include "ipdiameter.h"
#ifdef __cplusplus
extern "C" {
#endif
/*
**************************************************************************
* DEFINES
*************************************************************************
*/
#define IPDIAMETER_ENABLE_REENTRANT
#ifdef IPDIAMETER_ENABLE_REENTRANT
#ifdef IP_PORT_VXWORKS
#define IPDIAMETER_ROUTE_LOCK(route) ipcom_mutex_lock(route->code_mutex)
#define IPDIAMETER_ROUTE_UNLOCK(route) ipcom_mutex_unlock(route->code_mutex)
#define IPDIAMETER_POLICY_LOCK(policy) ipcom_mutex_lock(policy->code_mutex)
#define IPDIAMETER_POLICY_UNLOCK(policy) ipcom_mutex_unlock(policy->code_mutex)
#else /* !IP_PORT_VXWORKS, Linux recursive semaphore */
#define IPDIAMETER_ROUTE_LOCK(route) ipdiameter_route_lck(route)
#define IPDIAMETER_ROUTE_UNLOCK(route) ipdiameter_route_unlck(route)
#define IPDIAMETER_POLICY_LOCK(policy) ipdiameter_policy_lck(policy)
#define IPDIAMETER_POLICY_UNLOCK(policy) ipdiameter_policy_unlck(policy)
#endif /* IP_PORT_VXWORKS */
#else
#define IPDIAMETER_ROUTE_LOCK(route) IP_NOOP
#define IPDIAMETER_ROUTE_UNLOCK(route) IP_NOOP
#define IPDIAMETER_POLICY_LOCK(policy) IP_NOOP
#define IPDIAMETER_POLICY_UNLOCK(policy) IP_NOOP
#endif
/* Used to allocated additional memory for adding a Result Code. */
#define IPDIAMETER_ADDITIONAL_BUFFER 15
/* Ipdiameter_route_action types: 'action_type' */
typedef enum
{
DIAMETER_LOCAL = 1,
DIAMETER_RELAY,
DIAMETER_PROXY,
DIAMETER_REDIRECT
}Ipdiameter_route_action_type;
typedef struct Ipdiameter_route_server_struct
{
/* server-id */
Ipcom_list server_list;
/* Peer IP address */
union Ip_sockaddr_union peer_addr;
/* server-id */
char server_id[IPDIAMETER_MAX_FQDN_SIZE];
/* metric */
Ip_u32 metric;
} Ipdiameter_route_server;
typedef struct Ipdiameter_agent_pending_packet_struct
{
/* original hop_to_hop id */
Ip_u32 original_hbh_id;
Ip_u32 new_hbh_id;
/*original peer information */
Ipdiameter_peer_entry *original_peer;
Ipdiameter_peer_entry *new_peer;
/* added proxy-informaiton AVP */
Ip_u8 proxy_state;
/* original request packet length */
Ip_u32 pkt_length;
char next_hope_server[IPDIAMETER_MAX_FQDN_SIZE];
} Ipdiameter_agent_pending_packet_entry;
/******************************************************************************
* Diameter route entry definition
* refer to RFC 3588, section 2.7
*****************************************************************************
*/
typedef struct Ipdiameter_route_struct
{
Ipcom_list route_list;
/* realm id */
char realm_id[IPDIAMETER_MAX_FQDN_SIZE];
/* application id */
Ip_u32 application_id;
/* vendor_id. If application id is standard , this is always set to 0 */
Ip_u32 vendor_id;
/* local action type for this route entry, RFC 2.7 */
Ipdiameter_route_action_type action_type;
/* server list */
Ipcom_list server_head;
/* server_num, the current size of server list */
Ip_u32 server_num;
/* route type, static route or dynamic route */
Ip_bool dynamic;
/* if this is a dynamic route, it will expire after expiration_time seconds */
Ip_time_t expiration_time;
#ifdef IPDIAMETER_ENABLE_REENTRANT
Ipcom_mutex code_mutex; /* Mutex to protect IPDIAMETER route data. */
#endif
/* the process that currently holds the semaphore and taken counter */
Ip_pid_t pid;
Ip_u8 s_counter;
} Ipdiameter_route_entry;
typedef struct Ipdiameter_policy_entry_struct
{
Ipcom_list policy_list;
Ip_bool have_uname;
union {
/* user name */
char username[IPDIAMETER_MAX_FQDN_SIZE];
/* host id */
char hostid[IPDIAMETER_MAX_FQDN_SIZE];
} name;
#ifdef IPDIAMETER_ENABLE_REENTRANT
Ipcom_mutex code_mutex; /* Mutex to protect IPDIAMETER policy data. */
#endif
/* the process that currently holds the semaphore and taken counter */
Ip_pid_t pid;
Ip_u8 s_counter;
} Ipdiameter_policy_entry;
IP_PUBLIC Ipdiameter_route_entry
*ipdiameter_find_route(Ipdiameter_route_entry *route);
IP_PUBLIC Ipdiameter_route_entry
*ipdiameter_create_route(Ipdiameter_route_entry *route, char *server);
IP_PUBLIC Ip_bool
ipdiameter_delete_route(Ipdiameter_route_entry *route, char *server);
IP_PUBLIC Ip_bool
ipdiameter_del_route(Ipdiameter_route_entry *route);
IP_PUBLIC Ipdiameter_policy_entry
*ipdiameter_find_policy(Ip_bool username, char *name);
IP_PUBLIC Ip_err
ipdiameter_create_policy(Ipdiameter_policy_entry *policy);
IP_PUBLIC Ip_err
ipdiameter_delete_policy(Ipdiameter_policy_entry *policy);
IP_PUBLIC Ip_bool ipdiameter_proxy_process_protocol_errors(struct Ipdiameter_header *packet,
Ipdiameter_peer_entry *peer, Ip_u32 error_type);
IP_PUBLIC Ip_bool ipdiameter_proxy_process_received_protocol_errors (struct Ipdiameter_header *packet,
struct Ipdiameter_request_entry *reqent,
Ipdiameter_peer_entry *peer);
IP_PUBLIC Ip_bool ipdiameter_proxy_process_permanent_errors(struct Ipdiameter_header *packet,
Ipdiameter_peer_entry *peer, Ip_u32 error_type);
IP_PUBLIC Ipdiameter_route_entry *ipdiameter_find_default_route(void);
IP_PUBLIC void ipdiameter_route_lck(Ipdiameter_route_entry *route);
IP_PUBLIC void ipdiameter_route_unlck(Ipdiameter_route_entry *route);
IP_PUBLIC void ipdiameter_policy_lck(Ipdiameter_policy_entry *policy);
IP_PUBLIC void ipdiameter_policy_unlck(Ipdiameter_policy_entry *policy);
#ifdef __cplusplus
}
#endif
#endif /* #ifndef IPDIAMETER_ROUTING_H */
/*
****************************************************************************
* END OF FILE
****************************************************************************
*/
@@ -0,0 +1,320 @@
/* ipdiameter_session.h - IPNet Diameter session head file */
/*
* Copyright (c) 2007 Wind River Systems, Inc.
*
* The right to copy, distribute or otherwise make use of this software
* may be licensed only pursuant to the terms of an applicable Wind River
* license agreement. No license to Wind River intellectual property rights
* is granted herein. All rights not licensed by Wind River are reserved
* by Wind River.
*/
/*
modification history
--------------------
01g,20mar09,tlu Add RAR-RX event and re-auth field to session structure
01f,17apr08,tlu Add compile condition to call ipcom mutex utilities directly
for VxWorks, and call recursive semaphore for Linux
01e,10oct07,tlu Port to Linux
01d,06jul07,tlu Add multiple servers to session struct for server redundancy
01c,26jun07,tlu Add ipdiameter_session_delete as an application API
01b,20jun07,tlu Make DIAMETER_CLIENT_AUTH_EV_ANSWER_RX and
DIAMETER_CLIENT_AUTH_EV_ANSWER_RX_DEFAULT same event
01a,26apr07,tlu Created.
*/
#ifndef IPDIAMETER_SESSION_H
#define IPDIAMETER_SESSION_H
/*
****************************************************************************
* INCLUDE FILES
****************************************************************************
*/
#include <ipcom_tags.h>
#include <ipcom_type.h>
#include <ipcom_sock.h>
#include <ipcom_sock6.h>
#include <ipcom_list.h>
#include <ipcom_tmo2.h>
#include <ipdiameter_config.h>
#include <ipdiameter_constant.h>
/*
****************************************************************************
* DEFINES
****************************************************************************
*/
#define IPDIAMETER_ENABLE_REENTRANT
/*
*===========================================================================
* Client authentication session state machine events
*===========================================================================
* session auth events on client side.
* refer to RFC 3588, section 8.1,
* and draft-ietf-dime-rfc3588bis-xx, section 8.1
*/
typedef enum
{
DIAMETER_CLIENT_AUTH_EV_ACCESS_REQ = 1,
DIAMETER_CLIENT_AUTH_EV_ASR_RX,
DIAMETER_CLIENT_AUTH_EV_ANSWER_RX_DEFAULT,
DIAMETER_CLIENT_AUTH_EV_ANSWER_RX_NO_SERVICE,
DIAMETER_CLIENT_AUTH_EV_ANSWER_RX_PROC_ERR,
DIAMETER_CLIENT_AUTH_EV_ANSWER_RX_REJECT,
DIAMETER_CLIENT_AUTH_EV_ACCESS_REQ_SERVICE,
DIAMETER_CLIENT_AUTH_EV_TIMEOUT_EXPIRES,
DIAMETER_CLIENT_AUTH_EV_LIFETIME_GRACE_EXPIRES,
DIAMETER_CLIENT_AUTH_EV_STA_RX,
DIAMETER_CLIENT_AUTH_EV_SERV_TERMINATED,
DIAMETER_CLIENT_AUTH_EV_RAR_RX
} Ipdiameter_client_auth_events;
#define DIAMETER_CLIENT_AUTH_EV_ANSWER_RX DIAMETER_CLIENT_AUTH_EV_ANSWER_RX_DEFAULT
#define DIAMETER_CLIENT_AUTH_EV_ACCESS_REQ_SERVICE DIAMETER_CLIENT_AUTH_EV_ACCESS_REQ
#define DIAMETER_CLIENT_AUTH_EV_ANSWER_RX_NO_STATE DIAMETER_CLIENT_AUTH_EV_ANSWER_RX_DEFAULT
/*
*===========================================================================
* Session termination cause values
*===========================================================================
* refer to RFC 3588, section 8.15
*/
typedef enum
{
DIAMETER_LOGOUT = 1,
DIAMETER_SERVICE_NOT_PROVIDED,
DIAMETER_BAD_ANSWER,
DIAMETER_ADMINISTRATIVE,
DIAMETER_LINK_BROKEN,
DIAMETER_AUTH_EXPIRED,
DIAMETER_USER_MOVED,
DIAMETER_SESSION_TIMEOUT
} Ipdiameter_session_termination_cause;
/*
*===========================================================================
* Session states
*===========================================================================
* refer to RFC 3588, section 8.1
*/
typedef enum
{
DIAMETER_SESSION_STATE_IDLE = 1,
DIAMETER_SESSION_STATE_PENDING,
DIAMETER_SESSION_STATE_OPEN,
DIAMETER_SESSION_STATE_DISCON,
DIAMETER_SESSION_STATE_PENDINGS,
DIAMETER_SESSION_STATE_PENDINGI,
DIAMETER_SESSION_STATE_PENDINGE,
DIAMETER_SESSION_STATE_PENDINGB,
DIAMETER_SESSION_STATE_PENDINGL
} Ipdiameter_session_state;
/*
*===========================================================================
* Auth-Session-State values
*===========================================================================
* refer to RFC 3588, section 8.11
*/
typedef enum
{
DIAMETER_STATE_MAINTAINED = 0,
DIAMETER_NO_STATE_MAINTAINED
} Ipdiameter_auth_session_state;
/*
****************************************************************************
* TYPES
****************************************************************************
*/
struct Ipdiameter_header;
struct Ipdiameter_server;
struct Ipdiameter_request_struct;
/*
*===========================================================================
* Ipdiameter_session
*===========================================================================
* Diameter user session.
* refer to RFC 3588, section 8
*/
typedef struct Ipdiameter_session_struct
{
Ipcom_list session_list;
/* seconds since the session started (0 if not started) */
Ip_time_t start_time;
/* timeout handler for session timeout */
Ipcom_tmo2 session_tmo;
/* timeout handler for authentication timeout */
Ipcom_tmo2 auth_tmo;
/* timer related intevals */
Ip_u32 session_timeout;
Ip_u32 auth_lifetime;
Ip_u32 auth_grace_period;
#ifdef IPDIAMETER_ENABLE_REENTRANT
Ipcom_mutex code_mutex; /* Mutex to protect IPDIAMETER session data. */
#endif
/* selected server, the index number of serv_list */
Ip_s8 selected_server;
/* tried servers, the bit map represents the tried servers */
Ip_u8 tried_servers;
/* the servers for the session, supplied by applications */
Ip_u8 num_servers; /* Number of valid entries in 'serv_list' below. */
struct Ipdiameter_server *serv_list[IPDIAMETER_MAX_SPECIFIED_SERVERS];
/* the next hop to send the packet to */
struct Ipdiameter_peer_entry *peer;
/* Session ID */
Ip_u16 session_id_len;
char session_id[IPDIAMETER_MAX_SESSION_ID_SIZE];
/* Auth application ID, refer to RFC 3588, section 2.4 */
Ip_u32 appl_id;
/* Whether to perform subsequent re-auth */
/* refer to draft-ieft-dime-rfc3588bits-xx, section 8.3 */
Ip_bool perform_re_auth;
/* Record Diameter EAP auth cookie for RAR event callback */
void *auth_cookie;
/* Session state, the session is stateless by default */
Ip_bool is_stateful;
Ipdiameter_session_state state;
/* the process that currently holds the semaphore and taken counter */
Ip_pid_t pid;
Ip_u8 s_counter;
/* Application event callback function pointer. */
Ip_err (*event_callback)(int event, struct Ipdiameter_request_struct *request,
struct Ipdiameter_header *request_packet,
struct Ipdiameter_header *response_packet,
struct Ipdiameter_server *server);
/* Requests associated with this session. */
Ip_u32 request_num; /* number of requests. */
Ipcom_list request_head;
}
Ipdiameter_session;
/*
****************************************************************************
* Application APIs
****************************************************************************
*/
#ifdef __cplusplus
extern "C" {
#endif
IP_PUBLIC void ipdiameter_session_delete(char *session_id);
/*
****************************************************************************
* GLOBAL FUNCTIONS
****************************************************************************
*/
struct Ipdiameter_request_entry;
struct Ipdiameter_peer_entry;
IP_PUBLIC Ipdiameter_session *
ipdiameter_create_session(struct Ipdiameter_request_entry *reqent);
IP_PUBLIC void ipdiameter_delete_session(Ipdiameter_session *session);
IP_PUBLIC Ipdiameter_session *ipdiameter_find_session(char *session_id);
IP_PUBLIC Ip_err ipdiameter_discon_user(Ipdiameter_session *session);
IP_PUBLIC Ip_err ipdiameter_session_cleanup(Ipdiameter_session *session);
IP_PUBLIC void ipdiameter_session_add_req(Ipdiameter_session *session,
struct Ipdiameter_header *packet);
IP_PUBLIC void ipdiameter_session_remove_req(Ipdiameter_session *session,
struct Ipdiameter_request_entry *reqent);
IP_PUBLIC struct Ipdiameter_request_entry *
ipdiameter_session_find_req(Ipdiameter_session *session, Ip_u32 hbh_id);
IP_PUBLIC Ip_err ipdiameter_session_update_reqs(Ipdiameter_session *session);
IP_PUBLIC struct Ipdiameter_peer_entry *
ipdiameter_session_select_route(Ipdiameter_session *session);
IP_PUBLIC void ipdiameter_session_set_state(Ipdiameter_session *session,
Ipdiameter_session_state state);
IP_PUBLIC void ipdiameter_session_set_peer(Ipdiameter_session *session,
struct Ipdiameter_peer_entry *peer);
IP_PUBLIC Ip_err ipdiameter_session_start_timers(Ipdiameter_session *session,
struct Ipdiameter_header *hdr);
IP_PUBLIC Ip_err ipdiameter_client_auth_fsm(Ipdiameter_session *session,
struct Ipdiameter_header *hdr, int event);
IP_PUBLIC char * ipdiameter_session_appl_id(Ip_u32 appl_id);
IP_PUBLIC char * ipdiameter_session_state(Ipdiameter_session_state state);
IP_PUBLIC void ipdiameter_session_lck(Ipdiameter_session *session);
IP_PUBLIC void ipdiameter_session_unlck(Ipdiameter_session *session);
#ifdef IPDIAMETER_ENABLE_REENTRANT
#ifdef IP_PORT_VXWORKS
#define IPDIAMETER_SESSION_LOCK(session) ipcom_mutex_lock(session->code_mutex)
#define IPDIAMETER_SESSION_UNLOCK(session) ipcom_mutex_unlock(session->code_mutex)
#else /* !IP_PORT_VXWORKS, Linux recursive semaphore */
#define IPDIAMETER_SESSION_LOCK(session) ipdiameter_session_lck(session)
#define IPDIAMETER_SESSION_UNLOCK(session) ipdiameter_session_unlck(session)
#endif /* IP_PORT_VXWORKS */
#else
#define IPDIAMETER_SESSION_LOCK(session) IP_NOOP
#define IPDIAMETER_SESSION_UNLOCK(session) IP_NOOP
#endif
#ifdef __cplusplus
}
#endif
#endif /* #ifndef IPDIAMETER_SESSION_H */
/*
****************************************************************************
* END OF FILE
****************************************************************************
*/
@@ -0,0 +1,95 @@
/* ipdiameter_tls.h - IPNet Diameter TLS head file */
/*
* Copyright (c) 2007 Wind River Systems, Inc.
*
* The right to copy, distribute or otherwise make use of this software
* may be licensed only pursuant to the terms of an applicable Wind River
* license agreement. No license to Wind River intellectual property rights
* is granted herein. All rights not licensed by Wind River are reserved
* by Wind River.
*/
/*
modification history
--------------------
01b,10oct07,tlu Port to Linux
01a,08aug07,tlu Created.
*/
#ifndef IPDIAMETER_TLS_H
#define IPDIAMETER_TLS_H
#ifdef IPSSL
/*
****************************************************************************
* INCLUDE FILES
****************************************************************************
*/
#include <ipcom_tags.h>
#include <ipcom_type.h>
#include <openssl/rand.h>
#include <openssl/err.h>
#include <ipdiameter_config.h>
#include <ipdiameter_constant.h>
#include <ipdiameter_peer.h>
/*
****************************************************************************
* DEFINES
****************************************************************************
*/
#define DIAMETER_CIPHER_LIST "ALL:!ADH:!LOW:!EXP:@STRENGTH"
/*
****************************************************************************
* TYPES
****************************************************************************
*/
#ifdef __cplusplus
extern "C" {
#endif
/*
****************************************************************************
* GLOBAL FUNCTIONS
****************************************************************************
*/
IP_PUBLIC Ip_err ipdiameter_setup_ssl_ctx();
IP_PUBLIC Ip_err ipdiameter_tls_connection(Ipdiameter_peer_entry *peer,
Ip_bool connect);
IP_PUBLIC int ipdiameter_tls_read(Ipdiameter_peer_entry *peer, char *buf,
int length);
IP_PUBLIC int ipdiameter_tls_write(SSL *ssl, char *buf, int length);
#endif /* IPSSL */
#ifdef __cplusplus
}
#endif
#endif /* #ifndef IPDIAMETER_TLS_H */
/*
****************************************************************************
* END OF FILE
****************************************************************************
*/