Example #1
0
int ampe_initialize(struct mesh_node *mesh, struct ampe_cb *callbacks) {
  int sup_rates_len;

  if (!check_callbacks(callbacks))
    return -1;

  cb = callbacks;

  /* TODO: move these to a config file */
  ampe_conf.retry_timeout_ms = 1000;
  ampe_conf.holding_timeout_ms = 10000;
  ampe_conf.confirm_timeout_ms = 1000;
  ampe_conf.max_retries = 10;
  ampe_conf.mesh = mesh;

  if (mesh->conf->is_secure) {
    RAND_bytes(mgtk_tx, 16);
    sae_hexdump(AMPE_DEBUG_KEYS, "mgtk: ", mgtk_tx, sizeof(mgtk_tx));
  }

  if (mesh->conf->pmf) {
    RAND_bytes(mesh->igtk_tx, 16);
    mesh->igtk_keyid = 4;
    memset(mesh->igtk_ipn, 0, sizeof(mesh->igtk_ipn));
    sae_hexdump(
        AMPE_DEBUG_KEYS, "igtk: ", mesh->igtk_tx, sizeof(mesh->igtk_tx));
  }

  /* We can do this because valid supported rates non null and the array is null
   * terminated */
  sup_rates_len = strnlen((char *)mesh->conf->rates, sizeof(mesh->conf->rates));
  if (sup_rates_len <= 8) {
    /*  rates fit into a the supported rates IE */
    sta_fixed_ies_len = 2 + sup_rates_len;
    sta_fixed_ies = malloc(sta_fixed_ies_len);
    *sta_fixed_ies = IEEE80211_EID_SUPPORTED_RATES;
    *(sta_fixed_ies + 1) = sup_rates_len;
    memcpy(sta_fixed_ies + 2, mesh->conf->rates, sup_rates_len);
  } else if (sup_rates_len < sizeof(mesh->conf->rates)) {
    /*  rates overflow onto the extended supported rates IE */
    sta_fixed_ies_len = 4 + sup_rates_len;
    sta_fixed_ies = malloc(sta_fixed_ies_len);
    *sta_fixed_ies = IEEE80211_EID_SUPPORTED_RATES;
    *(sta_fixed_ies + 1) = 8;
    memcpy(sta_fixed_ies + 2, mesh->conf->rates, 8);
    *(sta_fixed_ies + 10) = IEEE80211_EID_EXTENDED_SUP_RATES;
    *(sta_fixed_ies + 11) = sup_rates_len - 8;
    memcpy(sta_fixed_ies + 12, mesh->conf->rates + 8, sup_rates_len - 8);
  } else {
    sae_debug(SAE_DEBUG_ERR, "mesh->conf->rates should be null-terminated");
    return -1;
  }

  sae_hexdump(
      MESHD_DEBUG,
      "Fixed Information Elements in this STA",
      sta_fixed_ies,
      sta_fixed_ies_len);
  return 0;
}
Example #2
0
/*! \brief
 * Checks the validity of a selection method.
 *
 * \param[in]     fp     File handle to use for diagnostic messages
 *   (can be NULL).
 * \param[in,out] method Method to check.
 * \param[in]     symtab Symbol table (used for checking overlaps).
 *
 * Checks the validity of the given selection method data structure
 * that does not have \ref SMETH_MODIFIER set.
 * If you remove a check, please make sure that the selection parser,
 * compiler, and evaluation functions can deal with the method.
 */
static bool
check_method(FILE *fp, gmx_ana_selmethod_t *method,
             const gmx::SelectionParserSymbolTable &symtab)
{
    bool         bOk = true;

    /* Check the type */
    if (method->type == NO_VALUE)
    {
        report_error(fp, method->name, "error: no value type specified");
        bOk = false;
    }
    if (method->type == STR_VALUE && method->nparams > 0)
    {
        report_error(fp, method->name, "error: evaluates to a string but is not a keyword");
        bOk = false;
    }
    /* Check flags */
    if (method->type == GROUP_VALUE)
    {
        /* Group methods should always have SMETH_SINGLEVAL,
         * so set it for convenience. */
        method->flags |= SMETH_SINGLEVAL;
        /* Check that conflicting flags are not present. */
        if (method->flags & SMETH_VARNUMVAL)
        {
            report_error(fp, method->name, "error: SMETH_VARNUMVAL cannot be set for group-valued methods");
            bOk = false;
        }
    }
    else
    {
        if ((method->flags & SMETH_SINGLEVAL)
            && (method->flags & SMETH_VARNUMVAL))
        {
            report_error(fp, method->name, "error: SMETH_SINGLEVAL and SMETH_VARNUMVAL both set");
            bOk = false;
        }
    }
    if ((method->flags & SMETH_CHARVAL) && method->type != STR_VALUE)
    {
        report_error(fp, method->name, "error: SMETH_CHARVAL can only be specified for STR_VALUE methods");
        bOk = false;
    }
    /* Check the parameters */
    if (!check_params(fp, method->name, method->nparams, method->param, symtab))
    {
        bOk = false;
    }
    /* Check the callback pointers */
    if (!check_callbacks(fp, method))
    {
        bOk = false;
    }

    return bOk;
}
Example #3
0
int network_client_main_loop ( )
{
	fd_set testfds;

	univention_debug( UV_DEBUG_TRANSFILE, UV_DEBUG_INFO, "Starting main loop\n");
	/* create listener socket */

	FD_ZERO(&readfds);
	FD_SET(server_socketfd_listener, &readfds);

	/* main loop */
	while(1) {
		int fd;
		int rc;

		testfds = readfds;
		if( ((rc=select (FD_SETSIZE, &testfds, (fd_set*)0, (fd_set*)0, (struct timeval *) 0))) < 1) {
								  /*FIXME */
			if ( errno == EINTR || errno == 29) {
				/* Ignore signal */
				check_callbacks();
				continue;
			}
			univention_debug(UV_DEBUG_TRANSFILE, UV_DEBUG_ERROR, "unkonwn select error, exit");
			exit(1);
		}


		for(fd=0; fd < FD_SETSIZE; fd++) {
			if( FD_ISSET(fd,&testfds)) {
				NetworkClient_t *tmp;
				for ( tmp = network_client_first; tmp != NULL; tmp = tmp->next) {
					if ( tmp->fd == fd ) {
						tmp->handler(fd, network_client_del);
						break;
					}
				}
			}
		}
		check_callbacks();
	}

	return 0;
}
Example #4
0
/*! \brief
 * Checks the validity of a selection modifier method.
 *
 * \param[in]     fp     File handle to use for diagnostic messages
 *   (can be NULL).
 * \param[in,out] method Method to check.
 * \param[in]     symtab Symbol table (used for checking overlaps).
 *
 * Checks the validity of the given selection method data structure
 * that has \ref SMETH_MODIFIER set.
 * If you remove a check, please make sure that the selection parser,
 * compiler, and evaluation functions can deal with the method.
 */
static bool
check_modifier(FILE *fp, gmx_ana_selmethod_t *method,
               const gmx::SelectionParserSymbolTable &symtab)
{
    bool         bOk = true;

    /* Check the type */
    if (method->type != NO_VALUE && method->type != POS_VALUE)
    {
        report_error(fp, method->name, "error: modifier should have type POS_VALUE or NO_VALUE");
        bOk = false;
    }
    /* Check flags */
    if (method->flags & (SMETH_SINGLEVAL | SMETH_VARNUMVAL))
    {
        report_error(fp, method->name, "error: modifier should not have SMETH_SINGLEVAL or SMETH_VARNUMVAL set");
        bOk = false;
    }
    /* Check the parameters */
    /* The first parameter is skipped */
    if (!check_params(fp, method->name, method->nparams-1, method->param+1, symtab))
    {
        bOk = false;
    }
    /* Check the callback pointers */
    if (!check_callbacks(fp, method))
    {
        bOk = false;
    }
    if (method->update)
    {
        report_error(fp, method->name, "error: modifier should not have update");
        bOk = false;
    }
    if (method->type == POS_VALUE && !method->pupdate)
    {
        report_error(fp, method->name, "error: evaluation function missing");
        bOk = false;
    }

    return bOk;
}
Example #5
0
void CControlAnimation::update_frame() 
{
	if (m_freeze) return;
	
	// move to schedule update
	START_PROFILE("BaseMonster/Animation/Update Tracks");
	m_skeleton_animated->UpdateTracks	();	
	STOP_PROFILE;
	
	START_PROFILE("BaseMonster/Animation/Check callbacks");
	check_callbacks						();
	STOP_PROFILE;
	
	START_PROFILE("BaseMonster/Animation/Play");
	play								();	
	STOP_PROFILE;

	START_PROFILE("BaseMonster/Animation/Check Events");
	check_events						(m_data.global);
	check_events						(m_data.torso);
	check_events						(m_data.legs);
	STOP_PROFILE;
}