android bluetooth l2cap data flow
just read code find data flow
![](https://img.haomeiwen.com/i11634406/c037e979754afb6e.png)
![](https://img.haomeiwen.com/i11634406/040df9a16bf9a0e9.png)
add print in kernel and capture l2cap packet
I add follow print code in l2cap_sock.c, after compare with the capture file, we know that skb->len is l2cap packet length, skb->data is l2cap packet data
static void l2cap_do_send(struct l2cap_chan *chan, struct sk_buff *skb)
{
struct hci_conn *hcon = chan->conn->hcon;
unsigned char buffer[0x1000];
unsigned char* p = buffer;
u16 flags;
//change to printk
printk("chan %p, skb %p len 0x%x priority %u", chan, skb, skb->len,
skb->priority);
int i=0;
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++
for(i=0;i<skb->len && p<buffer+sizeof(buffer)-2;i++){
sprintf(p,"0x%2x ",skb->data[i]);
p=p+5;
}
*p='\n';
*(p+1)='\0';
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++
printk(buffer);
if (chan->hs_hcon && !__chan_is_moving(chan)) {
if (chan->hs_hchan)
hci_send_acl(chan->hs_hchan, skb, ACL_COMPLETE);
else
kfree_skb(skb);
return;
}
![](https://img.haomeiwen.com/i11634406/862dac2f6391cc3e.png)
![](https://img.haomeiwen.com/i11634406/ef92e348ea894636.png)
![](https://img.haomeiwen.com/i11634406/da143c32c1948d34.png)
change the packet length and content
I add following code
int l2cap_chan_send(struct l2cap_chan *chan, struct msghdr *msg, size_t len){
...
char* mydata="413x-send-data";
memcpy(skb->data+8,mydata,sizeof(mydata));
skb->len=0x10;
l2cap_do_send(chan, skb);
...
get bluetooth snoop from pixel, use wireshark to open it
![](https://img.haomeiwen.com/i11634406/9dbe0a10fd579372.png)
网友评论