2012年3月18日日曜日

KNOPPIX のカスタマイズ

使用しないであろうパッケージの削除

aptitude purge <package_name>

# purge と remove の違いは、設定ファイルも削除するかしないか


私が使用しないであろうパッケージ

・python
・xpdf
・linux-sound-base
・libreoffice-common
・anthy-common
・cups
・bluez
・java-common
・imagemagick
・ghostscript
・dvd+rw-tools
・mp3

2012年3月10日土曜日

verilog auto

組み合わせ回路
always @(/*AS*/) begin


入出力


module(/*AUTOARG*/) begin



submodule instancename(/*AUTOINST*/)

M-x verilog-auto C-c C-z

2012年3月7日水曜日

キャラクタデバイスのデバイスドライバ例

#include <linux/fs.h>    // file_operations, inode
#include <asm/uaccess.h> // copy_to_user
#include <linux/module.h>
#include <linux/kernel.h>


static int devmajor = 77;
static char devname[] = "logdev";
static char devbuf[] = "this is my message.\n";

static int
logdev_read(struct file *filp, char *buf, size_t count, loff_t *pos)
{
  int copy_len = sizeof(devbuf);

  copy_to_user(buf, devbuf, copy_len);

  return copy_len;
}


static struct file_operations logdev_fops = {
  .read = logdev_read,
};


int
init_module(void)
{
  register_chrdev(devmajor, devname, &logdev_fops);
  printk(KERN_INFO "logdev init\n");

  return 0;
}

void
cleanup_module(void)
{
  unregister_chrdev(devmajor, devname);
  printk(KERN_INFO "logdev clean\n");
}

MODULE_DESCRIPTION( "sample char device driver" );



$ ls -l /dev/logdev
crw-r--r-- 1 root root 77, 0  /dev/logdev

2012年3月4日日曜日

Linux で WPS を使う方法2


STA が Registrar、AP が Enrollee の場合、

■ AP 側 (hostapd)
# cat hostapd.conf
wpa=2
wpa_passphrase=xxxxxxxx
wps_state=1 (not configured)
eap_server=1

# hostapd_cli wps_ap_pin random
35344414 (PIN の生成)
# hostapd_cli wps_ap_pin get
35344414 (同じ PIN が得られる)


■ STA 側
wpa_supplicant 起動後
# wpa_cli wps_reg xx:xx:xx:xx:xx:xx 35344414 new_ssid WPA2PSK CCMP new_passphrase
ただし、xx:xx:xx:xx:xx:xx は AP の MAC アドレス
35344414 は STA Registrar の PIN を入力する。
これで、AP が新しい設定(new_ssid, new_passphrase) で再起動される。

うまくいけば、hostapd.conf は新しい設定に書き換えられている。
# cat hostapd.conf
wps_state=2
ssid=new_ssid
wpa=2
wpa_key_mgmt=WPA-PSK
wpa_pairwise=CCMP
wpa_passphrase=new_passphrase
auth_algs=1

2012年3月1日木曜日

Linux で WPA/WPA2 を使う方法

[AP]
# ./hostapd /etc/hostapd/hostapd.conf

ただし、hostapd.conf には、下記を記載。
wpa = 1(WPA) or 2(WPA2) or 3(WPA/WPA2 mixed)
wpa_passphrase = my_passphrase

[STA]
# wpa_passphrase my_ssid my_passphrase
# wpa_supplicant -i wlan1 /etc/wpa_supplicant/wpa_supplicant.conf
(これで、iw connect を実行しなくても自動的に接続される)

WLAN 接続メモ

[AP]
# ./hostapd hostapd.conf

[STA]
# iw -i wlan1 scan
# iw -i wlan1 connect my_ssid
# iw -i wlan1 disconnect

[capture(1024Byte までダンプする)]
# tcpdump -i hwsim0 -w dump.pcap -s 1024