2010年4月23日 星期五

gcc cross compiler union compatible issue.



有些platform struct or union 預設為4bytes(一般會預期應該要2bytes)
目前可用
__attribute__((__packed__))來解決
其它的code要小心有沒有類似的問題


typedef union _MACHTTRANSMIT_SETTING
{
        unsigned short word;
        union //short 2 bytes,但有些可能 assign 4 bytes
        {
                unsigned short MCS:7; // MCS
                unsigned short BW:1; //channel bandwidth 20MHz or 40 MHz
                unsigned short ShortGI:1;
                unsigned short STBC:2; //SPACE
                unsigned short rsv:3;
                unsigned short MODE:2; // Use definition MODE_xxx.
        } __attribute__((__packed__))field;
}__attribute__((__packed__)) MACHTTRANSMIT_SETTING, *PMACHTTRANSMIT_SETTING;

int main(int argc, char *argv[])
{
        MACHTTRANSMIT_SETTING m;
        printf("m: %d, m->word:%d@%p\n", sizeof(m), sizeof(m.word), &m.word);
        printf("m: %d, m->:%d@%p\n", sizeof(m), sizeof(m.word), &m.word);
        printf("ok: %d, m->:%d@%p\n", sizeof(m), sizeof(m.field), &m.field);
}
X86
others
peter@team-server:~$ ./a.out
m: 2, m->word:2@0xbff97a32
m: 2, m->:2@0xbff97a32
ok: 2, m->:1@0xbff97a32
/tmp/rootfs # ./a.out
m: 2, m->word:2@0x4261fcd4
m: 2, m->:2@0x4261fcd4
ok: 2, m->:1@0x4261fcd4


2010年4月20日 星期二

how to change default stack size...

方法一:
gcc -Wl,--defsym,__stacksize=0x80000 -o foo foo.c

方法二:

peter@team-server:sbin$ arm-elf-readelf -l foo

Elf file type is EXEC (Executable file)
Entry point 0x37fc
There are 6 program headers, starting at offset 52

Program Headers:
  Type           Offset   VirtAddr   PhysAddr   FileSiz MemSiz  Flg Align
  PHDR           0x000034 0x00000034 0x00000034 0x000c0 0x000c0 R E 0x4
  INTERP         0x0000f4 0x000000f4 0x000000f4 0x00014 0x00014 R   0x1
      [Requesting program interpreter: /lib/ld-uClibc.so.0]
  LOAD           0x000000 0x00000000 0x00000000 0x1f668 0x1f668 R E 0x1000
  LOAD           0x01f668 0x00020668 0x00020668 0x0b718 0x0ba98 RW  0x1000
  DYNAMIC        0x01f67c 0x0002067c 0x0002067c 0x000c8 0x000c8 RW  0x4
  GNU_STACK      0x000000 0x00000000 0x00000000 0x00000 0x20000 RWE 0x8 //原來的stack256KB


 Section to Segment mapping:
  Segment Sections...
   00
   01     .interp
   02     .interp .hash .dynsym .dynstr .rel.dyn .rel.plt .init .plt .text .fini .rofixup
   03     .ctors .dtors .jcr .dynamic .data .got .bss
   04     .dynamic
   05
peter@team-server:sbin$
peter@team-server:sbin$ ../../../fdpichdr/fdpichdr -s 0x100000  foo
peter@team-server:sbin$ arm-elf-readelf -l foo

Elf file type is EXEC (Executable file)
Entry point 0x37fc
There are 6 program headers, starting at offset 52

Program Headers:
  Type           Offset   VirtAddr   PhysAddr   FileSiz MemSiz  Flg Align
  PHDR           0x000034 0x00000034 0x00000034 0x000c0 0x000c0 R E 0x4
  INTERP         0x0000f4 0x000000f4 0x000000f4 0x00014 0x00014 R   0x1
      [Requesting program interpreter: /lib/ld-uClibc.so.0]
  LOAD           0x000000 0x00000000 0x00000000 0x1f668 0x1f668 R E 0x1000
  LOAD           0x01f668 0x00020668 0x00020668 0x0b718 0x0ba98 RW  0x1000
  DYNAMIC        0x01f67c 0x0002067c 0x0002067c 0x000c8 0x000c8 RW  0x4
  GNU_STACK      0x000000 0x00000000 0x00000000 0x00000 0x100000 RWE 0x8    //現在有1MB

 Section to Segment mapping:
  Segment Sections...
   00
   01     .interp
   02     .interp .hash .dynsym .dynstr .rel.dyn .rel.plt .init .plt .text .fini .rofixup
   03     .ctors .dtors .jcr .dynamic .data .got .bss
   04     .dynamic
   05     .bss

2010年4月11日 星期日

office 2007 快速鍵

http://www.ithome.com.tw/itadm/article.php?c=46929
http://bbs.mychat.to/reads.php?tid=781220
http://272586.blogspot.com/2008/05/excel_22.html



Keyboard Shortcut

Result in Excel 2000 - General

F1 KeyHelp
F2 KeyEdit current Cell
F5 KeyGoto
F7 KeySpell Check
F12 KeySave file as
CTRL and ASelect entire worksheet.
CTRL and BToggle Bold Text.
CTRL and CCopies the item or items selected to the Clipboard and can be pasted using CTRL and V.
CTRL and FDisplays the Find dialog box.
CTRL and HDisplays the Replace dialog box.
CTRL and IToggles Italic Text.
CTRL and NNew File.
CTRL and OOpen File.
CTRL and PPrint.
CTRL and SSave File.
CTRL and UToggles Underlined Text.
CTRL and VPaste the contents of the clipboard.
CTRL and XCut the selected item.
CTRL and YRedo the last undone action
CTRL and ZUndoes the last action.
CTRL and 1Displays Format Cells Dialogue Box
CTRL and 5Toggles Strikethrough Text


back to top | © Copyright 2001-2010 helpwithpcs.com

Keyboard Shortcut

Result in Excel 2000 - Formulas

ALT and =Autosum
ALT and F8Macros
CTRL and ;Insert Current Date
CTRL and :Insert Current Time

back to top | © Copyright 2001-2010 helpwithpcs.com

Keyboard Shortcut

Result in Excel 2000 - Movement

Left ArrowOne Cell Left (also SHIFT and TAB)
Right ArrowOne Cell Right (also TAB)
Up ArrowOne Cell Up
Down ArrowOne Cell Down
HomeGo to End of row
CTRL and left ArrowGo to End of Column
CTRL and HomeGo to Top of Worksheet (A1)
CTRL and EndGo to End of Worksheet
CTRL and PAGE-DOWNGo to Next Worksheet

back to top | © Copyright 2001-2010 helpwithpcs.com

Keyboard Shortcut

Result in Excel 2000 - Cell Selection

CTRL and SpacebarSelect the entire Column
SHIFT and SpacebarSelect the entire Row
CTRL and ASelect Entire Worksheet
SHIFT and Left CursorSelect all cells to the left of the active one
SHIFT and Right CursorSelect all cells to the right of the active one

2010年4月8日 星期四

LAB L2TPD + IPSec in NONE-MMU

l2tpd: rp-l2tpd
ipsec: openswan patched.


------------------------------------------
config:

peter@team-server:ppp$ cat l2tpd.conf

# comment

# Global section (by default, we start in global mode)
global

# Load handlers
load-handler "sync-pppd.so"
load-handler "cmd.so"

# Bind address
listen-port 1701

# Configure the sync-pppd handler.  You MUST have a "section sync-pppd" line
# even if you don't set any options.
section sync-pppd
pppd-path /sbin/pppd
lns-pppd-opts "require-pap 10.0.0.1:10.0.0.2 lcp-echo-interval 30 lcp-echo-failure 6"
lac-pppd-opts "user exampe name example noipdefault ipcp-accept-local ipcp-accept-remote lcp-echo-interval 30 lcp-echo-failure 6"

# Peer section
section peer
peer 172.21.33.92 #-----(1)
#secret s3cr3t ---------(2)
port 1701
hide-avps no
section cmd


------------------------
(1). please modify remote client IP correctly.
(2). if uncomment it, an error message show as: stop_conntrol on L2TP tunnel phase.?
lns-handler sync-pppd  0.002 51449/0: Peer host name is 'test-55e98b2637'
   0.003 l2tp_peer_find(172.21.33.92) examining peer 172.21.33.92/32
   0.004 l2tp_peer_find(172.21.33.92) found 172.21.33.92/32
   0.005 auth_gen_response(secret=s3cr3t) -> a49eacc864ed2f63d48973e8571f56d7

######################################


#cat options
#noipdefault
#defaultroute
#passive
debug
refuse-eap
lcp-echo-interval 30
lcp-echo-failure 4


require-pap
maxfail 3
#user "sw2_vpn_user" #---(1)
mtu  1400
mru  1400
auth  #noauth #--(2)
noaccomp
nopcomp
noccp
-am


------------------------
(1). if uncomment options "user". it will shown blow message!



Mar 18 19:56:43 DIR865 user.notice The remote system is required to authenticate itself
Mar 18 19:56:43 DIR865 daemon.err pppd[2848]: The remote system is required to authenticate itself
Mar 18 19:56:43 DIR865 user.notice pppd
Mar 18 19:56:43 DIR865 user.notice :
Mar 18 19:56:43 DIR865 user.notice but I couldn't find any suitable secret (password) for it to use to do so.
Mar 18 19:56:43 DIR865 daemon.err pppd[2848]: but I couldn't find any suitable secret (password) for it to use to do so.

(2). noauth is used to "said: I am server. and did need not PAP nor CHAP authentication, so you guy are allowed just get  by IPCP.










2010年4月5日 星期一

openswn porting

這回改到porting openswan的問題
在quick mode negotiate completed後要用netlink加sa到xfrm …
but出現以下問題(不能加入sa)...
kernel: 2.6.28.10
Openswan 2.4.12

| checking transid: 12 keylen: 16 auth: 1
| checking transid: 12 keylen: 16 auth: 2
"conn_psk" #2: ERROR: netlink response for Add SA esp.f44e8ed@172.21.33.70 included errno 93: Protocol not supported
003 "conn_psk" #2: ERROR: netlink response for Add SA esp.f44e8ed@172.21.33.70 included errno 93: Protocol not supported
| complete state transition with STF_INTERNAL_ERROR
032 "conn_psk" #2: STATE_QUICK_I1: internal error
| state transition function for STATE_QUICK_I1 had internal error
| next event EVENT_RETRANSMIT in 8 seconds for #2

pluto的程式在這裡加入sa (kernel_netlink.c) netlink_add_sa
kernel對應的應該是: (xfrm_user.c)xfrm_add_sa

但2.6應該是不用klips…


結論是…我少了一些module
insmod ./hmac.ko