예제 #1
0
파일: dhcp.c 프로젝트: frozensunq/thudhcp
void handle_dhcp()
{
	fprintf(err, "Sleep for %d seconds...\n", ack_lease.renew_time);
	sleep(ack_lease.renew_time);
	memcpy(&offer_lease, &ack_lease, sizeof(struct lease));
	renew = 1;
	generate_xid();
	next_state = REQUEST;
	dhcp_request();
}
예제 #2
0
파일: xid_table.c 프로젝트: Darma/trema
static xid_entry_t *
allocate_xid_entry( uint32_t original_xid, char *service_name, int index ) {
  xid_entry_t *new_entry;

  new_entry = xmalloc( sizeof ( xid_entry_t ) );
  new_entry->xid = generate_xid();
  new_entry->original_xid = original_xid;
  new_entry->service_name = xstrdup( service_name );
  new_entry->index = index;

  return new_entry;
}
예제 #3
0
파일: ofpmsg_send.c 프로젝트: Darma/trema
int
ofpmsg_send_featuresrequest( struct switch_info *sw_info ) {
  int ret;
  buffer *buf;

  buf = create_features_request( generate_xid() );

  ret = send_to_secure_channel( sw_info, buf );
  if ( ret == 0 ) {
    debug( "Send 'features request' to a switch. fd:%d", sw_info->secure_channel_fd );
  }

  return ret;
}
예제 #4
0
파일: dhcp.c 프로젝트: frozensunq/thudhcp
void init_dhcp()
{
	timeout_count = TIMEOUT_RETRY_TIMES;
	
	if (load_lease(&offer_lease)) {
		renew = 1;
		generate_xid();
		next_state = REQUEST;
		dhcp_request();
	} else {
		next_state = DISCOVER;
		dhcp_discover();
	}
}
예제 #5
0
파일: ofpmsg_send.c 프로젝트: Darma/trema
int
ofpmsg_send_setconfig( struct switch_info *sw_info ) {
  int ret;
  buffer *buf;

  buf = create_set_config( generate_xid(), sw_info->config_flags,
                           sw_info->miss_send_len );

  ret = send_to_secure_channel( sw_info, buf );
  if ( ret == 0 ) {
    debug( "Send 'set config request' to a switch %#" PRIx64 ".", sw_info->datapath_id );
  }

  return ret;
}
예제 #6
0
파일: ofpmsg_send.c 프로젝트: Darma/trema
int
ofpmsg_send_delete_all_flows( struct switch_info *sw_info ) {
  int ret;
  struct ofp_match match;
  buffer *buf;

  memset( &match, 0, sizeof( match ) );
  match.wildcards = OFPFW_ALL;

  buf = create_flow_mod( generate_xid(), match, RESERVED_COOKIE,
                         OFPFC_DELETE, 0, 0, 0, UINT32_MAX, OFPP_NONE, 0, NULL );

  ret = send_to_secure_channel( sw_info, buf );
  if ( ret == 0 ) {
    debug( "Send 'flow mod (delete all)' to a switch %#" PRIx64 ".", sw_info->datapath_id );
  }

  return ret;
}
예제 #7
0
파일: ofpmsg_send.c 프로젝트: Darma/trema
int
ofpmsg_send_error_msg( struct switch_info *sw_info, uint16_t type, uint16_t code, buffer *data ) {
  int ret;
  buffer *buf;

  if (data->length > OFP_ERROR_MSG_MAX_DATA ) {
    // FIXME
    data->length = OFP_ERROR_MSG_MAX_DATA;
  }

  buf = create_error( generate_xid(), type, code, data );

  ret = send_to_secure_channel( sw_info, buf );
  if ( ret == 0 ) {
    debug( "Send 'error' to a switch %#" PRIx64 ".", sw_info->datapath_id );
  }

  return ret;
}
예제 #8
0
파일: dhcp.c 프로젝트: frozensunq/thudhcp
void dhcp_discover()
{
	if (next_state != DISCOVER) {
		fprintf(err, "State is not DISCOVER!\n");
		return;
	}
	fprintf(err, "dhcp_discover()...\n");
	
	generate_xid();
	renew = 0;
	
	int len;
	struct dhcp_packet *packet = make_packet(&len);
	send_packet((char*)packet, len);
	free(packet);
	
	next_state = OFFER;
	dhcp_offer();
}
예제 #9
0
int
cc_send_features_request( sw_info* cc_sw_info,buffer* buf )
{
  int ret;
  buffer *buf;
  
  /*NOTICE! here we should add the ofp_pull, to get out of the 
   *exactly ofp msg
   */
  //ofpbuf_pull(buf,ofp_msg);
  buf = cc_create_features_request( generate_xid() );

  ret = cc_send_to_secure_channel( sw_info, buf );
  if ( ret == 0 ) {
    //debug( "Send 'features request' to a switch. fd:%d", sw_info->secure_channel_fd );
  }

  free_buffer()
  return ret;
}
예제 #10
0
파일: switch.c 프로젝트: Milstein/trema
static void
echo_request_interval( void *user_data ) {
  struct switch_info *sw_info = user_data;

  buffer *buf = alloc_buffer();
  echo_body *body = append_back_buffer( buf, sizeof( echo_body ) );
  body->datapath_id = htonll( switch_info.datapath_id );
  struct timespec now;
  clock_gettime( CLOCK_MONOTONIC, &now );
  body->sec = htonl( ( uint32_t ) now.tv_sec );
  body->nsec = htonl( ( uint32_t ) now.tv_nsec );
  sw_info->echo_request_xid = generate_xid();

  int err = ofpmsg_send_echorequest( sw_info, sw_info->echo_request_xid, buf );
  if ( err < 0 ) {
    switch_event_disconnected( &switch_info );
    return;
  }

  switch_set_timeout( ECHO_REPLY_TIMEOUT, echo_reply_timeout, NULL );
}