Building.Open.Source.Network.Security.Tools.Components.And.Techniques [Electronic resources] نسخه متنی

اینجــــا یک کتابخانه دیجیتالی است

با بیش از 100000 منبع الکترونیکی رایگان به زبان فارسی ، عربی و انگلیسی

Building.Open.Source.Network.Security.Tools.Components.And.Techniques [Electronic resources] - نسخه متنی

Mike D. Schiffman

| نمايش فراداده ، افزودن یک نقد و بررسی
افزودن به کتابخانه شخصی
ارسال به دوستان
جستجو در متن کتاب
بیشتر
تنظیمات قلم

فونت

اندازه قلم

+ - پیش فرض

حالت نمایش

روز نیمروز شب
جستجو در لغت نامه
بیشتر
لیست موضوعات
توضیحات
افزودن یادداشت جدید







Framework Functions

These four functions mediate the flow of control inside libnet.



libnet_t *libnet_init (int injection_type, char *device, char
*err_buf);


libnet_init() creates the libnet environment. It initializes the library and returns a libnet descriptor. If the injection_type is LIBNET_LINK, the function initializes the injection primitives for the link-layer interface-enabling the application programmer to build packets starting at the data-link layer (which also provides more granular control over the IP layer). If libnet uses the link-layer and device is non-NULL, the function attempts to use the specified network device for packet injection. This procedure is either a short canonical string that references the device (such as "ethO" for a 100MB Ethernet card on Linux or "fxpO" for a 100MB Ethernet card on OpenBSD) or the "dots and decimals" representation of the device's IP address ("192.168.0.1"). If device is NULL, libnet attempts to find a suitable device to use. If the injection_type is LIBNET_RAW4, the function initializes the injection primitives for the IPv4 raw socket interface. The final argument, err_buf, should be a buffer of size LIBNET_ERRBUF_SIZE and holds an error message if the function fails. This function requires root privileges to execute successfully. Upon success, the function returns a valid libnet descriptor for use in later function calls; upon failure, the function returns NULL. Table 3.1 summarizes the injection_type symbolic constants which control how libnet is internally initialized.


























































Table 3.1: libnet_init() Symbolic Constants

CONSTANT


MEANING





LIBNET_LINK


Specifies the link-layer interface





LIBNET_RAW4


Specifies the IPv4 raw socket layer interface





LIBNET_RAW6


Specifies the IPv6 raw socket layer interface





LIBNET_LINK_ADV


Specifies the link-layer interface (advanced mode)





LIBNET_RAW4_ADV


Specifies the IPv4 raw socket layer interface (advanced mode)





LIBNET_RAW6_ADV


Specifies the IPv6 raw socket layer interface (advanced mode)







The final three primitives specify the advanced interface which allows the application programmer to take advantage of some of libnet's more powerful and potentially dangerous features as discussed later in this chapter.



int libnet_write (libnet_t *1);


libnet_write() writes packet(s) to the network. Depending on what control flags are set, this function writes one or more packets to the network-pulling all of the information it needs from 1. Upon success, the program returns the number of bytes written to the network interface; upon failure, it returns -1 and libnet_geterr() can tell you why.



void libnet_clear_packet(libnet_t *1);


libnet_clear_packet() clears all packet memory associated with 1. It is useful if the application programmer needs to build a packet of one type, send it, and then build and send a different packet type.



void libnet_destroy (libnet_t *1);


libnet_destroy() shuts down the libnet session referenced by 1. It closes the network interface and frees all internal memory structures associated with 1.

/ 135