Linux API/network2009. 11. 30. 17:35
ioctl은

#include <sys/ioctl.h>
int ioctl(int d, int request, ...);

이런 모양인데, int d는 descriptor로 socket을 통해 받아와야 한다.
그리고 request는 /usr/include/bits/ioctls.h 파일에 정의된 내용을 사용하면 된다.


잠시 socket을 소개하자면

#include <sys/socket.h>
int socket(int domain, int type, int protocol);

domain
    Name                Purpose                          Man page
    PF_UNIX, PF_LOCAL   Local communication              unix(7)
    PF_INET             IPv4 Internet protocols          ip(7)
    PF_INET6            IPv6 Internet protocols
    PF_IPX              IPX - Novell protocols
    PF_NETLINK          Kernel user interface device     netlink(7)
    PF_X25              ITU-T X.25 / ISO-8208 protocol   x25(7)
    PF_AX25             Amateur radio AX.25 protocol
    PF_ATMPVC           Access to raw ATM PVCs
    PF_APPLETALK        Appletalk                        ddp(7)
    PF_PACKET           Low level packet interface       packet(7)

type
   SOCK_STREAM
          Provides sequenced, reliable, two-way, connection-based byte streams.  An  out-of-band  data  transmission
          mechanism may be supported.

   SOCK_DGRAM
          Supports datagrams (connectionless, unreliable messages of a fixed maximum length).

   SOCK_SEQPACKET(is not implemented for AF_INET)
          Provides  a  sequenced,  reliable,  two-way connection-based data transmission path for datagrams of fixed
          maximum length; a consumer is required to read an entire packet with each read system call.

   SOCK_RAW
          Provides raw network protocol access.

   SOCK_RDM
          Provides a reliable datagram layer that does not guarantee ordering.

   SOCK_PACKET
          Obsolete and should not be used in new programs; see packet(7).


protocol
    Normally only a single protocol exists to support a particular socket type within a given protocol family, in which case protocol can be specified as 0.

값들을 필요로 한다.

[링크 : http://www.joinc.co.kr/modules/moniwiki/wiki.php/article/network_information#s-2.2]

'Linux API > network' 카테고리의 다른 글

hton(), ntoh()  (0) 2011.09.26
netstat 에서 0.0.0.0의 의미  (2) 2009.12.07
termios 구조체를 이용한 자국반향(echo) 제어  (0) 2009.08.27
canonical / non-canonical  (0) 2009.08.27
struct in_addr  (0) 2009.08.18
Posted by 구차니