/***************************************** * * Actually check to see if we have a frame, and process it if we do. * *****************************************/ int eapol_execute(struct interface_data *workint) { char newframe[1518], respframe[1518]; int framesize, respsize, retval=0; struct eapol_header *temp; char *inframe; // A pointer to our frame data. (Normally will point // to the newframe[] array.) if (!workint) { debug_printf(DEBUG_NORMAL, "NULL data passed in to eapol_execute()!\n"); return XEMALLOC; } bzero(&newframe, 1518); if (getframe(workint, (char *)&newframe, &framesize) < 0) { debug_printf(DEBUG_EXCESSIVE, "There are no frames to process.\n"); framesize = 0; retval = XENOFRAMES; inframe = NULL; // Have the EAP types process, if they are in // a state to request information from the GUI. } else { // We want to let getframe be called, even if we don't have any // config information. That will keep the frame queue empty so that // when we do have enough config information we can start by processing // an EAP request that is valid. If we don't have any config informtion, // we should just bail here, and not return an error. inframe = (char *)&newframe; if (workint->userdata == NULL) return XEMALLOC; temp = (struct eapol_header *)&newframe[OFFSET_PAST_MAC]; if (ntohs(temp->frame_type) == 0x888e) { if (temp->eapol_version > MAX_EAPOL_VER) { debug_printf(DEBUG_EVERYTHING, "Got invalid EAPOL frame!\n"); framesize = 0; } else { switch (temp->eapol_type) { case EAP_PACKET: // Process the EAP header, and determine if we need to set // any state machine variables. eap_process_header(workint, (char *)&newframe, framesize); break; case EAPOL_START: debug_printf(DEBUG_NORMAL, "Got EAPoL-Start! Ignoring!\n"); return XEIGNOREDFRAME; case EAPOL_LOGOFF: debug_printf(DEBUG_NORMAL, "Got EAPoL-Logoff! Ignoring!\n"); return XEIGNOREDFRAME; case EAPOL_KEY: debug_printf(DEBUG_NORMAL, "Processing EAPoL-Key!\n"); workint->statemachine->rxKey = TRUE; run_key_statemachine(workint, (char *)&newframe, framesize); return XGOODKEYFRAME; case EAPOL_ASF_ALERT: debug_printf(DEBUG_NORMAL, "Got EAPoL-ASF-Alert!\n"); return XEIGNOREDFRAME; default: debug_printf(DEBUG_NORMAL, "Unknown EAPoL type! (%02X)\n", temp->eapol_type); return XEIGNOREDFRAME; } } } else { debug_printf(DEBUG_EVERYTHING, "Got a frame, but it isn't an EAPoL frame, ignoring.\n"); } } // Process our state machine. if (statemachine_run(workint, inframe, framesize, (char *)&respframe, &respsize) == XDATA) { // Send a frame out. sendframe(workint, (char *)&respframe, respsize); } return XENONE; }
/** * @breaf initialize the pfon comunication * * @param no parametrs */ int8_t FON_INIT() { enum fbus_frametype ftype; char buffer[24]; memset(buffer, 0, sizeof(buffer)); //write mesage in EEPPROM /* eeprom_read_block(buffer, (int*) 486, 18); if (strlen(buffer) == 0) { strcpy_P(buffer, CMD_ERR); eeprom_write_block(buffer, (int*) 486, 18); //strcpy_P(buffer, 0x00); } */ SetPort(); strcpy_P(buffer, CMD_ERR); eeprom_update_block(buffer, (int*) 486, 18); uint8_t init[] = { 0x00, 0x01, 0x64, 0x01, 0x01, 0x40 }; fbus_init(); sendframe(0x40, init, 6); ftype = fbus_readack(); if (ftype == FRAME_UNKNOWN) { sendframe(0x40, init, 6); ftype = fbus_readack(); if (ftype == FRAME_UNKNOWN) { sendframe(0x40, init, 6); ftype = fbus_readack(); if (ftype == FRAME_UNKNOWN) { PORTB |= (1 << PB5); //eror return 0; } } } //save smsc number if is not saved char smsc_nr[18]; memset(smsc_nr, 0, sizeof(smsc_nr)); _delay_ms(1000); fbus_getsmsc(smsc_nr); /* eeprom_read_block(buffer, (int*) 360, 18); if ((strcmp(smsc_nr, buffer) != 0) && (strlen(smsc_nr) != 0)) eeprom_write_block(smsc_nr, (int*) 360, 18); */ if (strlen(smsc_nr) != 0) eeprom_update_block(smsc_nr, (int*) 360, 18); sendack(0x02, 0x04); uint8_t init_sms[] = { 0x00, 0x01, 0x00, 0x07, 0x02, 0x01, 0x01, 0x64, 0x01, 0x47 }; sendframe(0x02, init_sms, 0x0a); //fbus_readack(); sendack(0x14, 0x00); //uart_sendsms("+40744946000", "+40745183841", smsc_nr); return 1; }