ÉîÈëÀí½âLinuxÄÚºËÖеÄÁ´±í
×î½ü£¬¿ªÊ¼ÑжÁÒ»ÏÂLinuxµÄÄں˴úÂ룬¸ÕÒ»¿ªÊ¼£¬¾ÍÓÐÁîÈ˾ªÌ¾µÄ·¢ÏÖ£¬²»µÃ²»¸Ð̾Äں˴úÂëÉè¼ÆµÃÖ®ÃÀ£¡µ¥ÊÇ×î³£ÓõÄÁ´±íÒ²Éè¼ÆµÃ²»µÃ²»ÁîÈËÅå·þ£¡
1.1.Á´±ílist_head
include/linux/list.h
ºÜ¾µä£¬Á´±íÔÚÄÚºËÖкܳ£Óã¬ÀýÈç¹ÜÀí½ø³Ì£¬½ø³ÌµÄ¸÷¸ö״̬¶ÓÁж¼ÊÇʹÓÃÕâ¸öË«ÏòÁ´±íʵÏֵġ£ÄÚºËÖеÄÁ´±í¶¨Òå³ÉºÍÊý¾ÝÎ޹صÄÐÎʽ£¬¶ø²»ÊÇͨ³£ÎÒÃÇʹÓõÄÁ´±í¸ñʽ£¬ÀýÈç
typedef struct _list{
Elemtype elem;
struct _list *next;
}list;
ÄÚºËÖеÄÁ´±í¶¨ÒåΪ
struct list_head{
struct list_head *next, *prev;
};
¿É¼û£¬Õâ¸öÁ´±í½ÚµãÖв»°üº¬ÈκÎÊý¾Ý£¬Ö»ÓÐÁ½¸öÖ¸Õë¡£µ±ÐèҪʹÓÃÁ´±íÀ´×éÖ¯Êý¾Ý½á¹¹Ê±£¬Õâ¸ö½á¹¹ÖоͰüº¬Ò»¸ölist_head³ÉÔ±£¬ÀýÈç
struct _list_struct{
Elemtype elem;
struct list_head list;
...
};
ÏÔ¶øÒ×¼û£¬Á´±íʵÏֳɺÍÊý¾Ý·ÖÀëµÄºÃ´¦ÊÇ£¬²»ÓÃΪÿÖÖÊý¾Ý¶¼¶¨ÒåÁ´±í²Ù×÷£¬¿ÉÒÔʹÓÃͳһµÄÁ´±í²Ù×÷¼´¿É¡£µ«ÊÇÎÊÌâÊÇ£ºÖ»ÖªµÀÊý¾Ý³ÉÔ±listµÄµØÖ·£¬ÔõÑùÈ¥·ÃÎÊ×ÔÉíÒÔ¼°ÆäËû³ÉÔ±ÄØ£¿
#define list_entry(ptr,type,member) \
container_of(ptr,type,member)
¶øcontainer_of(ptr,type,member)ºê¶¨ÒåÔÚinclude/list/kernel.hÖÐ
#define container_of(ptr,type,member) ({
const typeof( ((type *)0)->member) *__ptr=ptr;
(type *)( (char *)__ptr - offsetof(type,member));})
ÉÏÃæµÄºêÓм¸µãÐèÒª½âÊÍ£º
1£©typeof(type) ºê
typeof(type) ºê·µ»Ø±äÁ¿typeµÄÀàÐÍ£¬ÀýÈ磺int a; typeof(a) b;µÈ¼ÛÓÚint b;
2£©offsetof(type,member)ºê
Ëü¶¨ÒåÔÚinclude/linx/stddef.hÖУ¬ÈçÏ£º
#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
Õâ¸öºê·µ»ØmemberÔÚtypeÀàÐÍÖеÄÆ«ÒÆÁ¿£¬typeÊÇÒ»¸ö½á¹¹£¬ÀýÈ磺
typeof(list_head,next);·µ»Ø0£¬Ò²¾ÍÊÇ·µ»ØÏà¶ÔÓڽṹÆðʼµØÖ·µÄÆ«ÒÆÁ¿¡£
3£©ÎªÊ²Ã´ÒªÊ¹ÓÃtypeof(((type *)0)->member)À´¶¨ÒåÖ¸Õë __ptr£¬¶ø²»ÊÇÕâÑù£º
const typeof(member) *__ptr=ptr;£¿
Æäʵ£¬Õâ¸öºÜ¼ò
Ïà¹ØÎĵµ£º
£¨L2CAPÐÒé¼ò½é£¬L2CAPÔÚBlueZÖеÄʵÏÖÒÔ¼°L2CAP±à³Ì½Ó¿Ú£©
Ò»£ºL2CAPÐÒé¼ò½é£º
Logical Link Control and Adaptation Protocol(L2CAP)
Âß¼Á¬½Ó¿ØÖƺÍÊÊÅäÐÒé (L2CAP) ΪÉϲãÐÒéÌṩÃæÏòÁ¬½ÓºÍÎÞÁ¬½ÓµÄÊý¾Ý·þÎñ£¬²¢Ìṩ¶àÐÒ鹦ÄܺͷָîÖØ×é²Ù×÷¡£L2CAP ³äÐíÉϲãÐÒéºÍÓ¦ÓÃÈí¼þ´«ÊäºÍ½ÓÊÕ×î´ó³¤¶ÈΪ 64K µÄ L2CAP Ê ......
ÀýÒ»£º·¢ËÍSignaling Packet£º
Signaling CommandÊÇ2¸öBluetoothʵÌåÖ®¼äµÄL2CAP²ãÃüÁî´«Êä¡£ËùÒÔµÃSignaling CommandʹÓÃCID 0x0001.
¶à¸öCommand¿ÉÒÔÔÚÒ»¸öC-frame£¨control frame£©Öз¢ËÍ¡£
Èç¹ûÒªÖ±½Ó·¢ËÍSignaling Command.ÐèÒª½¨Á¢SOCK_RAWÀàÐ͵ÄL2CAPÁ¬½ÓSocket¡£ÕâÑù²ÅÓлú»á×Ô¼ºÌî³äCommand Code£¬Identi ......
ÔÚlinuxµÄprocÎļþϵͳÖУ¬Í¨¹ý²é¿´/proc/net/devÎļþ
¿ÉÒԵõ½Ã¿¸öÍøÂç½Ó¿ÚµÄÍÌÍÂÁ¿£¬µ«ÊÇÎÞ·¨»ñµÃʵʱ´ø¿í
×î½ü·¢ÏÖÁËÒ»ÖÖ»ùÓÚncurses¿âµÄС³ÌÐòbmon£¬¿ÉÒÔ»ñµÃʵʱ´ø¿í
Example:
Ö´ÐÐ
[root@debian ~]# bmon -o ascii -p eth0
Interface RX Rate RX # TX Rate TX #
eth0 0.00B 0.0 0.00B 0.0
eth0 0.00B 0.0 ......
Èç¹ûÄú¾³£³©Óλ¥ÁªÍø£¬ÄÇôһ¶¨Á˽âÍøÕ¾µÄÓòÃû£¬ÔÚä¯ÀÀÆ÷ÖдòÉÏhttp://www.si-bay.comµÈÓÐÒ»¶¨º¬ÒåµÄÓòÃû¾Í¿ÉÒÔ·ÃÎÊÎù°ÔÍø»òÆäËûÍøÕ¾£¬¶ø²»±ØÈ¥¼ÇÒä¿ÝÔïµÄIPµØÖ·£¬ÊµÔÚÊǺüÇÓÖºÃÓá£
¡¡¡¡¾ÖÓòÍøÖÐÈçºÎʵÏÖIntranet£¬¹¹½¨ÆóÒµÄÚ²¿ÍøµÄWeb·þÎñÆ÷»òÕßÆäËû·þÎñÆ÷£¬Ê¹ÓúÍÅäÖÃDNS¾ÍÏÔµÃÓÈÆäÖØÒª¡£ÏÂÃæ¾ÍLinuxÏÂÅäÖÃDNS×÷һЩ´ ......