День добрый! 
Проблема в следующем :
Мне нужен сетевой клиент и сервер написанные с использованием либы LWIP, из которой необходимо использовать только RAW интерфейсы - то есть без сокетов.
Сказу скажу для чего - мне необходимо забирать из сети ВСЮ посылку (с заголовками, и пр пр ), а не только "полезные данные".
Итак, я скомпилил либу по дефолту, безо всяких изменений внутри нее.
Создаю сервер:
1) Как я понял из манов к либе необходимо запустить функцию/метод init() и затем уйти в бесконечный цикл.
    int main(int argc, char** argv) { 
    echo_init(); 
    std::cout << "endles cycle" << std::endl; 
    while(1) { 
    } 
    return 0; 
} 
2) Сам init();
echo_pcb = tcp_new(); // - create the pcb
err_t err; ip_addr_t ipaddr; //create variables for error checking and IP address I wanna use with my server.
 IP4_ADDR(&ipaddr, 150,18,8,165); //Put in variable adress of MY machine
  /* ifconfig says   
     eth1      Link encap:Ethernet     
    inet addr:150.18.8.165  Bcast:150.18.11.255*  Mask:255.255.251.0   */ 
err = tcp_bind(echo_pcb, &ipaddr, 667); //than bind IP address and desired port to the pcb
echo_pcb = tcp_listen(echo_pcb); //Than I listen pcb 
tcp_accept(echo_pcb, echo_accept); //If there is request - accept in
Верна ли эта логика?
Клиент:
int main(int argc, char** argv) { 
   err_t err =  hello_connect(); 
   if (err != ERR_OK)  { 
   std::cout << "err =  " << err << std::endl; 
   } 
    std::cout << "End of Main" << std::endl; 
    return 0; 
 } 
Сам  hello_connect(); 
 lwip_init(); 
 u8_t *state; 
 err_t err; 
 struct tcp_pcb *pcb; 
 ip_addr_t ipaddr; 
  IP4_ADDR(&ipaddr, 150,18,8,165); 
  if ((state = mem_malloc(1)) == NULL)  { 
     return ERR_MEM; 
  } 
   *state = 1; 
   if ((pcb = tcp_new()) == NULL)  { 
   mem_free(state); 
   return ERR_MEM; 
  } 
  tcp_arg(pcb, state); 
  tcp_err(pcb, hello_err); 
  tcp_recv(pcb, hello_recv); 
  tcp_sent(pcb, NULL); 
  tcp_poll(pcb, hello_poll_close, 10); 
  tcp_bind(pcb,&ipaddr, 55555); //Bind ourselvs to the port 55555 and my own adress   
  err = tcp_connect(pcb, &ipaddr, 667, hello_connected); 
  if (err != ERR_OK)  { 
     std::cout << "err =  " << err << std::endl; 
    mem_free(state); 
     tcp_abort(pcb); 
}
 
Проблемы 
Сервак поднимается, но создает интерфейс tap0
tap0
 Link encap:Ethernet HWaddr ******** inet addr:192.168.1.1 
Bcast:192.168.1.255 
Mask:255.255.255.0 inet6 addr: fe80::a82b:dcff:fedf:3964/64 
Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 
Metric:1 
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
 TX packets:40 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 
txqueuelen:500 RX bytes:0 (0.0 B) TX bytes:8136 (7.9 KiB)
Почему?
Хочу просканировать порты на машине
sudo nmap -sT -O 192.168.1.1 
Starting Nmap 6.00 () at 2014-06-25 11:58 MSK 
Nmap scan report for 192.168.1.1 
Host is up (0.000011s latency). 
Not shown: 996 closed ports 
PORT    STATE SERVICE 
22/tcp  open  ssh 
111/tcp open  rpcbind 
443/tcp open  https 
902/tcp open  iss-realsecure 
No exact OS matches for host (If you know what OS is running on it, see :** ). 
TCP/IP fingerprint: 
OS:SCAN(V=6.00%E=4%D=6/25%OT=22%CT=1%CU=40454%PV=Y%DS=0%DC=L%G=Y%TM=53AA812 
OS:3%P=x86_64-unknown-linux-gnu)SEQ(SP=108%GCD=1%ISR=10A%TI=Z%CI=I%II=I%TS= 
OS:8)OPS(O1=M400CST11NW7%O2=M400CST11NW7%O3=M400CNNT11NW7%O4=M400CST11NW7%O 
OS:5=M400CST11NW7%O6=M400CST11)WIN(W1=8000%W2=8000%W3=8000%W4=8000%W5=8000% 
OS:W6=8000)ECN(R=Y%DF=Y%T=41%W=8018%O=M400CNNSNW7%CC=Y%Q=)T1(R=Y%DF=Y%T=41% 
OS:S=O%A=S+%F=AS%RD=0%Q=)T2(R=N)T3(R=N)T4(R=Y%DF=Y%T=41%W=0%S=A%A=Z%F=R%O=% 
OS:RD=0%Q=)T5(R=Y%DF=Y%T=41%W=0%S=Z%A=S+%F=AR%O=%RD=0%Q=)T6(R=Y%DF=Y%T=41%W 
OS:=0%S=A%A=Z%F=R%O=%RD=0%Q=)T7(R=Y%DF=Y%T=41%W=0%S=Z%A=S+%F=AR%O=%RD=0%Q=) 
OS:U1(R=Y%DF=N%T=41%IPL=164%UN=0%RIPL=G%RID=G%RIPCK=G%RUCK=G%RUD=G)IE(R=Y%D 
OS:FI=N%T=41%CD=S) 
Network Distance: 0 hops 
OS detection performed. Please report any incorrect results at 
http://nmap.org/submit/ . 
Nmap done: 1 IP address (1 host up) scanned in 25.97 seconds 
Нету порта 667  ...
И вообще - ГДЕ мой сервак тогда??? )
Запускаю клиент :
tcp_connect to port 667
И повисает.
Но если я делаю клиент вида :
u8_t *state; 
    err_t err; 
    struct tcp_pcb *pcb; 
  ip_addr_t ipaddr; 
  netif_init(); 
  IP4_ADDR(&ipaddr, 127,0,0,1); 
 if ((state = mem_malloc(1)) == NULL) { 
     return ERR_MEM; 
 } 
  *state = 1; 
  if ((pcb = tcp_new()) == NULL)  { 
  mem_free(state); 
  return ERR_MEM; 
  } 
  tcp_arg(pcb, state); 
  tcp_err(pcb, hello_err); 
  tcp_recv(pcb, hello_recv); 
  tcp_sent(pcb, NULL); 
  tcp_poll(pcb, hello_poll_close, 10); 
  err = tcp_connect(pcb, &ipaddr, 667, hello_connected); 
  if (err != ERR_OK)  { 
     std::cout << "err =  " << err << std::endl; 
     std::cout << "err =  " << (int)err << std::endl; 
     mem_free(state); 
     tcp_abort(pcb); 
 } 
 
То в консоль валится
LWIP_HAVE_LOOPIF = 1 
tcp_connect to port 667 
ip_output_if: lo2 
IP header: 
+-------------------------------+ 
| 4 | 5 |  0x00 |        44     | (v, hl, tos, len) 
+-------------------------------+ 
|        0      |000|       0   | (id, flags, offset) 
+-------------------------------+ 
|  255  |    6  |    0xbdc9     | (ttl, proto, chksum) 
+-------------------------------+ 
|  127  |    0  |    0  |    1  | (src) 
+-------------------------------+ 
|  127  |    0  |    0  |    1  | (dest) 
+-------------------------------+ 
netif_loop_output() 
tcpip_thread: CALLBACK 0x7f1fbe811868 
ip_input: packet accepted on interface lo 
ip_input: 
IP header: 
+-------------------------------+ 
| 4 | 5 |  0x00 |        44     | (v, hl, tos, len) 
+-------------------------------+ 
|        0      |000|       0   | (id, flags, offset)
+-------------------------------+ 
|  255  |    6  |    0xbdc9     | (ttl, proto, chksum) 
+-------------------------------+ 
|  127  |    0  |    0  |    1  | (src) 
+-------------------------------+ 
|  127  |    0  |    0  |    1  | (dest) 
+-------------------------------+ 
ip_input: p->len 44 p->tot_len 44 
ip_output_if: lo2 
IP header: 
+-------------------------------+ 
| 4 | 5 |  0x00 |        40     | (v, hl, tos, len) 
+-------------------------------+ 
|        1      |000|       0   | (id, flags, offset) 
+-------------------------------+ 
|  255  |    6  |    0xbdcc     | (ttl, proto, chksum) 
+-------------------------------+ 
|  127  |    0  |    0  |    1  | (src) 
+-------------------------------+ 
|  127  |    0  |    0  |    1  | (dest) 
+-------------------------------+ 
netif_loop_output()ip_input: packet accepted on interface lo 
ip_input: 
IP header: 
+-------------------------------+ 
| 4 | 5 |  0x00 |        40     | (v, hl, tos, len) 
+-------------------------------+ 
|        1      |000|       0   | (id, flags, offset) 
+-------------------------------+ 
|  255  |    6  |    0xbdcc     | (ttl, proto, chksum) 
+-------------------------------+ 
|  127  |    0  |    0  |    1  | (src) 
+-------------------------------+ 
|  127  |    0  |    0  |    1  | (dest) 
+-------------------------------+ 
ip_input: p->len 40 p->tot_len 40 
 hello_err BEGINE  //This is the mark of error handler 
 hello_err END        //This is the mark of error handler 
tcp_pcb_purge 
tcp_pcb_purge: data left on ->unacked 
tcpip_thread: CALLBACK 0x7f1fbe811840 
tcpip_thread: PACKET 0x7f1fbe8119a8 
Куда идут эти пакеты? Кто ему отвечает? Сам себе?
Итак, итог - мне нужны 2 приложения
1)Сервак, который ждет подключения, берет всю посылку, упаковывает и передает другому (кому-то)
2) Клиент, посылающий некую data.
Господа, есть идеи?