sendit.helper_functions package¶
Submodules¶
sendit.helper_functions.helper module¶
-
sendit.helper_functions.helper.
MAC_to_manufacturer
(address)¶ Takes a MAC Address and searches through CSV files from IEEE to find manufacturer they belong to
Parameters: address (String) – MAC Address, bytes separated with colon (:) Returns: String of manufacturer of device with provided MAC Address Unknown if not found Return type: String
-
sendit.helper_functions.helper.
addr_to_bytes
(address)¶ Takes address represented in string consisting of hex characters, MAC or IPv6, and converts to bytes
Parameters: address (String) – addrss to convert Returns: bytes form of address Return type: bytes
-
sendit.helper_functions.helper.
bytes_to_MAC
(address)¶ Converts bytes form of MAC address to String form of MAC address
Parameters: address (bytes) – Bytes form of MAC address Returns: String form of MAC Address Return type: String
-
sendit.helper_functions.helper.
checksum
(message)¶ Calculates 16 bit checksum by 1’s compliment addition between all 16 bit words in message, and then taking the 1’s compliment of the sum Formula same as defined for IPv4, TCP, and UDP
Parameters: message (bytes) – takes header to create checksum Returns: 16 bit checksum Return type: int
-
sendit.helper_functions.helper.
create_ip_int_to_protocols
()¶
-
sendit.helper_functions.helper.
create_ip_protocols_to_int
()¶
-
sendit.helper_functions.helper.
form_pseudo_header
(src_ip, dst_ip, length, protocol, version=4)¶ Form TCP/UDP pseudoheader for checksum calculation
Parameters: - src_ip (String) – source ip
- dst_ip (String) – destination ip
- length (int) – length of tcp segment, header included
- protocol (String) – L4 Protocol - currently only support tcp and udp
- version (int) – IP version, defaults to 4
Returns: pseudoheader in bytes
Return type: bytes
-
sendit.helper_functions.helper.
get_IP
(interface)¶ Finds IP of a network interface on the host Uses UNIX tools ifconfig, grep, and awk Not supported on all Operating Systems or all kernels
Parameters: interface (String) – string of the interface to look for Returns: string representing MAC address of interface if OS does not support commands or interface not found, program exits with code 1 Return type: String
-
sendit.helper_functions.helper.
get_IPv6
(interface)¶ Finds IPv6 of a network interface on the host Uses UNIX tools ifconfig, grep, and awk Not supported on all Operating Systems
Parameters: interface (String) – string of the interface to look for Returns: string representing MAC address of interface if OS does not support commands or interface not found, program exits with code 1 Return type: String
-
sendit.helper_functions.helper.
get_MAC
(interface)¶ Finds MAC address of a network interface on the host Uses Unix tools ifconfig and grep Not supported on all Operating Systems, or all kernels
Parameters: interface (String) – string of the interface to look for Returns: string representing MAC address of interface if OS does not support commands or interface not found, program exits with code 1 Return type: String
-
sendit.helper_functions.helper.
int_to_ip
(number)¶ Converts int to string IPv4 address
Parameters: number (int) – int to convert to string IPv4 address Returns: String of IPv4 address Return type: String
-
sendit.helper_functions.helper.
ip_to_int
(address)¶ Converts string IP addrss to an int
Parameters: address (String) – string IP address Returns: int representing IP address Return type: int Raises: ValueError – if address is not valid IPv4 addrss
-
sendit.helper_functions.helper.
is_hex
(string)¶ Determines if string consists solely of ascii characters that are hexidecimal characters
Parameters: string (String) – string to check if hex Returns: boolean representing if the string consists of only hex ascii characters Return type: Boolean
-
sendit.helper_functions.helper.
is_valid_MAC
(address)¶ Determines if address if valid MAC address Checks that there are 12 characters, and all are Hex values
Parameters: address (String) – value to check if valid MAC address Returns: boolean representing if address is a valid MAC address Return type: Boolean
-
sendit.helper_functions.helper.
is_valid_ipv4
(address)¶ Determines if address if valid IPv4 address Checks that there are 4 octets, and values are between 0 and 255, inclusive
Parameters: address (String) – value to check if valid IPv4 address Returns: boolean representing if address is a valid IPv4 address Return type: Boolean
-
sendit.helper_functions.helper.
manufacturer_to_MAC
(manufacturer)¶ Provides a list of MAC prefixes based off provided manufacturer
Parameters: manufacturer (String) – Name of manufacturer Returns: list of strings of 3 byte MAC prefixes registered to that manufacturer Return type: list of Strings