245 lines
8.8 KiB
C
245 lines
8.8 KiB
C
/* ipwps_protocol_handler.h - IPWPS Protocol Handler header file */
|
|
|
|
/*
|
|
* Copyright (c) 2009 Wind River Systems, Inc.
|
|
*
|
|
* The right to copy, distribute, modify, or otherwise make use
|
|
* of this software may be licensed only pursuant to the terms
|
|
* of an applicable Wind River license agreement.
|
|
*
|
|
*/
|
|
|
|
/*
|
|
modification history
|
|
--------------------
|
|
01a,09Feb09,mry Created
|
|
*/
|
|
#ifndef IPWPS_PROTO_HANDLER_H
|
|
#define IPWPS_PROTO_HANDLER_H
|
|
|
|
/*
|
|
****************************************************************************
|
|
* 1 DESCRIPTION
|
|
****************************************************************************
|
|
*/
|
|
|
|
/*
|
|
****************************************************************************
|
|
* 2 CONFIGURATION
|
|
****************************************************************************
|
|
*/
|
|
|
|
/*
|
|
****************************************************************************
|
|
* 3 INCLUDE FILES
|
|
****************************************************************************
|
|
*/
|
|
|
|
#include <ipcom_type.h>
|
|
#include <ipcom_cstyle.h>
|
|
#include <ipcom_sock.h>
|
|
#include <ipcom_ipd.h>
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
/*
|
|
****************************************************************************
|
|
* 4 DEFINES
|
|
****************************************************************************
|
|
*/
|
|
|
|
|
|
/*
|
|
****************************************************************************
|
|
* 5 TYPES
|
|
****************************************************************************
|
|
*/
|
|
typedef enum {
|
|
IPWPS_PROTO_SENDNOTIFY_START,
|
|
IPWPS_PROTO_SENDNOTIFY_M1,
|
|
IPWPS_PROTO_SENDNOTIFY_M2,
|
|
IPWPS_PROTO_SENDNOTIFY_M2D,
|
|
IPWPS_PROTO_SENDNOTIFY_M3,
|
|
IPWPS_PROTO_SENDNOTIFY_M4,
|
|
IPWPS_PROTO_SENDNOTIFY_M5,
|
|
IPWPS_PROTO_SENDNOTIFY_M6,
|
|
IPWPS_PROTO_SENDNOTIFY_M7,
|
|
IPWPS_PROTO_SENDNOTIFY_M8,
|
|
IPWPS_PROTO_SENDNOTIFY_DONE,
|
|
IPWPS_PROTO_SENDNOTIFY_ACK,
|
|
IPWPS_PROTO_SENDNOTIFY_NACK,
|
|
IPWPS_PROTO_SENDNOTIFY_WPS_FIN
|
|
} Ipwps_proto_notify;
|
|
|
|
struct Ipwps_ctx_st;
|
|
/*
|
|
****************************************************************************
|
|
* 6 FUNCTIONS
|
|
****************************************************************************
|
|
*/
|
|
|
|
/*
|
|
*===========================================================================
|
|
*
|
|
*===========================================================================
|
|
* Description:
|
|
* Allocate and Initialize an IPWPS Protocol Handler context.
|
|
* Called by the WPS application before registering its receive methods with
|
|
* the protocol adaptor.
|
|
* Parameters:
|
|
* Ipwps_ctx* ctx - A valid Ready wps context.
|
|
* Returns:
|
|
* Pointer to an initialized IPWPS Protocol Handler context if successfull,
|
|
* IP_NULL otherwise.
|
|
*/
|
|
IP_GLOBAL Ipwps_proto_ctx *ipwps_protocol_ctx_init
|
|
(
|
|
struct Ipwps_ctx_st* ctx
|
|
);
|
|
|
|
/*
|
|
*===========================================================================
|
|
*
|
|
*===========================================================================
|
|
* Description:
|
|
* Destroy the IPWPS Protocol Handler context.
|
|
* Called by the WPS application upon shutdown.
|
|
* Parameters:
|
|
* Ipwps_ctx* ctx - A valid Ready wps context.
|
|
* Ipwps_proto_ctx *proto_ctx - A valid IPWPS Protocol Handler context.
|
|
* Returns:
|
|
* IPCOM_SUCCESS upon success, otherwise a failure indication
|
|
*/
|
|
IP_GLOBAL Ip_err ipwps_protocol_ctx_destroy
|
|
(
|
|
struct Ipwps_ctx_st* ctx,
|
|
Ipwps_proto_ctx *proto_ctx
|
|
);
|
|
|
|
#ifdef IPWPS_DEBUG
|
|
/*
|
|
*===========================================================================
|
|
* ipwps_protocol_debug_show
|
|
*===========================================================================
|
|
* Description: Display the internal information for the specified protocol context.
|
|
* (FOR DEBUGGING PURPOSES ONLY). Uses DEBUG2 level logs to display.
|
|
* VERY IMPORTANT NOTE: If IPWPS_DEBUG_PROTO_CRYPTO_DATA is defined, this
|
|
* routine will display cryptographically sensitive data (keys, nonces, etc).
|
|
* Parameters:
|
|
* Ipwps_proto_ctx *proto_ctx - A valid IPWPS Protocol Handler context
|
|
* char *prefix - Prefix string to use in the logs
|
|
* Returns:
|
|
* None
|
|
*/
|
|
IP_GLOBAL void ipwps_protocol_debug_show
|
|
(
|
|
Ipwps_proto_ctx *proto_ctx,
|
|
char *prefix
|
|
);
|
|
#endif
|
|
|
|
/*
|
|
*===========================================================================
|
|
* ipwps_proto_alloc_msg_struct
|
|
*===========================================================================
|
|
* Description: Allocate a WPS Message structure of specified type.
|
|
* (Initializes the common header too)
|
|
* Called by WPS applications.
|
|
* Parameters:
|
|
* Ip_u8 msgtype - Msg type to allocate struct for.
|
|
* Returns:
|
|
* Pointer to allocated message or IP_NULL if failed.
|
|
*/
|
|
IP_GLOBAL Ipwps_protomsg_overlay *ipwps_proto_alloc_msg_struct
|
|
(
|
|
Ip_u8 msgtype
|
|
);
|
|
|
|
/*
|
|
*===========================================================================
|
|
* ipwps_proto_setup_msg
|
|
*===========================================================================
|
|
* Description: Setup the contents of a WPS message structure in preperation
|
|
* to send it.
|
|
* Called by WPS applications.
|
|
* Parameters:
|
|
* Ipwps_ctx* ctx - A valid Ready wps context with enough data to setup the msg.
|
|
* Ipwps_proto_ctx *proto_ctx - A valid IPWPS Protocol Handler context
|
|
* Ipwps_protomsg_overlay *msg - Pointer to valid message to setup.
|
|
* Returns:
|
|
*
|
|
*/
|
|
IP_GLOBAL Ip_err ipwps_proto_setup_msg
|
|
(
|
|
struct Ipwps_ctx_st* ctx,
|
|
Ipwps_proto_ctx *proto_ctx,
|
|
Ipwps_protomsg_overlay *msg
|
|
);
|
|
|
|
/*
|
|
*===========================================================================
|
|
* ipwps_proto_handler_process_xxx
|
|
*===========================================================================
|
|
* Description: Process the xxx protocol message.
|
|
* CALLED ONLY BY "ipwps_proto_adaptor.c" handler functions.
|
|
* Parameters:
|
|
* Ipwps_ctx* ctx - A valid Ready wps context.
|
|
* Ipwps_proto_ctx *proto_ctx - A valid IPWPS Protocol Handler context
|
|
* Ipwps_protomsg_xxx *xxx - xxx protocol message to process
|
|
* Returns:
|
|
*
|
|
*/
|
|
IP_GLOBAL Ip_err ipwps_proto_handler_process_START(struct Ipwps_ctx_st* ctx, Ipwps_proto_ctx *proto_ctx);
|
|
IP_GLOBAL Ip_err ipwps_proto_handler_process_M1(struct Ipwps_ctx_st* ctx, Ipwps_proto_ctx *proto_ctx, Ipwps_protomsg_M1* m1);
|
|
IP_GLOBAL Ip_err ipwps_proto_handler_process_M2(struct Ipwps_ctx_st* ctx, Ipwps_proto_ctx *proto_ctx, Ipwps_protomsg_M2* m2);
|
|
IP_GLOBAL Ip_err ipwps_proto_handler_process_M2D(struct Ipwps_ctx_st* ctx, Ipwps_proto_ctx *proto_ctx, Ipwps_protomsg_M2D* m2d);
|
|
IP_GLOBAL Ip_err ipwps_proto_handler_process_M3(struct Ipwps_ctx_st* ctx, Ipwps_proto_ctx *proto_ctx, Ipwps_protomsg_M3* m3);
|
|
IP_GLOBAL Ip_err ipwps_proto_handler_process_M4(struct Ipwps_ctx_st* ctx, Ipwps_proto_ctx *proto_ctx, Ipwps_protomsg_M4* m4);
|
|
IP_GLOBAL Ip_err ipwps_proto_handler_process_M5(struct Ipwps_ctx_st* ctx, Ipwps_proto_ctx *proto_ctx, Ipwps_protomsg_M5* m5);
|
|
IP_GLOBAL Ip_err ipwps_proto_handler_process_M6(struct Ipwps_ctx_st* ctx, Ipwps_proto_ctx *proto_ctx, Ipwps_protomsg_M6* m6);
|
|
IP_GLOBAL Ip_err ipwps_proto_handler_process_M7(struct Ipwps_ctx_st* ctx, Ipwps_proto_ctx *proto_ctx, Ipwps_protomsg_M7* m7);
|
|
IP_GLOBAL Ip_err ipwps_proto_handler_process_M8(struct Ipwps_ctx_st* ctx, Ipwps_proto_ctx *proto_ctx, Ipwps_protomsg_M8* m8);
|
|
IP_GLOBAL Ip_err ipwps_proto_handler_process_ACK(struct Ipwps_ctx_st* ctx, Ipwps_proto_ctx *proto_ctx, Ipwps_protomsg_ACK* ack);
|
|
IP_GLOBAL Ip_err ipwps_proto_handler_process_NACK(struct Ipwps_ctx_st* ctx, Ipwps_proto_ctx *proto_ctx, Ipwps_protomsg_NACK* nack);
|
|
IP_GLOBAL Ip_err ipwps_proto_handler_process_DONE(struct Ipwps_ctx_st* ctx, Ipwps_proto_ctx *proto_ctx, Ipwps_protomsg_DONE* done);
|
|
IP_GLOBAL Ip_err ipwps_proto_handler_process_WPS_FIN(struct Ipwps_ctx_st* ctx, Ipwps_proto_ctx *proto_ctx);
|
|
|
|
/*
|
|
*===========================================================================
|
|
* ipwps_proto_handler_send_notify
|
|
*===========================================================================
|
|
* Description: Notify the protocol handler once sending of a protocol message
|
|
* is successful or had failed.
|
|
* CALLED ONLY BY "ipwps_proto_adaptor.c" handler functions.
|
|
* Parameters:
|
|
* Ipwps_ctx* ctx - A valid Ready wps context.
|
|
* Ipwps_proto_notify notify_type - Notificaiton type corresponding to protocol
|
|
* message sent
|
|
* Ipwps_proto_ctx *proto_ctx - A valid IPWPS Protocol Handler context associated
|
|
* with the event
|
|
* Ip_bool success - Indication if sending was successful or not.
|
|
* Returns:
|
|
*
|
|
*/
|
|
IP_GLOBAL Ip_err ipwps_proto_handler_send_notify
|
|
(
|
|
struct Ipwps_ctx_st* ctx,
|
|
Ipwps_proto_ctx *proto_ctx,
|
|
Ipwps_proto_notify notify_type,
|
|
Ip_bool success
|
|
);
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
|
|
#endif
|
|
|
|
/*
|
|
****************************************************************************
|
|
* END OF FILE
|
|
****************************************************************************
|
|
*/
|