示例#1
0
static int send_usrname(EAP_FRAME *requestframe)
{
    memcpy(Eap_response_ident->DestMac,Nearest_mac,MAC_ADDRESS_LEN);

    Eap_response_ident->Length = username_len+EAP_EXTENDATA_BASE_LEN;
    swapbyte((u_char*)&Eap_response_ident->Length);

    Eap_response_ident->ExtenData.Length = username_len+EAP_EXTENDATA_BASE_LEN;
    swapbyte((u_char*)&Eap_response_ident->ExtenData.Length);

    Eap_response_ident->ExtenData.Id = requestframe->ExtenData.Id;

    memcpy(Eap_response_ident->ExtenData.Data,username,username_len);

    /* printf("size %d\n",sizeof(*Eap_response_ident)); */
    if (pcap_sendpacket(handle, (u_char*)Eap_response_ident, EAP_MESSAGE_LEN) != 0)
    {
        printf("Error Sending the packet: %s\n", pcap_geterr(handle));
        return ERROR;
    }
    if(debug_mode)
    {
        printf("EAP-Response-Identity sending...\n");
    }
    //exit(0);
    return DONE;
}
示例#2
0
/*
** reverse the order of all bytes
** this works on floats and ints
*/
static void convert8byte(char *x)
{
  swapbyte(x, x+7);
  swapbyte(x+1, x+6);
  swapbyte(x+2, x+5);
  swapbyte(x+3, x+4);
}
示例#3
0
static int send_passwd(EAP_FRAME *requestframe)
{
    u_char str[MAX_MD5_STR];
    int len;

    EAP_MD5_VALUE *final_key = (EAP_MD5_VALUE*)(Eap_response_md5->ExtenData.Data);
    EAP_MD5_VALUE *attach_key = (EAP_MD5_VALUE*)requestframe->ExtenData.Data;
    printf("length of challenge value: %d\n",attach_key->Size);

    final_key->Size = attach_key->Size;

    memcpy(str,&requestframe->ExtenData.Id,sizeof(u_char));
    len = sizeof(u_char);

    memcpy(str+len,password,password_len);
    len += password_len;

    memcpy(str+len,attach_key->value,attach_key->Size);
    len += attach_key->Size;

    memcpy(final_key->value,get_md5(str,len),final_key->Size);


    memcpy(Eap_response_md5->DestMac,Nearest_mac,MAC_ADDRESS_LEN);

    Eap_response_md5->Length = username_len+EAP_EXTENDATA_BASE_LEN+sizeof(EAP_MD5_VALUE);
    swapbyte((u_char*)&Eap_response_md5->Length);

    Eap_response_md5->ExtenData.Length = username_len+EAP_EXTENDATA_BASE_LEN+sizeof(EAP_MD5_VALUE);
    swapbyte((u_char*)&Eap_response_md5->ExtenData.Length);

    Eap_response_md5->ExtenData.Id = requestframe->ExtenData.Id;

    memcpy(Eap_response_md5->ExtenData.Data+sizeof(EAP_MD5_VALUE),username,username_len);

    printf("size %d\n",sizeof(*Eap_response_md5));
    if (pcap_sendpacket(handle, (u_char*)Eap_response_md5, EAP_MESSAGE_LEN) != 0)
    {
        printf("Error Sending the packet: %s\n", pcap_geterr(handle));
        return ERROR;
    }
    printf("EAP-Response_MD5_Challenge sending...\n");
    //exit(0);
    return DONE;
}
示例#4
0
文件: kup4k.c 项目: Ingramz/u-boot
int checkboard(void)
{
	volatile immap_t *immap = (immap_t *) CONFIG_SYS_IMMR;
	uchar rev,mod,tmp,pcf,ak_rev,ak_mod;

	/*
	 * Init ChipSelect #4 (CAN + HW-Latch)
	 */
	out_be32(&immap->im_memctl.memc_or4, CONFIG_SYS_OR4);
	out_be32(&immap->im_memctl.memc_br4, CONFIG_SYS_BR4);

	/*
	 * Init ChipSelect #5 (S1D13768)
	 */
	out_be32(&immap->im_memctl.memc_or5, CONFIG_SYS_OR5);
	out_be32(&immap->im_memctl.memc_br5, CONFIG_SYS_BR5);

	tmp = swapbyte(in_8((unsigned char*) LATCH_ADDR));
	rev = (tmp & 0xF8) >> 3;
	mod = (tmp & 0x07);

	i2c_init(CONFIG_SYS_I2C_SPEED, CONFIG_SYS_I2C_SLAVE);

	if (read_diag())
		gd->flags &= ~GD_FLG_SILENT;

	printf("Board: KUP4K Rev %d.%d AK:",rev,mod);
	/*
	 * TI Application report: Before using the IO as an input,
	 * a high must be written to the IO first
	 */
	pcf = 0xFF;
	i2c_write(0x21, 0, 0 , &pcf, 1);
	if (i2c_read(0x21, 0, 0, &pcf, 1)) {
		puts("n/a\n");
	} else {
		ak_rev = (pcf & 0xF8) >> 3;
		ak_mod = (pcf & 0x07);
		printf("%d.%d\n", ak_rev, ak_mod);
	}
	return 0;
}
示例#5
0
文件: ceos.c 项目: 0004c/node-gdal
void NativeToCeos( void *dst, const void *src, const size_t len, const size_t swapunit)
{
    int i;
    int remainder;
    int units;


    remainder = len % swapunit;

    units = len - remainder;

    for(i = 0;i < units; i += swapunit )
    {
	swapbyte( ( unsigned char *) dst + i, ( unsigned char * ) src + i, swapunit);
    }

    if(remainder)
    {
	memcpy( ( unsigned char * ) dst + i, ( unsigned char * ) src + i, remainder );
    }
}
示例#6
0
文件: kup4k.c 项目: Ingramz/u-boot
phys_size_t initdram(int board_type)
{
	volatile immap_t *immap = (immap_t *) CONFIG_SYS_IMMR;
	volatile memctl8xx_t *memctl = &immap->im_memctl;
	long int size = 0;
	uchar *latch, rev, tmp;

	/*
	 * Init ChipSelect #4 (CAN + HW-Latch) to determine Hardware Revision
	 * Rev 1..6 -> 48 MB RAM;   Rev >= 7 -> 96 MB
	 */
	out_be32(&immap->im_memctl.memc_or4, CONFIG_SYS_OR4);
	out_be32(&immap->im_memctl.memc_br4, CONFIG_SYS_BR4);

	latch = (uchar *)0x90000200;
	tmp = swapbyte(*latch);
	rev = (tmp & 0xF8) >> 3;

	upmconfig(UPMA, (uint *) sdram_table,
		   sizeof (sdram_table) / sizeof (uint));

	out_be16(&memctl->memc_mptpr, CONFIG_SYS_MPTPR);

	out_be32(&memctl->memc_mar, 0x00000088);
	/* no refresh yet */
	if(rev >= 7) {
		out_be32(&memctl->memc_mamr,
				 CONFIG_SYS_MAMR_9COL & (~(MAMR_PTAE)));
	} else {
		out_be32(&memctl->memc_mamr,
				 CONFIG_SYS_MAMR_8COL & (~(MAMR_PTAE)));
	}

	udelay(200);

	/* perform SDRAM initializsation sequence */

	/* SDRAM bank 0 */
	out_be32(&memctl->memc_mcr, 0x80002105);
	udelay(1);
	out_be32(&memctl->memc_mcr, 0x80002830); /* execute twice */
	udelay(1);
	out_be32(&memctl->memc_mcr, 0x80002106); /* RUN MRS Pattern from loc 6 */
	udelay(1);

	/* SDRAM bank 1 */
	out_be32(&memctl->memc_mcr, 0x80004105);
	udelay(1);
	out_be32(&memctl->memc_mcr, 0x80004830); /* execute twice */
	udelay(1);
	out_be32(&memctl->memc_mcr, 0x80004106); /* RUN MRS Pattern from loc 6 */
	udelay(1);

	/* SDRAM bank 2 */
	out_be32(&memctl->memc_mcr, 0x80006105);
	udelay(1);
	out_be32(&memctl->memc_mcr, 0x80006830); /* execute twice */
	udelay(1);
	out_be32(&memctl->memc_mcr, 0x80006106); /* RUN MRS Pattern from loc 6 */
	udelay(1);

	setbits_be32(&memctl->memc_mamr, MAMR_PTAE); /* enable refresh */
	udelay(1000);

	out_be16(&memctl->memc_mptpr, CONFIG_SYS_MPTPR);
	udelay(1000);
	if(rev >= 7) {
		size = 32 * 3 * 1024 * 1024;
		out_be32(&memctl->memc_or1, CONFIG_SYS_OR1_9COL);
		out_be32(&memctl->memc_br1, CONFIG_SYS_BR1_9COL);
		out_be32(&memctl->memc_or2, CONFIG_SYS_OR2_9COL);
		out_be32(&memctl->memc_br2, CONFIG_SYS_BR2_9COL);
		out_be32(&memctl->memc_or3, CONFIG_SYS_OR3_9COL);
		out_be32(&memctl->memc_br3, CONFIG_SYS_BR3_9COL);
	} else {
		size = 16 * 3 * 1024 * 1024;
		out_be32(&memctl->memc_or1, CONFIG_SYS_OR1_8COL);
		out_be32(&memctl->memc_br1, CONFIG_SYS_BR1_8COL);
		out_be32(&memctl->memc_or2, CONFIG_SYS_OR2_8COL);
		out_be32(&memctl->memc_br2, CONFIG_SYS_BR2_8COL);
		out_be32(&memctl->memc_or3, CONFIG_SYS_OR3_8COL);
		out_be32(&memctl->memc_br3, CONFIG_SYS_BR3_8COL);
	}
	return (size);
}
示例#7
0
/*
** reverse the order of all bytes
** this works on floats and ints
*/
static void convert4byte(char *x)
{
  swapbyte(x, x+3);
  swapbyte(x+1, x+2);
}
示例#8
0
/*
** convert two byte quantities by byte swapping
** Pass the address of the 2 byte value to be converted
** it is converted in place
*/
static void convert2byte(char *x)
{
  swapbyte(x, x+1);
}