Part 1
요약·해설
Packet sniffing을 위한 promiscuous mode를 켜고 data를 기다린 뒤 reference를 반환하고 mode를 끄는 흐름입니다.
Packet sniffing
All traffic
net_pkt_unref
Part 2
접을 수 있는 영어 원문 전체
영어 원문 전체 펼치기
1789DF6A2D7F1EE5F922BA652B04846CAD28642FE1BA9E5EF839B905D9DE2851
.. _promiscuous_interface:
Promiscuous Mode
################
.. contents::
:local:
:depth: 2
Overview
********
Promiscuous mode is a mode for a network interface controller that
causes it to pass all traffic it receives to the application rather than
passing only the frames that the controller is specifically programmed
to receive. This mode is normally used for packet sniffing as used
to diagnose network connectivity issues by showing an application
all the data being transferred over the network. (See the
`Wikipedia article on promiscuous mode
<https://en.wikipedia.org/wiki/Promiscuous_mode>`_ for more information.)
The network promiscuous APIs are used to enable and disable this mode,
and to wait for and receive a network data to arrive. Not all network
technologies or network device drivers support promiscuous mode.
Sample usage
************
First the promiscuous mode needs to be turned ON by the application like this:
.. code-block:: c
ret = net_promisc_mode_on(iface);
if (ret < 0) {
if (ret == -EALREADY) {
printf("Promiscuous mode already enabled\n");
} else {
printf("Cannot enable promiscuous mode for "
"interface %p (%d)\n", iface, ret);
}
}
If there is no error, then the application can start to wait for network data:
.. code-block:: c
while (true) {
pkt = net_promisc_mode_wait_data(K_FOREVER);
if (pkt) {
print_info(pkt);
}
net_pkt_unref(pkt);
}
Finally the promiscuous mode can be turned OFF by the application like this:
.. code-block:: c
ret = net_promisc_mode_off(iface);
if (ret < 0) {
if (ret == -EALREADY) {
printf("Promiscuous mode already disabled\n");
} else {
printf("Cannot disable promiscuous mode for "
"interface %p (%d)\n", iface, ret);
}
}
See :zephyr:code-sample:`net-promiscuous-mode` for a more comprehensive example.
API Reference
*************
.. doxygengroup:: promiscuous
Part 3
한국어 전문 번역
개요
Promiscuous mode는 network interface controller가 자신에게 수신하도록 특별히 설정된 frame만 넘기는 대신, 수신한 모든 traffic을 application에 전달하게 하는 mode입니다. Network에서 전달되는 모든 data를 application에 보여 주므로 보통 network connectivity 문제를 진단하는 packet sniffing에 사용됩니다.
Network promiscuous API는 이 mode를 활성화·비활성화하고 network data 도착을 기다렸다가 수신하는 데 사용합니다. 모든 network technology 또는 network device driver가 promiscuous mode를 지원하는 것은 아닙니다.
사용 예
먼저 application이 다음처럼 promiscuous mode를 켭니다.
ret = net_promisc_mode_on(iface);
if (ret < 0) {
if (ret == -EALREADY) {
printf("Promiscuous mode already enabled\n");
} else {
printf("Cannot enable promiscuous mode for "
"interface %p (%d)\n", iface, ret);
}
}net_promisc_mode_on(iface)이 음수를 반환하면 오류입니다. -EALREADY는 이미 활성화돼 있다는 뜻이고, 그 밖의 오류는 interface와 error code를 출력합니다.
오류가 없으면 application은 network data를 기다릴 수 있습니다.
while (true) {
pkt = net_promisc_mode_wait_data(K_FOREVER);
if (pkt) {
print_info(pkt);
}
net_pkt_unref(pkt);
}net_promisc_mode_wait_data(K_FOREVER)는 packet이 도착할 때까지 기다립니다. Packet을 처리한 뒤에는 매 반복에서 net_pkt_unref(pkt)로 reference를 반환합니다.
마지막으로 application은 다음처럼 promiscuous mode를 끕니다.
ret = net_promisc_mode_off(iface);
if (ret < 0) {
if (ret == -EALREADY) {
printf("Promiscuous mode already disabled\n");
} else {
printf("Cannot disable promiscuous mode for "
"interface %p (%d)\n", iface, ret);
}
}net_promisc_mode_off(iface)의 -EALREADY는 이미 비활성화돼 있음을 뜻합니다. 더 종합적인 예는 Net Promiscuous Mode sample을 참고하십시오.
API Reference
Doxygen group promiscuous가 API reference를 제공합니다.
Source
출처
영어 원문에는 문단, 문서 지시문, 표, 코드, 코드 심벌, 경로를 그대로 보존했습니다.