hellopics-ctrl_conn.c File Reference

Relating to managing the connections. More...

#include <string.h>
#include <jnx/aux_types.h>
#include <jnx/trace.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <jnx/pconn.h>
#include <sync/hellopics_ipc.h>
#include "hellopics-ctrl_conn.h"
#include "hellopics-ctrl_logging.h"

Go to the source code of this file.

Defines

#define RETRY_CONNECT_INTERVAL   200
#define MGMT_CLIENT_CONNECT_RETRIES   3
 max number of connect retries
#define HELLOPICS_CTRL_SERVER_MAX_CONN   1
 max # cnxs

Functions

static void connect_ctrl_pic (evContext ctx, void *uap __unused, struct timespec due __unused, struct timespec inter __unused)
static void client_connection (pconn_client_t *session, pconn_event_t event, void *cookie __unused)
static status_t client_message (pconn_client_t *session, ipc_msg_t *msg, void *cookie __unused)
static void receive_connection (pconn_session_t *session, pconn_event_t event, void *cookie __unused)
static status_t receive_message (pconn_session_t *session, ipc_msg_t *msg, void *cookie __unused)
status_t init_connections (evContext ctx)
void close_connections (void)

Variables

static pconn_server_t * ctrl_server
 the server connection info (to data)
static pconn_session_t * data_session
 the session to the data component
static pconn_client_t * mgmt_client
 client cnx to management component
static boolean mgmt_connected
 the mgmt_client cnx is established
static boolean data_ready
 the data component is ready
static evTimerID ctrl_timer_id
 timerID for retrying cnx to mgmt
static evContext ev_ctx
 event context for main thread


Detailed Description

Relating to managing the connections.

These functions and types will manage the connections.

Definition in file hellopics-ctrl_conn.c.


Function Documentation

static void client_connection ( pconn_client_t *  session,
pconn_event_t  event,
void *cookie  __unused 
) [static]

Connection handler for new and dying connections

Parameters:
[in] session The session information for the source peer
[in] event The event (established, or shutdown are the ones we care about)
[in] cookie user data passed back

Definition at line 70 of file hellopics-ctrl_conn.c.

References connect_ctrl_pic(), ctrl_timer_id, data_ready, ev_ctx, HELLOPICS_ID_CTRL, INSIST_ERR, LOG, mgmt_client, mgmt_connected, MSG_ID, MSG_READY, and RETRY_CONNECT_INTERVAL.

Referenced by connect_ctrl_pic().

static status_t client_message ( pconn_client_t *  session,
ipc_msg_t *  msg,
void *cookie  __unused 
) [static]

Message handler for open connections. We receive all only HELLO messages.

Parameters:
[in] session The session information for the source peer
[in] msg The inbound message
[in] cookie The cookie we passed in. This is the eventlib context here.
Returns:
SUCCESS if successful; otherwise EFAIL with an error message.

Definition at line 166 of file hellopics-ctrl_conn.c.

References data_session, INSIST_ERR, LOG, mgmt_client, and MSG_HELLO.

Referenced by connect_ctrl_pic().

void close_connections ( void   ) 

Terminate all the connections

Definition at line 445 of file hellopics-ctrl_conn.c.

References ctrl_server, data_session, and mgmt_client.

Referenced by hellopics_ctrl_quit().

static void connect_ctrl_pic ( evContext  ctx,
void *uap  __unused,
struct timespec due  __unused,
struct timespec inter  __unused 
) [static]

Create server scoket for the data component and create a new connection to the mgmt server.

Parameters:
[in] ctx event context

Definition at line 359 of file hellopics-ctrl_conn.c.

References client_connection(), client_message(), ctrl_server, data_ready, data_session, HELLOPICS_CTRL_SERVER_MAX_CONN, HELLOPICS_PORT_NUM, LOG, mgmt_client, MGMT_CLIENT_CONNECT_RETRIES, mgmt_connected, receive_connection(), and receive_message().

Referenced by client_connection(), and init_connections().

status_t init_connections ( evContext  ctx  ) 

Initiate connections to the data component and the mgmt component

Parameters:
[in] ctx event context
Returns:
SUCCESS if successful; otherwise EFAIL with an error message.

Definition at line 420 of file hellopics-ctrl_conn.c.

References connect_ctrl_pic(), ctrl_timer_id, ev_ctx, LOG, mgmt_client, and RETRY_CONNECT_INTERVAL.

Referenced by hellopics_ctrl_init().

static void receive_connection ( pconn_session_t *  session,
pconn_event_t  event,
void *cookie  __unused 
) [static]

Connection handler for new and dying connections

Parameters:
[in] session The session information for the source peer
[in] event The event (established, or shutdown are the ones we care about)
[in] cookie The cookie we passed in. This is the eventlib context here.

Definition at line 217 of file hellopics-ctrl_conn.c.

References data_session, INSIST_ERR, and LOG.

Referenced by connect_ctrl_pic().

static status_t receive_message ( pconn_session_t *  session,
ipc_msg_t *  msg,
void *cookie  __unused 
) [static]

Message handler for open connections. We receive MSG_ID, MSG_READY, and MSG_HELLO messages (msg_type_e).

Parameters:
[in] session The session information for the source peer
[in] msg The inbound message
[in] cookie The cookie we passed in. This is the eventlib context here.
Returns:
SUCCESS if successful; otherwise EFAIL with an error message.

Definition at line 280 of file hellopics-ctrl_conn.c.

References data_ready, data_session, HELLOPICS_ID_DATA, INSIST_ERR, LOG, mgmt_client, mgmt_connected, MSG_HELLO, MSG_ID, and MSG_READY.

Referenced by connect_ctrl_pic().


2007-2009 Juniper Networks, Inc. All rights reserved. The information contained herein is confidential information of Juniper Networks, Inc., and may not be used, disclosed, distributed, modified, or copied without the prior written consent of Juniper Networks, Inc. in an express license. This information is subject to change by Juniper Networks, Inc. Juniper Networks, the Juniper Networks logo, and JUNOS are registered trademarks of Juniper Networks, Inc. in the United States and other countries. All other trademarks, service marks, registered trademarks, or registered service marks are the property of their respective owners.
Generated on Sun May 30 20:26:58 2010 for SDK Your Net Corporation Hellopics Example: hellopics-ctrl 1.0 by Doxygen 1.5.1