Exemple #1
0
void parse_wps_settings(const u_char *packet, struct pcap_pkthdr *header, char *target, int passive, int mode, int source)
{
	struct radio_tap_header *rt_header = NULL;
	struct dot11_frame_header *frame_header = NULL;
	struct libwps_data *wps = NULL;
	enum encryption_type encryption = NONE;
	char *bssid = NULL, *ssid = NULL, *lock_display = NULL;
	int wps_parsed = 0, probe_sent = 0, channel = 0, rssi = 0;
	static int channel_changed = 0;

	wps = malloc(sizeof(struct libwps_data));
	memset(wps, 0, sizeof(struct libwps_data));

	if(packet == NULL || header == NULL || header->len < MIN_BEACON_SIZE)
        {
                goto end;
        }

	rt_header = (struct radio_tap_header *) radio_header(packet, header->len);
	frame_header = (struct dot11_frame_header *) (packet + rt_header->len);

	/* If a specific BSSID was specified, only parse packets from that BSSID */
	if(!is_target(frame_header))
	{
		goto end;
	}

	set_ssid(NULL);
	bssid = (char *) mac2str(frame_header->addr3, ':');

	if(bssid)
	{
		if((target == NULL) ||
		   (target != NULL && strcmp(bssid, target) == 0))
		{
			channel = parse_beacon_tags(packet, header->len);
			rssi = signal_strength(packet, header->len);
			ssid = (char *) get_ssid();

			if(target != NULL && channel_changed == 0)
			{
				ualarm(0, 0);
				change_channel(channel);
				channel_changed = 1;
			}

			if(frame_header->fc.sub_type == PROBE_RESPONSE ||
                                   frame_header->fc.sub_type == SUBTYPE_BEACON)
			{
				wps_parsed = parse_wps_parameters(packet, header->len, wps);
			}
	
			if(!is_done(bssid) && (get_channel() == channel || source == PCAP_FILE || !get_channel()))
			{
				if(frame_header->fc.sub_type == SUBTYPE_BEACON && 
				   mode == SCAN && 
				   !passive && 
				   should_probe(bssid))
				{
					send_probe_request(get_bssid(), get_ssid());
					probe_sent = 1;
				}
		
				if(!insert(bssid, ssid, wps, encryption, rssi))
				{
					update(bssid, ssid, wps, encryption);
				}
				else if(wps->version > 0)
				{
					switch(wps->locked)
					{
						case WPSLOCKED:
							lock_display = YES;
							break;
						case UNLOCKED:
						case UNSPECIFIED:
							lock_display = NO;
							break;
					}

					cprintf(INFO, "%17s      %2d            %.2d        %d.%d               %s               %s\n", bssid, channel, rssi, (wps->version >> 4), (wps->version & 0x0F), lock_display, ssid);
				}

				if(probe_sent)
				{
					update_probe_count(bssid);
				}

				/* 
				 * If there was no WPS information, then the AP does not support WPS and we should ignore it from here on.
				 * If this was a probe response, then we've gotten all WPS info we can get from this AP and should ignore it from here on.
				 */
				if(!wps_parsed || frame_header->fc.sub_type == PROBE_RESPONSE)
				{
					mark_ap_complete(bssid);
				}
	
			}
		}

		/* Only update received signal strength if we are on the same channel as the AP, otherwise power measurements are screwy */
		if(channel == get_channel())
		{
			update_ap_power(bssid, rssi);
		}

		free(bssid);
		bssid = NULL;
	}
 bool is_target(expr * var) {
     rational val;
     return is_target(var, val);
 }
Exemple #3
0
void parse_wps_settings(const u_char *packet, struct pcap_pkthdr *header, char *target, int passive, int mode, int source)
{
    struct radio_tap_header *rt_header = NULL;
    struct dot11_frame_header *frame_header = NULL;
    struct libwps_data *wps = NULL;
    enum encryption_type encryption = NONE;
    char *bssid = NULL, *ssid = NULL, *lock_display = NULL;
    int wps_parsed = 0, probe_sent = 0, channel = 0, rssi = 0;
    static int channel_changed = 0;
    
    char info_manufac[500];
    char info_modelnum[500];
    char info_modelserial[500];

    wps = malloc(sizeof(struct libwps_data));
    memset(wps, 0, sizeof(struct libwps_data));

    if(packet == NULL || header == NULL || header->len < MIN_BEACON_SIZE)
    {
        goto end;
    }

    rt_header = (struct radio_tap_header *) radio_header(packet, header->len);
    frame_header = (struct dot11_frame_header *) (packet + rt_header->len);

    /* If a specific BSSID was specified, only parse packets from that BSSID */
    if(!is_target(frame_header))
    {
        goto end;
    }

    set_ssid(NULL);
    bssid = (char *) mac2str(frame_header->addr3, ':');
    set_bssid((unsigned char *) frame_header->addr3);

    if(bssid)
    {
        if((target == NULL) ||
                (target != NULL && strcmp(bssid, target) == 0))
        {
            channel = parse_beacon_tags(packet, header->len);
            rssi = signal_strength(packet, header->len);
            ssid = (char *) get_ssid();

            if(target != NULL && channel_changed == 0)
            {
                ualarm(0, 0);
                change_channel(channel);
                channel_changed = 1;
            }

            if(frame_header->fc.sub_type == PROBE_RESPONSE ||
                    frame_header->fc.sub_type == SUBTYPE_BEACON)
            {
                wps_parsed = parse_wps_parameters(packet, header->len, wps);
            }

            if(!is_done(bssid) && (get_channel() == channel || source == PCAP_FILE))
            {
                if(frame_header->fc.sub_type == SUBTYPE_BEACON && 
                        mode == SCAN && 
                        !passive && 
                        should_probe(bssid))
                {
                    send_probe_request(get_bssid(), get_ssid());
                    probe_sent = 1;
                }

                if(!insert(bssid, ssid, wps, encryption, rssi))
                {
                    update(bssid, ssid, wps, encryption);
                }
                else if(wps->version > 0)
                {
                    switch(wps->locked)
                    {
                        case WPSLOCKED:
                            lock_display = YES;
                            break;
                        case UNLOCKED:
                        case UNSPECIFIED:
                            lock_display = NO;
                            break;
                    }
					
					//ideas made by kcdtv
					
					if(get_chipset_output == 1)
					//if(1)
					{
						if (c_fix == 0)
						{
							//no use a fixed channel
							cprintf(INFO,"Option (-g) REQUIRES a channel to be set with (-c)\n");
							exit(0);
						}
						
						FILE *fgchipset=NULL;
						char cmd_chipset[4000];
						char cmd_chipset_buf[4000];
						char buffint[5];
						
						char *aux_cmd_chipset=NULL;
						

						
						memset(cmd_chipset, 0, sizeof(cmd_chipset));
						memset(cmd_chipset_buf, 0, sizeof(cmd_chipset_buf));
						memset(info_manufac, 0, sizeof(info_manufac));
                        memset(info_modelnum, 0, sizeof(info_modelnum));
                        memset(info_modelserial, 0, sizeof(info_modelserial));
						

						
						strcat(cmd_chipset,"reaver -0 -s y -vv -i "); //need option to stop reaver in m1 stage
						strcat(cmd_chipset,get_iface());
						
						strcat(cmd_chipset, " -b ");
						strcat(cmd_chipset, mac2str(get_bssid(),':'));
						
						strcat(cmd_chipset," -c ");
						snprintf(buffint, sizeof(buffint), "%d",channel);
						strcat(cmd_chipset, buffint);
						
						//cprintf(INFO,"\n%s\n",cmd_chipset);

						if ((fgchipset = popen(cmd_chipset, "r")) == NULL) {
							printf("Error opening pipe!\n");
							//return -1;
						}
						
						

						while (fgets(cmd_chipset_buf, 4000, fgchipset) != NULL) 
						{
							//[P] WPS Manufacturer: xxx
							//[P] WPS Model Number: yyy
							//[P] WPS Model Serial Number: zzz
							//cprintf(INFO,"\n%s\n",cmd_chipset_buf);

							aux_cmd_chipset = strstr(cmd_chipset_buf,"[P] WPS Manufacturer:");
							if(aux_cmd_chipset != NULL)
							{
								//bug fix by alxchk
								strncpy(info_manufac, aux_cmd_chipset+21, sizeof(info_manufac));							
							}

							aux_cmd_chipset = strstr(cmd_chipset_buf,"[P] WPS Model Number:");
							if(aux_cmd_chipset != NULL)
							{
                                //bug fix by alxchk
								strncpy(info_modelnum, aux_cmd_chipset+21, sizeof(info_modelnum));
								
							}

							aux_cmd_chipset = strstr(cmd_chipset_buf,"[P] WPS Model Serial Number:");
							if(aux_cmd_chipset != NULL)
							{
                                //bug fix by alxchk
								strncpy(info_modelserial, aux_cmd_chipset+28, sizeof(info_modelserial));
								
							}

						}
						
						//cprintf(INFO,"\n%s\n",info_manufac);
						info_manufac[strcspn ( info_manufac, "\n" )] = '\0';
						info_modelnum[strcspn ( info_modelnum, "\n" )] = '\0';
						info_modelserial[strcspn ( info_modelserial, "\n" )] = '\0';
						


                        if(pclose(fgchipset))  {
                        //printf("Command not found or exited with error status\n");
                        //return -1;
                        }

					

					}
					
					
					if (o_file_p == 0)
					{
						cprintf(INFO, "%17s      %2d            %.2d        %d.%d               %s               %s\n", bssid, channel, rssi, (wps->version >> 4), (wps->version & 0x0F), lock_display, ssid);
					}
					else
					{
						if(get_chipset_output == 1)
						{
							cprintf(INFO, "%17s|%2d|%.2d|%d.%d|%s|%s|%s|%s|%s\n", bssid, channel, rssi, (wps->version >> 4), (wps->version & 0x0F), lock_display, ssid, info_manufac, info_modelnum, info_modelserial);
							
						}else
						{
							cprintf(INFO, "%17s|%2d|%.2d|%d.%d|%s|%s\n", bssid, channel, rssi, (wps->version >> 4), (wps->version & 0x0F), lock_display, ssid);
							
						}
						
					}
void grid_cell::draw()
{
    static const double df_iso =0.05;
    glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
    glLineWidth(1.0);
    if(active_survey_param::non_ros::cell_drawing_mode == 0)
        glColor3f(1-0.8*ground_truth_value_,
                  1-0.8*ground_truth_value_,
                  1);
    else if(active_survey_param::non_ros::cell_drawing_mode == 1)
    {
        if(!is_covered())
            glColor3f(0.45,0.55,0.4);
        else
        glColor3f(1-2*df_iso*ceil(estimated_value_/df_iso),
                  1-2*df_iso*ceil(estimated_value_/df_iso),
                  1-2*df_iso*ceil(estimated_value_/df_iso));
    }
    else if(active_survey_param::non_ros::cell_drawing_mode == 3)
        glColor3f(2*variance_,
                  2*variance_,
                  2*variance_);
    else if(active_survey_param::non_ros::cell_drawing_mode == 4)
    {
        bool l = (estimated_value_+ active_survey_param::non_ros::beta*variance_
                  < active_survey_param::non_ros::target_threshold);
        bool h = (estimated_value_- active_survey_param::non_ros::beta*variance_
                  > active_survey_param::non_ros::target_threshold);
        bool u = !(l||h);
        glColor3f(l?1:0, h?1:0, u?1:0);

//        if(is_ignored())
//            glColor3f(0,0,0);
        //glColor4f(estimated_value_+ variance_, estimated_value_+ variance_,
        //          estimated_value_+ variance_,1);
    }
//        glColor4f(2*variance_,
//                  ((1-variance_)<0?0:(1-variance_))*estimated_value_,
//                  2*variance_, ignored_?0.3:1.0);
    else if(active_survey_param::non_ros::cell_drawing_mode == 5)
        utility::gl_color(utility::get_altitude_color(label_));
    else if(active_survey_param::non_ros::cell_drawing_mode == 2)
    {
        double dsc = pow(0.999, sensed_time_);
        utility::gl_color(sensed_&&is_target()?Vector3f(1-dsc,1-dsc,1-dsc):Vector3f(1,1,1));
        //double rt = (sensed_time_>active_survey_param::time_limit)?0:sensed_time_/active_survey_param::time_limit;
        //utility::gl_color(Vector3f(1-rt, 0 ,rt));
    }
    else
    {
        if(is_covered())
            glColor3f(0,is_target()?1:0,0);
        else
            glColor3f(0.5,0.5,0.5);
    }

    glBegin(GL_QUADS);
    utility::draw_quad(get_rect());
    glEnd();

    if(ground_truth_value_ > active_survey_param::non_ros::target_threshold)
    {
        glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
        glColor3f(1,0.95,0.7);
        glBegin(GL_QUADS);
        utility::draw_quad(get_rect(), 0.1);
        glEnd();
    }

    static Vector4f offset{0.1,0.1,-0.1,-0.1};

    if(false && is_ignored())
    {
        glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
        glColor4f(0.0,0.0,1, 0.2);
        glBegin(GL_QUADS);
        utility::draw_quad(get_rect()+offset, 0.15);
        glEnd();
    }
}
        void operator()(goal_ref const & g, 
                        goal_ref_buffer & result, 
                        model_converter_ref & mc, 
                        proof_converter_ref & pc,
                        expr_dependency_ref & core) {
            SASSERT(g->is_well_sorted());
            mc = 0; pc = 0; core = 0;

            fail_if_proof_generation("occf", g);

            bool produce_models = g->models_enabled();
            tactic_report report("occf", *g);
            
            m_mc = 0;
            
            ptr_vector<expr> new_lits;
            
            cnstr2bvar c2b;
            
            unsigned sz = g->size();
            for (unsigned i = 0; i < sz; i++) {
                checkpoint();
                expr * f = g->form(i);
                expr_dependency * d = g->dep(i);
                if (!m.is_or(f))
                    continue;
                app * cls = to_app(f);
                if (!is_target(cls))
                    continue;
                if (produce_models && !m_mc) {
                    m_mc = alloc(filter_model_converter, m);
                    mc = m_mc;
                }
                expr * keep = 0;
                new_lits.reset();
                unsigned num = cls->get_num_args();
                for (unsigned j = 0; j < num; j++) {
                    expr * l = cls->get_arg(j);
                    if (is_constraint(l)) {
                        expr * new_l = get_aux_lit(c2b, l, g);
                        if (new_l != 0) {
                            new_lits.push_back(new_l);
                        }
                        else if (keep == 0) {
                            keep = l;
                        }
                        else {
                            new_l = mk_aux_lit(c2b, l, produce_models, g);
                            new_lits.push_back(new_l);
                        }
                    }
                    else {
                        new_lits.push_back(l);
                    }
                }
                if (keep != 0)
                    new_lits.push_back(keep);
                g->update(i, m.mk_or(new_lits.size(), new_lits.c_ptr()), 0, d);
            }
            g->inc_depth();
            result.push_back(g.get());
            TRACE("occf", g->display(tout););
Exemple #6
0
OBJECT InsertSym(FULL_CHAR *str, unsigned char xtype, FILE_POS *xfpos,
unsigned char xprecedence, BOOLEAN xindefinite, BOOLEAN xrecursive,
unsigned xpredefined, OBJECT xenclosing, OBJECT xbody)
{ register int sum, rlen;
  register unsigned char *x;
  OBJECT p, q, s, tmp, link, entry, plink;  int len;

  debug3(DST, DD, "InsertSym( %s, %s, in %s )",
	Image(xtype), str, SymName(xenclosing));
  if( !LexLegalName(str) )
    Error(29, 3, "invalid symbol name %s", WARN, xfpos, str);

  New(s, xtype);
  FposCopy(fpos(s), *xfpos);
  has_body(s)          = FALSE;
  filter(s)            = nilobj;
  use_invocation(s)    = nilobj;
  imports(s)           = nilobj;
  imports_encl(s)      = FALSE;
  right_assoc(s)       = TRUE;
  precedence(s)        = xprecedence;
  indefinite(s)        = xindefinite;
  recursive(s)         = xrecursive;
  predefined(s)        = xpredefined;
  enclosing(s)         = xenclosing;
  sym_body(s)          = xbody;
  base_uses(s)         = nilobj;
  uses(s)              = nilobj;
  marker(s)            = nilobj;
  cross_sym(s)         = nilobj;
  is_extern_target(s)  = FALSE;
  uses_extern_target(s)= FALSE;
  visible(s)           = FALSE;
  uses_galley(s)       = FALSE;
  horiz_galley(s)      = ROWM;
  has_compulsory(s)    = 0;
  is_compulsory(s)     = FALSE;

  uses_count(s)  = 0;
  dirty(s)       = FALSE;
  if( enclosing(s) != nilobj && type(enclosing(s)) == NPAR )
    dirty(s) = dirty(enclosing(s)) = TRUE;

  has_par(s)     = FALSE;
  has_lpar(s)    = FALSE;
  has_rpar(s)    = FALSE;
  if( is_par(type(s)) )  has_par(enclosing(s))  = TRUE;
  if( type(s) == LPAR )  has_lpar(enclosing(s)) = TRUE;
  if( type(s) == RPAR )  has_rpar(enclosing(s)) = TRUE;

  /* assign a code letter between a and z to any NPAR symbol */
  if( type(s) == NPAR )
  { if( LastDown(enclosing(s)) != enclosing(s) )
    { Child(tmp, LastDown(enclosing(s)));
      if( type(tmp) == NPAR )
      { if( npar_code(tmp) == 'z' || npar_code(tmp) == ' ' )
	  npar_code(s) = ' ';
	else
	  npar_code(s) = npar_code(tmp)+1;
      }
      else
	npar_code(s) = 'a';
    }
    else npar_code(s) = 'a';
  }

  has_target(s)  = FALSE;
  force_target(s) = FALSE;
  if( !StringEqual(str, KW_TARGET) ) is_target(s) = FALSE;
  else
  { is_target(s) = has_target(enclosing(s)) = TRUE;

    /* if @Target is found after @Key, take note of external target */
    if( has_key(enclosing(s)) && xbody != nilobj && is_cross(type(xbody)) )
    { if( LastDown(xbody) != Down(xbody) )
      { OBJECT sym;
	Child(sym, Down(xbody));
	if( type(sym) == CLOSURE )
	{ is_extern_target(actual(sym)) = TRUE;
	  uses_extern_target(actual(sym)) = TRUE;
	}
      }
    }
  }

  has_tag(s) = is_tag(s) = FALSE;
  has_key(s) = is_key(s) = FALSE;
  has_optimize(s) = is_optimize(s) = FALSE;
  has_merge(s) = is_merge(s) = FALSE;
  has_enclose(s) = is_enclose(s) = FALSE;
  if( enclosing(s) != nilobj && type(enclosing(s)) == LOCAL )
  {
    if( StringEqual(str, KW_TAG) )
      is_tag(s) = has_tag(enclosing(s)) = dirty(enclosing(s)) = TRUE;

    if( StringEqual(str, KW_OPTIMIZE) )
      is_optimize(s) = has_optimize(enclosing(s)) = TRUE;

    if( StringEqual(str, KW_KEY) )
    { is_key(s) = has_key(enclosing(s)) = dirty(enclosing(s)) = TRUE;

      /* if @Key is found after @Target, take note of external target */
      for( link=Down(enclosing(s));  link!=enclosing(s);  link=NextDown(link) )
      { Child(p, link);
	if( is_target(p) && sym_body(p)!=nilobj && is_cross(type(sym_body(p))) )
	{ OBJECT sym;
	  Child(sym, Down(sym_body(p)));
	  if( type(sym) == CLOSURE )
	  { is_extern_target(actual(sym)) = TRUE;
	    uses_extern_target(actual(sym)) = TRUE;
	  }
	}
      }
    } 

    if( StringEqual(str, KW_MERGE) )
      is_merge(s) = has_merge(enclosing(s)) = TRUE;

    if( StringEqual(str, KW_ENCLOSE) )
      is_enclose(s) = has_enclose(enclosing(s)) = TRUE;
  }

  if( StringEqual(str, KW_FILTER) )
  { if( type(s) != LOCAL || enclosing(s) == StartSym )
      Error(29, 4, "%s must be a local definition", WARN, &fpos(s), str);
    else if( !has_rpar(enclosing(s)) )
      Error(29, 14, "%s must lie within a symbol with a right parameter",
	WARN, &fpos(s), KW_FILTER);
    else
    { filter(enclosing(s)) = s;
      precedence(enclosing(s)) = FILTER_PREC;
    }
  }

  if( type(s) == RPAR && has_body(enclosing(s)) &&
    (is_tag(s) || is_key(s) || is_optimize(s)) )
    Error(29, 5, "a body parameter may not be named %s", WARN, &fpos(s), str);

  if( type(s) == RPAR && has_target(enclosing(s)) &&
    (is_tag(s) || is_key(s) || is_optimize(s)) )
    Error(29, 6, "the right parameter of a galley may not be called %s",
      WARN, &fpos(s), str);

  len = StringLength(str);
  hash(str, len, sum);

  ifdebug(DST, D, sym_spread[sum]++;  sym_count++);
  entry = (OBJECT) &symtab[sum];
  for( plink = Down(entry);  plink != entry;  plink = NextDown(plink) )
  { Child(p, plink);
    if( length(p) == len && StringEqual(str, string(p)) )
    { for( link = Down(p);  link != p;  link = NextDown(link) )
      {	Child(q, link);
	if( enclosing(s) == enclosing(q) )
	{ Error(29, 7, "symbol %s previously defined at%s",
	    WARN, &fpos(s), str, EchoFilePos(&fpos(q)) );
	  if( AltErrorFormat )
	  {
	    Error(29, 13, "symbol %s previously defined here",
	      WARN, &fpos(q), str);
	  }
	  break;
	}
      }
      goto wrapup;
    }
  }

  /* need a new OBJECT as well as s */
  NewWord(p, WORD, len, xfpos);
  length(p) = len;
  StringCopy(string(p), str);
  Link(entry, p);

 wrapup:
  Link(p, s);
  if( enclosing(s) != nilobj ) Link(enclosing(s), s);
  debug2(DST, DD, "InsertSym Link(%s, %s) and returning.",
		SymName(enclosing(s)), SymName(s));
  return s;
} /* end InsertSym */
Exemple #7
0
static int
search_file(EFI_BLOCK_IO *blkio, EFI_LBA *head, UINTN *size, int (*is_target)(unsigned char *p))
{
	EFI_STATUS status;
	unsigned char buf[512], *p;
	int i;

	unsigned long root_dir_sectors;
	unsigned long first_root_dir_sec_num;
	unsigned long first_data_sector;
	unsigned long fatsz;
	unsigned long bpb_byts_per_sec;
	unsigned long bpb_sec_per_clus;
	unsigned long bpb_resvd_sec_cnt;
	unsigned long bpb_num_fats;
	unsigned long bpb_root_ent_cnt;
	unsigned long bpb_fat_sz_16;
	unsigned long bpb_fat_sz_32;
	unsigned long bpb_root_clus;

	unsigned long cluster;

	status = blkio->ReadBlocks(blkio, blkio->Media->MediaId, 0, 512, buf);
	if (EFI_ERROR(status))
		return -1;

	bpb_byts_per_sec = buf[11] + (buf[12] << 8);
	bpb_sec_per_clus = buf[13];
	bpb_resvd_sec_cnt = buf[14] + (buf[15] << 8);
	bpb_num_fats = buf[16];
	bpb_root_ent_cnt = buf[17] + (buf[18] << 8);
	bpb_fat_sz_16 = buf[22] + (buf[23] << 8);
	bpb_fat_sz_32 = buf[36] + (buf[37] << 8) + (buf[38] << 16) + (buf[39] << 24);
	bpb_root_clus = buf[44] + (buf[45] << 8) + (buf[46] << 16) + (buf[47] << 24);

	if (bpb_fat_sz_16 != 0) {
		fatsz = bpb_fat_sz_16;
	} else {
		fatsz = bpb_fat_sz_32;
	}

	root_dir_sectors = ((bpb_root_ent_cnt * 32) + (bpb_byts_per_sec - 1)) / bpb_byts_per_sec;
	first_data_sector = bpb_resvd_sec_cnt + (bpb_num_fats * fatsz) + root_dir_sectors;

	if (bpb_root_ent_cnt == 0) {
		first_root_dir_sec_num = ((bpb_root_clus - 2) * bpb_sec_per_clus) + first_data_sector;
	} else {
		first_root_dir_sec_num = bpb_resvd_sec_cnt + (bpb_num_fats * bpb_fat_sz_16);
	}

	status = blkio->ReadBlocks(blkio, blkio->Media->MediaId, first_root_dir_sec_num, 512, buf);
	if (EFI_ERROR(status))
		return -1;

	for (i = 0; i < 16; ++i) {
		p = &buf[32 * i];

		if (p[0] == 0xe5)
			continue;

		if (p[0] == 0x00)
			return -1;

		if (is_target(p)) {
			cluster = p[26] + (p[27] << 8) + (p[20] << 16) + (p[21] << 24);
			*head = ((cluster - 2) * bpb_sec_per_clus) + first_data_sector;
			*size = p[28] + (p[29] << 8) + (p[30] << 16) + (p[31] << 24);
			return 0;
		}
	}

	return -1;
}
int osc_controller::_param_cb(const char* path, const char* types,
                              lo_arg** argv, int argc, lo_message msg)
{
    if (argc < 4)
        return 0;

    if (!m_restricted || is_target(lo_message_get_source(msg))) {
	pair<int,int> net_id(argv[0]->i, argv[1]->i);

	map<pair<int,int>, int>::iterator it = m_local_id.find(net_id);
	world_node obj;

	if (it != m_local_id.end() &&
	    !(obj = m_world->find_node(it->second)).is_null()) {



	    m_skip++;
            int param_type = 0;

            // TODO: CLEAN this shit!
            switch (types[2])
            {
            case 'i':
            {
                int param_id = argv[2]->i;
                switch(param_type = obj.get_param_type(param_id)) {
                case graph::node_param::FLOAT:
                    m_world->set_param_node(obj, param_id, argv[3]->f);
                    break;
                case graph::node_param::INT:
                    m_world->set_param_node(obj, param_id, argv[3]->i);
                    break;
                case graph::node_param::STRING:
                    m_world->set_param_node(obj, param_id, string(&argv[3]->s));
                    break;
                case graph::node_param::VECTOR2F:
                    if (argc < 5)
                        return 0;
                    m_world->set_param_node(
                        obj, param_id, base::vector_2f(argv[3]->f, argv[4]->f));
                    break;
                default:
                    return 0;
                }
                break;
            }

            case 's':
            {
                std::string param_id = &argv[2]->s;
                switch(param_type = obj.get_param_type(param_id)) {
                case graph::node_param::FLOAT:
                    m_world->set_param_node(obj, param_id, argv[3]->f);
                    break;
                case graph::node_param::INT:
                    m_world->set_param_node(obj, param_id, argv[3]->i);
                    break;
                case graph::node_param::STRING:
                    m_world->set_param_node(obj, param_id, string(&argv[3]->s));
                    break;
                case graph::node_param::VECTOR2F:
                    if (argc < 5)
                        return 0;
                    m_world->set_param_node(
                        obj, param_id, base::vector_2f(argv[3]->f, argv[4]->f));
                    break;
                default:
                    return 0;
                }
                break;
            }

            default:
                return 0;
            }


	    m_skip--;

	    if (m_broadcast) {
		lo_message newmsg = lo_message_new();
		lo_message_add_int32(newmsg, argv[0]->i);
		lo_message_add_int32(newmsg, argv[1]->i);
		lo_message_add_int32(newmsg, argv[2]->i);

		switch(param_type) {
		case graph::node_param::FLOAT:
		    lo_message_add_float(newmsg, argv[3]->f);
		    break;
		case graph::node_param::INT:
		    lo_message_add_int32(newmsg, argv[3]->i);
		    break;
		case graph::node_param::STRING:
		    lo_message_add_string(newmsg, &argv[3]->s);
		    break;
		case graph::node_param::VECTOR2F:
		    lo_message_add_float(newmsg, argv[3]->f);
		    lo_message_add_float(newmsg, argv[4]->f);
		    break;
		default:
		    break;
		}

		broadcast_message_from(PSYNTH_OSC_MSG_PARAM, newmsg, lo_message_get_source(msg));
		lo_message_free(newmsg);
	    }
	}
    }

    return 0;
}