Esempio n. 1
0
ldc_info_t * info (int log) {
	hd_data_t * hd_data = new_hd_data_t();
	hd_t *hd;

	hd = hd_list(hd_data, hw_cdrom, 1, NULL);

	ldc_info_t * head = NULL;
	ldc_info_t * tail = NULL;

	char buffer[500];

	for(; hd; hd = hd->next) {
		if (! head) {
			head = new_ldc_info_t("dvdcd");
			tail = head;
		} else {
			tail->next = new_ldc_info_t("dvdcd");
			tail = tail->next;
		}

		set_vendor(tail, "vendor", hd->vendor.name, hd->vendor.id, "Vendor");
		set_model(tail, "model", hd->device.name, hd->device.id, "Model");

		add_info_tuple(tail, "device", hd->unix_dev_names->str, -1, "Device file");
		add_info_tuple(tail, "drivers", format_drivers(hd, buffer), -1, "Drivers");
		add_info_tuple(tail, "medias", format_medias(hd, buffer), -1, "Supported media types");

		tail->return_status = 1;
	}

	if (log){
		insert_info_log(head);
	}

	free_hd_structs (hd_data, hd);

	return head;
}
Esempio n. 2
0
ldc_info_t * info (int log) {
	ldc_info_t * head = NULL;
	ldc_info_t * tail = NULL;

	hd_data_t * hd_data = new_hd_data_t();
	hd_t *hd;
	hd_res_t *res;

	hd = hd_list(hd_data, hw_usb, 1, NULL);

	for(; hd; hd = hd->next) {
		if (hd->hw_class){
			if (hd->hw_class == hw_disk){ //apenas os discos usb
				if (hd->device.name && (strstr(hd->device.name, "Card") == NULL && strstr(hd->device.name, "card") == NULL )){
					if (! head) {
						head = new_ldc_info_t("pendrive");
						tail = head;
					} else {
						tail->next = new_ldc_info_t("pendrive");
						tail = tail->next;
					}

					if(hd->vendor.name){
						set_vendor (tail, "vendor", hd->vendor.name, -1, "Vendor");
					} else {
						set_vendor (tail, "vendor", "Unknown", -1, "Vendor");
					}
					if (hd->device.name){
						set_model (tail, "device", hd->device.name, -1, "Model");
					} else {
						set_model (tail, "device", "Unknown", -1, "Model");
					}

					if(hd->drivers) {
						char *s = hd_join("; ", hd->drivers);
						add_info_tuple(tail, "driver", s, -1, "Driver");
						free(s);
					} else {
						add_info_tuple(tail, "driver", "Unknown", -1, "Driver");
					}
					if (hd->unix_dev_name){
						add_info_tuple(tail, "device_file", hd->unix_dev_name, -1, "Device File");
						partitions_info(hd->unix_dev_name, tail);
					} else {
						add_info_tuple(tail, "device_file", "Unknown", -1, "Device File");
					}
					int speed = -1;
					int size = -1;
					for(res = hd->res; res; res = res->next) {
						switch(res->any.type) {
							case res_baud:
								//convertendo para Mbps (divisão por 10^6)
								speed = res->baud.speed/1000000;
								break;
							case res_size:
								if(res->size.unit == size_unit_sectors){
									//FIXME: adicionado 1 e feito floor => usar ceil
									size = ((res->size.val1*res->size.val2)/1073741824.0) + 1; //byte => GB
								}
								break;
							default:
								break;
						}
					}
					add_info_tuple(tail, "speed", NULL, speed, "Speed (in Mbps)");
					add_info_tuple(tail, "Size", NULL, size, "Size (in GB)");
				}
			}
		}
	}

	if (tail) {
		tail->return_status = 1;
	} else {
		//printf("Não foi detectado nenhum pen drive!!\n");

		//FIXME: deve ser padronizado o retorno
		//head = new_ldc_info_t("pendrive");
	}

	free_hd_structs (hd_data, hd);

	if (log){
		insert_info_log(head);
	}

	return head;
}
Esempio n. 3
0
ldc_info_t * videocard_module () {
	hd_data_t * hd_data;
	hd_t * hd;

	ldc_info_t * head = NULL;

	int primary_display = -1;

	hd_data = new_hd_data_t();
	hd = hd_list(hd_data, hw_display, 1, NULL);

	primary_display =  hd_display_adapter(hd_data);

	for (; hd; hd = hd->next) {
		if (primary_display != -1 && primary_display == hd->idx){
			ldc_info_t * current = new_ldc_info_t("videocard");

			driver_info_t * di;

			str_list_t * tmp_sl;

			char buffer[100];


			if (hd->vendor.name != NULL){
				set_vendor (current, "vendor", hd->vendor.name, hd->vendor.id, "Vendor");
			} else {
				set_vendor (current, "vendor", "Unknown", -1, "Vendor");
			}
			if (hd->model != NULL){
				set_model (current, "device", hd->model, hd->device.id, "Model");
			} else {
				set_model (current, "device", "Unknown", -1, "Model");
			}

			if (hd->driver_info) {
				di = hd->driver_info;
				for (; di; di = di->next) {
					if (di->any.type == di_x11){
						// XFree86 Server Module
						insert_tuple(current, "xf86_module_name", di->x11.server, -1, "XFree86 Server Module");
		//
						// 3D Support
						insert_tuple(current, "xf86_module_3d", NULL, di->x11.x3d, "XFree86 Server Module 3D Support");
		//
						// Extensions
						if (di->x11.extensions) {
							buffer[0] = '\0';

							for (tmp_sl = di->x11.extensions; tmp_sl; tmp_sl = tmp_sl->next) {
								sprintf (buffer, "%s%s|", buffer, tmp_sl->str);
							}
						}
						insert_tuple(current, "xf86_module_ext", buffer, -1, "XFree86 Server Module Extensions");

					} else {
						add_info_tuple(current, "xf86_module_name", "Unknown", -1, "XFree86 Server Module");
						add_info_tuple(current, "xf86_module_3d", NULL, -1, "XFree86 Server Module 3D Support");
						add_info_tuple(current, "xf86_module_ext", "Unknown", -1, "XFree86 Server Module Extensions");
					}

				}
			} else {
				add_info_tuple(current, "xf86_module_name", "Unknown", -1, "XFree86 Server Module");
				add_info_tuple(current, "xf86_module_3d", NULL, -1, "XFree86 Server Module 3D Support");
				add_info_tuple(current, "xf86_module_ext", "Unknown", -1, "XFree86 Server Module Extensions");
			}

			current->return_status = 1;

			head = enqueue_ldc_info_t(head, current);
		}
	}

	free_hd_structs (hd_data, hd);

	return head;
}
Esempio n. 4
0
ldc_info_t * info (int log) {
	hd_data_t * hd_data = new_hd_data_t();
	hd_t *hd;

	hd = hd_list(hd_data, hw_sound, 1, NULL);

	ldc_info_t * head = NULL;
	ldc_info_t * tail = NULL;

	for(; hd; hd = hd->next) {
		if (! head) {
			head = new_ldc_info_t("sound");
			tail = head;
		} else {
			tail->next = new_ldc_info_t("sound");
			tail = tail->next;
		}

		//vendor
		if (hd->vendor.name){
			set_vendor (tail, "vendor", hd->vendor.name, hd->vendor.id, "Vendor");
		} else {
			set_vendor (tail, "vendor", "Unknown", -1, "Vendor");
		}

		//device
		if (hd->device.name){
			set_model (tail, "device", hd->device.name, hd->device.id, "Device");
		} else {
			set_model (tail, "device", "Unknown", -1, "Device");
		}

		//model
		if (hd->model){
			add_info_tuple(tail, "model", hd->model, -1, "Model");
		} else {
			add_info_tuple(tail, "model", "Unknown", -1, "Model");
		}

		//driver modules; driver active; device id
		if (hd->driver_info){
			driver_info_t *di;
			for(di = hd->driver_info; di; di = di->next) {
				if (di->any.type == di_module) {
					str_list_t * mod_list = di->module.names;
					add_info_tuple(tail, "driver_active", NULL, di->module.active, "Driver Active");

					for (; mod_list; mod_list = mod_list->next){
						add_info_tuple(tail, "driver_modules", mod_list->str, -1, "Driver Modules");
						device_id(tail, mod_list->str);
					}
				}
			}
		} else {
			add_info_tuple(tail, "driver_modules", "Unknown", -1, "Driver Modules");
			add_info_tuple(tail, "driver_active", NULL, -1, "Driver Active");
		}

		tail->return_status = 1;
	}

	free_hd_structs (hd_data, hd);

	if (log){
		insert_info_log(head);
	}

	return head;
}
Esempio n. 5
0
/* Given the tagged parameter sets from a beacon packet, locate the AP's SSID and return its current channel number */
int parse_beacon_tags(const unsigned char *packet, size_t len)
{
	set_vendor(0, "\0\0\0");
	char *ssid = NULL;
	const unsigned char *tag_data = NULL;
	unsigned char *ie = NULL, *channel_data = NULL;
	size_t ie_len = 0, ie_offset = 0, tag_len = 0, tag_offset = 0;
	int channel = 0;
	struct radio_tap_header *rt_header = NULL;

	rt_header = (struct radio_tap_header *) radio_header(packet, len);
	tag_offset = end_le16toh(rt_header->len) + sizeof(struct dot11_frame_header) + sizeof(struct beacon_management_frame);

	if(tag_offset < len)
	{
		tag_len = (len - tag_offset); /* this actually denotes length of the entire tag data area */
		tag_data = (const unsigned char *) (packet + tag_offset);

		/* If no SSID was manually specified, parse and save the AP SSID */
		if(get_ssid() == NULL)
		{
			ie = parse_ie_data(tag_data, tag_len, (uint8_t) SSID_TAG_NUMBER, &ie_len, &ie_offset);
			if(ie)
			{
				/* Return data is not null terminated; allocate ie_len+1 and memcpy string */
				ssid = malloc(ie_len+1);
				if(ssid)
				{
					memset(ssid, 0, (ie_len+1));
					memcpy(ssid, ie, ie_len);
					set_ssid(ssid);
					free(ssid);
				}

				free(ie);
			}
		}

		ie = parse_ie_data(tag_data, tag_len, HT_CAPS_TAG_NUMBER, &ie_len, &ie_offset);
		if(ie)
		{
			set_ap_htcaps(ie, ie_len);
			free(ie);
		}

		ie = parse_ie_data(tag_data, tag_len, (uint8_t) RATES_TAG_NUMBER, &ie_len, &ie_offset);
		if(ie)
		{
			set_ap_rates(ie, ie_len);
			free(ie);
		}

		ie = parse_ie_data(tag_data, tag_len, (uint8_t) ERATES_TAG_NUMBER, &ie_len, &ie_offset);
		if(ie)
		{
			set_ap_ext_rates(ie, ie_len);
			free(ie);
		}

		channel_data = parse_ie_data(tag_data, tag_len, (uint8_t) CHANNEL_TAG_NUMBER, &ie_len, &ie_offset);
		if(channel_data)
		{
			if(ie_len  == 1)
			{
				channel = *(uint8_t*)channel_data;
			}
			free(channel_data);
		}

		size_t ie_iterator = 0;
		do {
			const unsigned char *tag = tag_data + ie_iterator;
			// check for the length of the tag, and that its not microsoft
			if(tag[0] == VENDOR_SPECIFIC_TAG &&
			   ie_iterator+2+3 < tag_len &&
			   ((tag[1] < 11 && memcmp(tag+2, "\x00\x14\x6c", 3) && memcmp(tag+2, "\x00\x50\xf2", 3)) ||
			    (tag[1] == 30 && !(memcmp(tag+2, "\x00\x26\x86", 3))))) {
				set_vendor(1, tag + 2);
				break;
			}

		} while(get_next_ie(tag_data, tag_len, &ie_iterator));
	}

	return channel;
}