⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cardif_radius.c

📁 linux 下通过802.1认证的安装包
💻 C
📖 第 1 页 / 共 2 页
字号:

  if (send_eap_id < (TO_SEND_IDS+1)) return OFFSET_TO_DATA;

  if (size < 0) return XENOFRAMES;

  debug_printf(DEBUG_NORMAL, "Got :\n");
  debug_hex_dump(DEBUG_NORMAL, packet, size);

  radsiz = verify_rad_hdr(packet, size);

  if (radsiz == 0xffff)
    {
      debug_printf(DEBUG_NORMAL, "Got an Access-Reject\n");
      ctx->eap_state->rxFailure = TRUE;
      return 0;
    }

  debug_printf(DEBUG_NORMAL, "Packet size is %d!\n", radsiz);

  // Process AVPs.
  offset = sizeof(struct radius_pkt);
  eapptr = OFFSET_TO_EAP;

  while (offset < radsiz)
    {
      radavp = (struct radius_avp *)&packet[offset];

      switch (radavp->attribute)
	{
	case RADIUS_AVP_EAPMSG:
          memcpy(&ctx->recvframe[eapptr], &packet[offset+2], radavp->length-2);
          offset += radavp->length;
          eapptr += radavp->length - 2;
	  break;
	  
	default:
	  debug_printf(DEBUG_NORMAL, "Skipping AVP %02X\n", radavp->attribute);
	  offset += radavp->length;
	  break;
	}
    }

  eapolhdr = (struct eapol_header *)&ctx->recvframe[OFFSET_PAST_MAC];

  eapolhdr->frame_type = htons(EAPOL_FRAME);
  eapolhdr->eapol_version = 1;
  eapolhdr->eapol_type = EAP_PACKET;
  eapolhdr->eapol_length = htons(sizeof(struct eapol_header)+sizeof(struct eap_header));

  debug_printf(DEBUG_INT, "EAP Packet Dump : \n");
  debug_hex_dump(DEBUG_INT, ctx->recvframe, eapptr);

  return eapptr;
}

uint8_t cardif_radius_eap_sm(context *ctx)
{
  struct eap_header *eaphdr;
  struct eapol_header *eapolhdr;

  if (send_eap_id < TO_SEND_IDS)
    {
      // We need to fake an EAP request ID.
      debug_printf(DEBUG_NORMAL, "Building fake EAP request ID.\n");

      if (config_build("radius") != TRUE)
	{
	  debug_printf(DEBUG_NORMAL, "Couldn't build config for network "
		       "\"radius\"!\n");
	  return FALSE;
	}

      eaphdr = Malloc(sizeof(struct eap_header));
      if (eaphdr == NULL)
	{
	  debug_printf(DEBUG_NORMAL, "Couldn't allocate memory for faked "
		       "EAP request ID!\n");
	  debug_printf(DEBUG_NORMAL, "Nothing to do!\n");
	  send_eap_id++;  // To avoid looping and filling the screen.
	  return FALSE;
	}

      eaphdr->eap_code = EAP_REQUEST_PKT;
      eaphdr->eap_identifier = send_eap_id+1;
      eaphdr->eap_length = htons(sizeof(struct eap_header));
      eaphdr->eap_type = EAP_REQUEST_ID;

      memcpy(&ctx->recvframe[OFFSET_TO_EAP], (uint8_t *)eaphdr, 
	     sizeof(struct eap_header));

      FREE(eaphdr);

      eapolhdr = Malloc(sizeof(struct eapol_header));
      if (eapolhdr == NULL)
	{
	  debug_printf(DEBUG_NORMAL, "Couldn't allocate memory to fake EAPoL "
		       "header!\n");
	  return FALSE;
	}

      eapolhdr->frame_type = htons(EAPOL_FRAME);
      eapolhdr->eapol_version = 1;
      eapolhdr->eapol_type = EAP_PACKET;
      eapolhdr->eapol_length = htons(sizeof(struct eapol_header)+sizeof(struct eap_header));
      memcpy(&ctx->recvframe[OFFSET_PAST_MAC], eapolhdr, 
             sizeof(struct eapol_header));

      debug_printf(DEBUG_NORMAL, "EAPoL Header : \n");
      debug_hex_dump(DEBUG_NORMAL, (uint8_t *)eapolhdr, 
		     sizeof(struct eapol_header));

      debug_printf(DEBUG_NORMAL, "Frame dump : \n");
      debug_hex_dump(DEBUG_NORMAL, (uint8_t *)&ctx->recvframe, ctx->recv_size);

      FREE(eapolhdr);

      ctx->recv_size = OFFSET_TO_DATA;
      ctx->eap_state->eapReq = TRUE;

      ctx->statemachine->eapolEap = TRUE;
      ctx->statemachine->suppStart = TRUE;

      send_eap_id++;
      return TRUE;
    }
  // Otherwise, do nothing.
  send_eap_id = 0xff;
  return FALSE;
}

void cardif_clock_tick(context *ctx)
{
}

int cardif_get_if_state(context *ctx)
{
  // Assume that this "interface" is always up.
  return TRUE;
}

int cardif_int_is_valid(char *intname)
{
  if (strcmp(intname, "radius") == 0)
    {
      return TRUE;
    }

  return FALSE;
}

int cardif_check_dest(context *ctx)
{
  return TRUE;
}

int cardif_validate(char *intname)
{
  if (strcmp(intname, "radius") == 0)
    {
      return TRUE;
    }

  return FALSE;
}

char *cardif_get_search_ssid()
{
  return NULL;
}

void cardif_set_search_ssid(char *newssid)
{

}

int cardif_enable_wpa(context *ctx)
{
  return XENOWIRELESS;
}

int cardif_do_wireless_scan(context *ctx, char *c)
{
  return XENOWIRELESS;
}

int cardif_set_wep_key(context *ctx, uint8_t *key, int size1, int size2)
{
  return XENOWIRELESS;
}

int cardif_set_tkip_key(context *ctx, char *c, int i1, int i2, char *c2,
			int i3)
{
  return XENOWIRELESS;
}

int cardif_set_ccmp_key(context *ctx, char *c, int i1, int i2, char *c2,
			int i3)
{
  return XENOWIRELESS;
}

int cardif_delete_key(context *ctx, int i1, int i2)
{
  return XENOWIRELESS;
}

void cardif_associate(context *ctx)
{
  debug_printf(DEBUG_NORMAL, "Got an association call for the RADIUS driver."
	       "\n");
}

int cardif_disassociate(context *ctx, int i1)
{
  debug_printf(DEBUG_NORMAL, "Got a disassociation call for the RADIUS "
	       "driver\n");
  return XENOWIRELESS;
}

int cardif_GetSSID(context *ctx, char *ssid)
{
  return XENOWIRELESS;
}

int cardif_check_ssid(context *ctx)
{
  return XENOWIRELESS;
}

int cardif_GetBSSID(context *ctx, char *ssid)
{
  return XENOWIRELESS;
}

int cardif_setBSSID(context *ctx, uint8_t *newssid)
{
  return XENOWIRELESS;
}

int cardif_int_is_wireless(char *intname)
{
  return FALSE;
}

int cardif_wep_associate(context *ctx, int zs)
{
  return XENOWIRELESS;
}

int cardif_disable_wpa_state(context *ctx)
{
  return XENOWIRELESS;
}

int cardif_enable_wpa_state(context *ctx)
{
  return XENOWIRELESS;
}

int cardif_drop_unencrypted(context *ctx, char c)
{
  return XENOWIRELESS;
}

int cardif_countermeasures(context *ctx, char c)
{
  return XENOWIRELESS;
}

int cardif_get_wpa_ie(context *ctx, char *c, int *i)
{
  return XENOWIRELESS;
}

int cardif_get_wpa2_ie(context *ctx, char *c, int *i)
{
  return XENOWIRELESS;
}

int cardif_clear_keys(context *ctx)
{
  return XENOWIRELESS;
}

int cardif_check_associated(context *ctx)
{
  return XENOWIRELESS;
}

void cardif_reassociate(context *ctx, uint8_t i)
{
  // Do nothing
}

void cardif_association_timeout_expired(context *ctx)
{
  // Do nothing
}

int cardif_enc_disable(context *ctx)
{
  return XENOWIRELESS;
}

void cardif_get_abilities(context *ctx)
{
  // Do nothing.
}

void cardif_wait_for_int(char *intname)
{
  // Do nothing.
}

void cardif_passive_scan_timeout(context *ctx)
{
  // Do nothing.
}

void cardif_operstate(context *ctx, uint8_t state)
{
  // Do nothing.
}

void cardif_linkmode(context *ctx, uint8_t state)
{
  // Do nothing.
}

#endif // USE_DIRECT_RADIUS

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -