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

This is a Digital Library

With over 100,000 free electronic resource in Persian, Arabic and English

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

Mike D. Schiffman

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

فونت

اندازه قلم

+ - پیش فرض

حالت نمایش

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







Chapter 3. Because there is no native support for Ethernet frame or IP packet datatypes, these libdnet functions are most useful for quick and dirty packet injection when more robust functionality such as advanced packet manipulation is not required. The library does not specify error-reporting status for the following functions. That is, errno might or might not be set upon an error condition.



eth_t *eth_open(const char *device);


eth_open() obtains a low-level handle in order to transmit Ethernet frames via device. Upon success, the function returns a valid eth_t handle pointer; upon failure, it returns NULL.



int eth_get (eth_t *e, eth_addr_t *ea);


eth_get() retrieves the hardware MAC address of the interface that e references and writes it to ea. Upon success, the function returns 0; upon failure, it returns −1.



int eth_set (eth_t *e, const eth_addr_t *ea);


eth_set() sets the hardware MAC address of the interface that e references to the Ethernet address stored in ea. Upon success, the function returns 0; upon failure, it returns −1.



ssize_t eth_send (eth_t *e, const void *buf, size_t len);


eth_send() writes the Ethernet frame in buf of size len bytes to the network via the handle e. Upon success, the function returns the number of bytes written; upon failure, it returns −1.



eth_t *eth_close (eth_t *e);


eth_close() closes the underlying network interface and frees any memory associated with e. The function returns NULL.



ip_t *ip_open (void);


ip_open() obtains a handle in order to transmit IP packets. Upon success, the function returns a valid ip_t handle pointer; upon failure, it returns NULL.



size_t ip_add_option (void *buf, size_t len, int proto, const void *optbuf, size_t optlen);


ip_add_option() builds a header options list for the protocol proto, which should be either IP_PROTO_IP or IP_PROTO_TCP. The options list, optbuf, should contain a valid sequence of options of size optlen bytes.

They are then appended to the end of the IP or TCP header stored in buf. Any existing payload shifts in memory to enable the options header to be padded with NOPs to an even-word boundary if necessary. Upon success, the function returns the length of the added options list; upon failure, it returns −1 and sets errno.



void ip_checksum (void *buf, size_t len);


ip_checksum() calculates the IP checksum for the IP packet in buf of size len bytes. If the packet contains a UDP, TCP, or ICMP header beyond the IP header, the function computes checksums for those headers as well.



ssize_t ip_send (ip_t *i, const void *buf, size_t len);


ip_send() writes the IP packet in buf of size len bytes to the network via the handle i. Upon success, the function returns the number of bytes written; upon failure, it returns −1.



ip_t *ip_close (ip_t *i);


ip_close() closes the underlying network interface and frees any memory associated with i. The function returns NULL.

/ 135