hellopics-data_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-data_conn.h"
#include "hellopics-data_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 CTRL_CLIENT_CONNECT_RETRIES   3
 max number of connect retries

Functions

static void connect_mgmt (evContext ctx, void *uap __unused, struct timespec due __unused, struct timespec inter __unused)
static void ctrl_client_connection (pconn_client_t *session, pconn_event_t event, void *cookie __unused)
static status_t ctrl_client_message (pconn_client_t *session, ipc_msg_t *msg, void *cookie __unused)
static void mgmt_client_connection (pconn_client_t *session, pconn_event_t event, void *cookie __unused)
static status_t mgmt_client_message (pconn_client_t *session, ipc_msg_t *msg, void *cookie __unused)
status_t init_connections (evContext ctx)
void close_connections (void)

Variables

static pconn_client_t * ctrl_client
 client cnx to control component
static pconn_client_t * mgmt_client
 client cnx to management component
static evContext ev_ctx
 event context
static evTimerID mgmt_timer_id
 timerID for retrying cnx to mgmt


Detailed Description

Relating to managing the connections.

These functions and types will manage the connections.

Definition in file hellopics-data_conn.c.


Function Documentation

void close_connections ( void   ) 

Terminate all the connections

Definition at line 434 of file hellopics-data_conn.c.

References ctrl_client, and mgmt_client.

Referenced by hellopics_data_quit().

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

Connect to the mgmt component

Parameters:
[in] ctx event context

Definition at line 371 of file hellopics-data_conn.c.

References ctrl_client, ev_ctx, HELLOPICS_PORT_NUM, LOG, mgmt_client, MGMT_CLIENT_CONNECT_RETRIES, mgmt_client_connection(), and mgmt_client_message().

Referenced by init_connections(), and mgmt_client_connection().

static void ctrl_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 66 of file hellopics-data_conn.c.

References ctrl_client, HELLOPICS_ID_DATA, INSIST_ERR, LOG, mgmt_client, MSG_ID, and MSG_READY.

Referenced by mgmt_client_message().

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

Message handler for open connections. We receive 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 135 of file hellopics-data_conn.c.

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

Referenced by mgmt_client_message().

status_t init_connections ( evContext  ctx  ) 

Initiate connection establishement

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

Definition at line 410 of file hellopics-data_conn.c.

References connect_mgmt(), ev_ctx, LOG, mgmt_client, mgmt_timer_id, and RETRY_CONNECT_INTERVAL.

Referenced by hellopics_data_init().

static void mgmt_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 188 of file hellopics-data_conn.c.

References connect_mgmt(), ev_ctx, HELLOPICS_ID_DATA, INSIST_ERR, LOG, mgmt_client, mgmt_timer_id, MSG_GET_PEER, MSG_ID, and RETRY_CONNECT_INTERVAL.

Referenced by connect_mgmt().

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

Message handler for open connections. We receive MSG_HELLO and MSG_PEER 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 288 of file hellopics-data_conn.c.

References ctrl_client, CTRL_CLIENT_CONNECT_RETRIES, ctrl_client_connection(), ctrl_client_message(), ev_ctx, HELLOPICS_PORT_NUM, INSIST_ERR, LOG, mgmt_client, MSG_HELLO, and MSG_PEER.

Referenced by connect_mgmt().


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-data 1.0 by Doxygen 1.5.1