diff options
author | Alexey Kardashevskiy <aik@ozlabs.ru> | 2016-01-22 11:48:30 +1100 |
---|---|---|
committer | Alexey Kardashevskiy <aik@ozlabs.ru> | 2016-01-29 17:09:58 +1100 |
commit | 253298295e0a0404a5380247abdf08c29f103032 (patch) | |
tree | 19aebea2f090f5f4c16729dc23d19721b48f421f /clients | |
parent | 2e9f1f28d236ba2376d4af22fd4181d309082820 (diff) | |
download | SLOF-253298295e0a0404a5380247abdf08c29f103032.zip SLOF-253298295e0a0404a5380247abdf08c29f103032.tar.gz SLOF-253298295e0a0404a5380247abdf08c29f103032.tar.bz2 |
net-snk: Fix coding style
This restyles function prototypes:
- return types on the same line;
- opening brace is on the next line.
VIM configs used for this was:
set noexpandtab
set tabstop=8
set shiftwidth=4
set cino=:0,(0
This replaces [><]* with "*" as >< are also used to resolve merge
conflicts.
This removes trailing spaces.
This removes some redundant braces.
This should cause no behavioural change.
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Diffstat (limited to 'clients')
-rw-r--r-- | clients/net-snk/app/netlib/dhcp.c | 148 | ||||
-rw-r--r-- | clients/net-snk/app/netlib/ethernet.c | 37 | ||||
-rw-r--r-- | clients/net-snk/app/netlib/ipv4.c | 113 | ||||
-rw-r--r-- | clients/net-snk/app/netlib/ipv4.h | 2 | ||||
-rw-r--r-- | clients/net-snk/app/netlib/ipv6.c | 63 | ||||
-rw-r--r-- | clients/net-snk/app/netlib/tcp.c | 16 | ||||
-rw-r--r-- | clients/net-snk/app/netlib/tftp.c | 51 | ||||
-rw-r--r-- | clients/net-snk/app/netlib/udp.c | 26 |
8 files changed, 194 insertions, 262 deletions
diff --git a/clients/net-snk/app/netlib/dhcp.c b/clients/net-snk/app/netlib/dhcp.c index bd9c104..c9b3d6d 100644 --- a/clients/net-snk/app/netlib/dhcp.c +++ b/clients/net-snk/app/netlib/dhcp.c @@ -11,7 +11,7 @@ *****************************************************************************/ -/*>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> ALGORITHMS <<<<<<<<<<<<<<<<<<<<<<<<<<<<<*/ +/******************************* ALGORITHMS ******************************/ /** \file dhcp.c <pre> * **************** State-transition diagram for DHCP client ************* @@ -41,7 +41,7 @@ * </pre> */ -/*>>>>>>>>>>>>>>>>>>>>> DEFINITIONS & DECLARATIONS <<<<<<<<<<<<<<<<<<<<<<*/ +/********************** DEFINITIONS & DECLARATIONS ***********************/ #include <dhcp.h> #include <ethernet.h> @@ -110,11 +110,11 @@ static uint8_t dhcp_magic[] = {0x63, 0x82, 0x53, 0x63}; * If flag[i] == TRUE then field for i-th option retains valid value and * information from this field may retrived (in case of receiving) or will * be transmitted (in case of transmitting). - * + * */ typedef struct { uint8_t flag[256]; /**< Show if corresponding opt. is valid */ - uint8_t request_list[256]; /**< o.55 If i-th member is TRUE, then i-th + uint8_t request_list[256]; /**< o.55 If i-th member is TRUE, then i-th option will be requested from server */ uint32_t server_ID; /**< o.54 Identifies DHCP-server */ uint32_t requested_IP; /**< o.50 Must be filled in DHCP-Request */ @@ -132,45 +132,35 @@ typedef struct { static uint8_t dhcp_state; -/*>>>>>>>>>>>>>>>>>>>>>>>>>>>> PROTOTYPES <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<*/ +/***************************** PROTOTYPES ********************************/ -static int32_t -dhcp_attempt(int fd); +static int32_t dhcp_attempt(int fd); -static int32_t -dhcp_encode_options(uint8_t * opt_field, dhcp_options_t * opt_struct); +static int32_t dhcp_encode_options(uint8_t * opt_field, dhcp_options_t * opt_struct); -static int32_t -dhcp_decode_options(uint8_t opt_field[], uint32_t opt_len, - dhcp_options_t * opt_struct); +static int32_t dhcp_decode_options(uint8_t opt_field[], uint32_t opt_len, + dhcp_options_t * opt_struct); -static int8_t -dhcp_merge_options(uint8_t dst_options[], uint32_t * dst_len, - uint8_t src_options[], uint32_t src_len); +static int8_t dhcp_merge_options(uint8_t dst_options[], uint32_t * dst_len, + uint8_t src_options[], uint32_t src_len); -static int8_t -dhcp_find_option(uint8_t options[], uint32_t len, - uint8_t op_code, uint32_t * op_offset); +static int8_t dhcp_find_option(uint8_t options[], uint32_t len, + uint8_t op_code, uint32_t * op_offset); -static void -dhcp_append_option(uint8_t dst_options[], uint32_t * dst_len, - uint8_t * new_option); +static void dhcp_append_option(uint8_t dst_options[], uint32_t * dst_len, + uint8_t * new_option); -static void -dhcp_combine_option(uint8_t dst_options[], uint32_t * dst_len, - uint32_t dst_offset, uint8_t * new_option); +static void dhcp_combine_option(uint8_t dst_options[], uint32_t * dst_len, + uint32_t dst_offset, uint8_t * new_option); -static void -dhcp_send_discover(int fd); +static void dhcp_send_discover(int fd); -static void -dhcp_send_request(int fd); +static void dhcp_send_request(int fd); -static uint8_t -strtoip(int8_t * str, uint32_t * ip); +static uint8_t strtoip(int8_t * str, uint32_t * ip); -/*>>>>>>>>>>>>>>>>>>>>>>>>>>>> LOCAL VARIABLES <<<<<<<<<<<<<<<<<<<<<<<<<<*/ +/***************************** LOCAL VARIABLES ***************************/ static uint8_t ether_packet[ETH_MTU_SIZE]; static uint32_t dhcp_own_ip = 0; @@ -182,17 +172,15 @@ static uint32_t dhcp_xid; static char * response_buffer; -/*>>>>>>>>>>>>>>>>>>>>>>>>>>>> IMPLEMENTATION <<<<<<<<<<<<<<<<<<<<<<<<<<<*/ +/***************************** IMPLEMENTATION ****************************/ -void -dhcpv4_generate_transaction_id(void) +void dhcpv4_generate_transaction_id(void) { dhcp_xid = (rand() << 16) ^ rand(); } -int32_t -dhcpv4(char *ret_buffer, filename_ip_t * fn_ip) { - +int32_t dhcpv4(char *ret_buffer, filename_ip_t *fn_ip) +{ uint32_t dhcp_tftp_ip = 0; int fd = fn_ip->fd; @@ -226,9 +214,9 @@ dhcpv4(char *ret_buffer, filename_ip_t * fn_ip) { } else { // TFTP server defined by its name - if (!strtoip(dhcp_tftp_name, &(dhcp_tftp_ip))) { - if (!dns_get_ip(fd, dhcp_tftp_name, (uint8_t *)&(dhcp_tftp_ip), 4)) { - // DNS error - can't obtain TFTP-server name + if (!strtoip(dhcp_tftp_name, &dhcp_tftp_ip)) { + if (!dns_get_ip(fd, dhcp_tftp_name, (uint8_t *)&dhcp_tftp_ip, 4)) { + // DNS error - can't obtain TFTP-server name // Use TFTP-ip from siaddr field, if presented if (dhcp_siaddr_ip) { dhcp_tftp_ip = dhcp_siaddr_ip; @@ -252,8 +240,8 @@ dhcpv4(char *ret_buffer, filename_ip_t * fn_ip) { /** * DHCP: Tries o obtain DHCP parameters, refer to state-transition diagram */ -static int32_t -dhcp_attempt(int fd) { +static int32_t dhcp_attempt(int fd) +{ int sec; // Send DISCOVER message and switch DHCP-client to SELECT state @@ -277,7 +265,7 @@ dhcp_attempt(int fd) { } while (get_timer() > 0); } - // timeout + // timeout return 0; } @@ -285,7 +273,7 @@ dhcp_attempt(int fd) { * DHCP: Supplements DHCP-message with options stored in structure. * For more information about option coding see dhcp_options_t. * - * @param opt_field Points to the "vend" field of DHCP-message + * @param opt_field Points to the "vend" field of DHCP-message * (destination) * @param opt_struct this structure stores info about the options which * will be added to DHCP-message (source) @@ -293,8 +281,8 @@ dhcp_attempt(int fd) { * FALSE - error condition occurs. * @see dhcp_options_t */ -static int32_t -dhcp_encode_options(uint8_t * opt_field, dhcp_options_t * opt_struct) { +static int32_t dhcp_encode_options(uint8_t * opt_field, dhcp_options_t * opt_struct) +{ uint8_t * options = opt_field; uint16_t i, sum; // used to define is any options set @@ -387,7 +375,7 @@ dhcp_encode_options(uint8_t * opt_field, dhcp_options_t * opt_struct) { * DHCP: Extracts encoded options from DHCP-message into the structure. * For more information about option coding see dhcp_options_t. * - * @param opt_field Points to the "options" field of DHCP-message + * @param opt_field Points to the "options" field of DHCP-message * (source). * @param opt_len Length of "options" field. * @param opt_struct this structure stores info about the options which @@ -396,9 +384,9 @@ dhcp_encode_options(uint8_t * opt_field, dhcp_options_t * opt_struct) { * FALSE - error condition occurs. * @see dhcp_options_t */ -static int32_t -dhcp_decode_options(uint8_t opt_field[], uint32_t opt_len, - dhcp_options_t * opt_struct) { +static int32_t dhcp_decode_options(uint8_t opt_field[], uint32_t opt_len, + dhcp_options_t * opt_struct) +{ int32_t offset = 0; memset(opt_struct, 0, sizeof(dhcp_options_t)); @@ -414,30 +402,30 @@ dhcp_decode_options(uint8_t opt_field[], uint32_t opt_len, switch(opt_field[offset]) { case DHCP_OVERLOAD : opt_struct -> overload = opt_field[offset + 2]; - offset += 2 + opt_field[offset + 1]; + offset += 2 + opt_field[offset + 1]; break; case DHCP_REQUESTED_IP : opt_struct -> requested_IP = htonl(* (uint32_t *) (opt_field + offset + 2)); - offset += 2 + opt_field[offset + 1]; + offset += 2 + opt_field[offset + 1]; break; case DHCP_MASK : opt_struct -> flag[DHCP_MASK] = 1; opt_struct -> subnet_mask = htonl(* (uint32_t *) (opt_field + offset + 2)); - offset += 2 + opt_field[offset + 1]; + offset += 2 + opt_field[offset + 1]; break; case DHCP_DNS : opt_struct -> flag[DHCP_DNS] = 1; opt_struct -> dns_IP = htonl(* (uint32_t *) (opt_field + offset + 2)); - offset += 2 + opt_field[offset + 1]; + offset += 2 + opt_field[offset + 1]; break; case DHCP_ROUTER : opt_struct -> flag[DHCP_ROUTER] = 1; opt_struct -> router_IP = htonl(* (uint32_t *) (opt_field + offset + 2)); - offset += 2 + opt_field[offset + 1]; + offset += 2 + opt_field[offset + 1]; break; case DHCP_MSG_TYPE : @@ -499,7 +487,8 @@ dhcp_decode_options(uint8_t opt_field[], uint32_t opt_len, * FALSE - error condition occurs. */ static int8_t dhcp_merge_options(uint8_t dst_options[], uint32_t * dst_len, - uint8_t src_options[], uint32_t src_len) { + uint8_t src_options[], uint32_t src_len) +{ int32_t dst_offset, src_offset = 0; // remove ENDOPT if presented @@ -529,7 +518,7 @@ static int8_t dhcp_merge_options(uint8_t dst_options[], uint32_t * dst_len, } } - if (src_offset == src_len) + if (src_offset == src_len) return 1; return 0; } @@ -547,7 +536,8 @@ static int8_t dhcp_merge_options(uint8_t dst_options[], uint32_t * dst_len, * FALSE - option wasn't find. */ static int8_t dhcp_find_option(uint8_t options[], uint32_t len, - uint8_t op_code, uint32_t * op_offset) { + uint8_t op_code, uint32_t * op_offset) +{ uint32_t srch_offset = 0; * op_offset = 0; @@ -575,9 +565,9 @@ static int8_t dhcp_find_option(uint8_t options[], uint32_t len, * @param dst_len length of the "options" field (modified) * @param new_option points to an option in another list (src) */ -static void -dhcp_append_option(uint8_t dst_options[], uint32_t * dst_len, - uint8_t * new_option) { +static void dhcp_append_option(uint8_t dst_options[], uint32_t * dst_len, + uint8_t * new_option) +{ memcpy(dst_options + ( * dst_len), new_option, 2 + (* (new_option + 1))); * dst_len += 2 + *(new_option + 1); } @@ -593,10 +583,9 @@ dhcp_append_option(uint8_t dst_options[], uint32_t * dst_len, * @param dst_offset offset of the option from beginning of the list * @param new_option points to an option in another list (src) */ -static void -dhcp_combine_option(uint8_t dst_options[], uint32_t * dst_len, - uint32_t dst_offset, uint8_t * new_option) { - +static void dhcp_combine_option(uint8_t dst_options[], uint32_t * dst_len, + uint32_t dst_offset, uint8_t * new_option) +{ uint8_t tmp_buffer[1024]; // use to provide safe memcpy uint32_t tail_len; @@ -619,8 +608,8 @@ dhcp_combine_option(uint8_t dst_options[], uint32_t * dst_len, /** * DHCP: Sends DHCP-Discover message. Looks for DHCP servers. */ -static void -dhcp_send_discover(int fd) { +static void dhcp_send_discover(int fd) +{ uint32_t packetsize = sizeof(struct iphdr) + sizeof(struct udphdr) + sizeof(struct btphdr); struct btphdr *btph; @@ -663,8 +652,8 @@ dhcp_send_discover(int fd) { /** * DHCP: Sends DHCP-Request message. Asks for acknowledgment to occupy IP. */ -static void -dhcp_send_request(int fd) { +static void dhcp_send_request(int fd) +{ uint32_t packetsize = sizeof(struct iphdr) + sizeof(struct udphdr) + sizeof(struct btphdr); struct btphdr *btph; @@ -713,7 +702,8 @@ dhcp_send_request(int fd) { /** * DHCP: Sends DHCP-Release message. Releases occupied IP. */ -void dhcp_send_release(int fd) { +void dhcp_send_release(int fd) +{ uint32_t packetsize = sizeof(struct iphdr) + sizeof(struct udphdr) + sizeof(struct btphdr); struct btphdr *btph; @@ -740,7 +730,7 @@ void dhcp_send_release(int fd) { dhcp_encode_options(btph -> vend, &opt); - fill_udphdr(ðer_packet[sizeof(struct iphdr)], + fill_udphdr(ðer_packet[sizeof(struct iphdr)], sizeof(struct btphdr) + sizeof(struct udphdr), UDPPORT_BOOTPC, UDPPORT_BOOTPS); fill_iphdr(ether_packet, sizeof(struct btphdr) + @@ -763,13 +753,13 @@ void dhcp_send_release(int fd) { * @see btphdr */ -int8_t -handle_dhcp(int fd, uint8_t * packet, int32_t packetsize) { +int8_t handle_dhcp(int fd, uint8_t * packet, int32_t packetsize) +{ struct btphdr * btph; struct iphdr * iph; dhcp_options_t opt; - memset(&opt, 0, sizeof(dhcp_options_t)); + memset(&opt, 0, sizeof(dhcp_options_t)); btph = (struct btphdr *) packet; iph = (struct iphdr *) packet - sizeof(struct udphdr) - sizeof(struct iphdr); @@ -801,7 +791,7 @@ handle_dhcp(int fd, uint8_t * packet, int32_t packetsize) { } - // decode options + // decode options if (!dhcp_decode_options(btph -> vend, packetsize - sizeof(struct btphdr) + sizeof(btph -> vend), &opt)) { @@ -915,7 +905,7 @@ handle_dhcp(int fd, uint8_t * packet, int32_t packetsize) { else { strcpy((char *) dhcp_filename, ""); if (opt.overload != DHCP_OVERLOAD_FILE && - opt.overload != DHCP_OVERLOAD_BOTH && + opt.overload != DHCP_OVERLOAD_BOTH && strlen((char *) btph -> file)) { strncpy((char *) dhcp_filename, (char *) btph->file, @@ -975,8 +965,8 @@ handle_dhcp(int fd, uint8_t * packet, int32_t packetsize) { * @return TRUE - IP converted successfully; * FALSE - error condition occurs (e.g. bad format) */ -static uint8_t -strtoip(int8_t * str, uint32_t * ip) { +static uint8_t strtoip(int8_t * str, uint32_t * ip) +{ int8_t ** ptr = &str; int16_t i = 0, res, len; char octet[256]; @@ -987,7 +977,7 @@ strtoip(int8_t * str, uint32_t * ip) { if (i > 3 || !isdigit(**ptr)) return 0; if (strstr((char *) * ptr, ".") != NULL) { - len = (int16_t) ((int8_t *) strstr((char *) * ptr, ".") - + len = (int16_t) ((int8_t *) strstr((char *) * ptr, ".") - (int8_t *) (* ptr)); strncpy(octet, (char *) * ptr, len); octet[len] = 0; * ptr += len; diff --git a/clients/net-snk/app/netlib/ethernet.c b/clients/net-snk/app/netlib/ethernet.c index bbfd6d1..c24d64f 100644 --- a/clients/net-snk/app/netlib/ethernet.c +++ b/clients/net-snk/app/netlib/ethernet.c @@ -11,7 +11,7 @@ *****************************************************************************/ -/*>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> ALGORITHMS <<<<<<<<<<<<<<<<<<<<<<<<<<<<<*/ +/******************************* ALGORITHMS ******************************/ /** \file netbase.c <pre> * *********************** Receive-handle diagram ************************* @@ -36,12 +36,12 @@ * | APPLICATION +----------------+-----------+ * V | | * upper DNS (handle_dns) BootP / DHCP (handle_bootp_client) - * + * * ************************************************************************ * </pre> */ -/*>>>>>>>>>>>>>>>>>>>>>>> DEFINITIONS & DECLARATIONS <<<<<<<<<<<<<<<<<<<<*/ +/************************ DEFINITIONS & DECLARATIONS *********************/ #include <ethernet.h> #include <string.h> @@ -50,22 +50,22 @@ #include <ipv6.h> -/*>>>>>>>>>>>>>>>>>>>>>>>>>>>>> LOCAL VARIABLES <<<<<<<<<<<<<<<<<<<<<<<<<*/ +/****************************** LOCAL VARIABLES **************************/ static uint8_t ether_packet[ETH_MTU_SIZE]; static uint8_t own_mac[6] = {0, 0, 0, 0, 0, 0}; static uint8_t multicast_mac[] = {0x01, 0x00, 0x5E}; static const uint8_t broadcast_mac[] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}; -/*>>>>>>>>>>>>>>>>>>>>>>>>>>>>> IMPLEMENTATION <<<<<<<<<<<<<<<<<<<<<<<<<<*/ +/****************************** IMPLEMENTATION ***************************/ /** * Ethernet: Set the own MAC address to initializes ethernet layer. * * @param own_mac own hardware-address (MAC) */ -void -set_mac_address(const uint8_t * _own_mac) { +void set_mac_address(const uint8_t * _own_mac) +{ if (_own_mac) memcpy(own_mac, _own_mac, 6); else @@ -77,19 +77,19 @@ set_mac_address(const uint8_t * _own_mac) { * * @return own hardware-address (MAC) */ -const uint8_t * -get_mac_address(void) { +const uint8_t *get_mac_address(void) +{ return own_mac; } /** * Ethernet: Check if given multicast address is a multicast MAC address - * starting with 0x3333 + * starting with 0x3333 * - * @return true or false + * @return true or false */ -static uint8_t -is_multicast_mac(uint8_t * mac) { +static uint8_t is_multicast_mac(uint8_t * mac) +{ uint16_t mc = 0x3333; if (memcmp(mac, &mc, 2) == 0) @@ -98,7 +98,6 @@ is_multicast_mac(uint8_t * mac) { return 0; } - /** * Ethernet: Receives an ethernet-packet and handles it according to * Receive-handle diagram. @@ -107,8 +106,8 @@ is_multicast_mac(uint8_t * mac) { * @return ZERO - packet was handled or no packets received; * NON ZERO - error condition occurs. */ -int32_t -receive_ether(int fd) { +int32_t receive_ether(int fd) +{ int32_t bytes_received; struct ethhdr * ethh; @@ -176,9 +175,9 @@ send_ether(int fd, void* buffer, int len) * @see fill_dnshdr * @see fill_btphdr */ -void -fill_ethhdr(uint8_t * packet, uint16_t eth_type, - const uint8_t * src_mac, const uint8_t * dest_mac) { +void fill_ethhdr(uint8_t * packet, uint16_t eth_type, + const uint8_t * src_mac, const uint8_t * dest_mac) +{ struct ethhdr * ethh = (struct ethhdr *) packet; ethh -> type = htons(eth_type); diff --git a/clients/net-snk/app/netlib/ipv4.c b/clients/net-snk/app/netlib/ipv4.c index aef38ce..c769612 100644 --- a/clients/net-snk/app/netlib/ipv4.c +++ b/clients/net-snk/app/netlib/ipv4.c @@ -11,7 +11,7 @@ *****************************************************************************/ -/*>>>>>>>>>>>>>>>>>>>>> DEFINITIONS & DECLARATIONS <<<<<<<<<<<<<<<<<<<<<<*/ +/********************** DEFINITIONS & DECLARATIONS ***********************/ #include <ipv4.h> #include <udp.h> @@ -81,32 +81,26 @@ struct icmphdr { } payload; }; -/*>>>>>>>>>>>>>>>>>>>>>>>>>>>>> PROTOTYPES <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<*/ +/****************************** PROTOTYPES *******************************/ -static unsigned short -checksum(unsigned short *packet, int words); +static unsigned short checksum(unsigned short *packet, int words); -static void -arp_send_request(int fd, uint32_t dest_ip); +static void arp_send_request(int fd, uint32_t dest_ip); -static void -arp_send_reply(int fd, uint32_t src_ip, uint8_t * src_mac); +static void arp_send_reply(int fd, uint32_t src_ip, uint8_t * src_mac); -static void -fill_arphdr(uint8_t * packet, uint8_t opcode, - const uint8_t * src_mac, uint32_t src_ip, - const uint8_t * dest_mac, uint32_t dest_ip); +static void fill_arphdr(uint8_t * packet, uint8_t opcode, + const uint8_t * src_mac, uint32_t src_ip, + const uint8_t * dest_mac, uint32_t dest_ip); -static arp_entry_t* -lookup_mac_addr(uint32_t ipv4_addr); +static arp_entry_t *lookup_mac_addr(uint32_t ipv4_addr); -static void -fill_udp_checksum(struct iphdr *ipv4_hdr); +static void fill_udp_checksum(struct iphdr *ipv4_hdr); -static int8_t -handle_icmp(int fd, struct iphdr * iph, uint8_t * packet, int32_t packetsize); +static int8_t handle_icmp(int fd, struct iphdr * iph, uint8_t * packet, + int32_t packetsize); -/*>>>>>>>>>>>>>>>>>>>>>>>>>>>>> LOCAL VARIABLES <<<<<<<<<<<<<<<<<<<<<<<<<*/ +/****************************** LOCAL VARIABLES **************************/ /* Routing parameters */ static uint32_t own_ip = 0; @@ -133,13 +127,12 @@ static int pending_pkt_len; /* Function pointer send_ip. Points either to send_ipv4() or send_ipv6() */ int (*send_ip) (int fd, void *, int); -/*>>>>>>>>>>>>>>>>>>>>>>>>>>>> IMPLEMENTATION <<<<<<<<<<<<<<<<<<<<<<<<<<<*/ +/***************************** IMPLEMENTATION ****************************/ /** * IPv4: Initialize the environment for the IPv4 layer. */ -static void -ipv4_init(void) +static void ipv4_init(void) { int i; @@ -155,7 +148,7 @@ ipv4_init(void) arp_table[i].pkt_pending = 0; } - /* Set IP send function to send_ipv4() */ + /* Set IP send function to send_ipv4() */ send_ip = &send_ipv4; } @@ -164,8 +157,7 @@ ipv4_init(void) * * @param _own_ip client IPv4 address (e.g. 127.0.0.1) */ -void -set_ipv4_address(uint32_t _own_ip) +void set_ipv4_address(uint32_t _own_ip) { own_ip = _own_ip; ipv4_init(); @@ -176,8 +168,7 @@ set_ipv4_address(uint32_t _own_ip) * * @return client IPv4 address (e.g. 127.0.0.1) */ -uint32_t -get_ipv4_address(void) +uint32_t get_ipv4_address(void) { return own_ip; } @@ -187,8 +178,7 @@ get_ipv4_address(void) * * @param _own_ip multicast IPv4 address (224.0.0.0 - 239.255.255.255) */ -void -set_ipv4_multicast(uint32_t _multicast_ip) +void set_ipv4_multicast(uint32_t _multicast_ip) { // is this IP Multicast out of range (224.0.0.0 - 239.255.255.255) if((htonl(_multicast_ip) < 0xE0000000) @@ -212,8 +202,7 @@ set_ipv4_multicast(uint32_t _multicast_ip) * * @return multicast IPv4 address (224.0.0.0 - 239.255.255.255 or 0 if not set) */ -uint32_t -get_ipv4_multicast(void) +uint32_t get_ipv4_multicast(void) { return multicast_ip; } @@ -223,8 +212,7 @@ get_ipv4_multicast(void) * * @param _router_ip router IPv4 address */ -void -set_ipv4_router(uint32_t _router_ip) +void set_ipv4_router(uint32_t _router_ip) { router_ip = _router_ip; ipv4_init(); @@ -235,8 +223,7 @@ set_ipv4_router(uint32_t _router_ip) * * @return router IPv4 address */ -uint32_t -get_ipv4_router(void) +uint32_t get_ipv4_router(void) { return router_ip; } @@ -246,8 +233,7 @@ get_ipv4_router(void) * * @param _subnet_mask netmask of the own IPv4 address */ -void -set_ipv4_netmask(uint32_t _subnet_mask) +void set_ipv4_netmask(uint32_t _subnet_mask) { subnet_mask = _subnet_mask; ipv4_init(); @@ -258,8 +244,7 @@ set_ipv4_netmask(uint32_t _subnet_mask) * * @return netmask of the own IPv4 address */ -uint32_t -get_ipv4_netmask(void) +uint32_t get_ipv4_netmask(void) { return subnet_mask; } @@ -282,9 +267,9 @@ get_ipv4_netmask(void) * @see fill_dnshdr * @see fill_btphdr */ -void -fill_iphdr(uint8_t * packet, uint16_t packetsize, - uint8_t ip_proto, uint32_t ip_src, uint32_t ip_dst) { +void fill_iphdr(uint8_t * packet, uint16_t packetsize, + uint8_t ip_proto, uint32_t ip_src, uint32_t ip_dst) +{ struct iphdr * iph = (struct iphdr *) packet; iph -> ip_hlv = 0x45; @@ -310,8 +295,7 @@ fill_iphdr(uint8_t * packet, uint16_t packetsize, * @see receive_ether * @see iphdr */ -int8_t -handle_ipv4(int fd, uint8_t * ip_packet, int32_t packetsize) +int8_t handle_ipv4(int fd, uint8_t * ip_packet, int32_t packetsize) { struct iphdr * iph; int32_t old_sum; @@ -424,8 +408,7 @@ handle_ipv4(int fd, uint8_t * ip_packet, int32_t packetsize) * @see receive_ether * @see iphdr */ -int -send_ipv4(int fd, void* buffer, int len) +int send_ipv4(int fd, void* buffer, int len) { arp_entry_t *arp_entry = 0; struct iphdr *ip; @@ -538,11 +521,9 @@ send_ipv4(int fd, void* buffer, int len) * * @param ipv4_hdr Points to the place where IPv4-header starts. */ - -static void -fill_udp_checksum(struct iphdr *ipv4_hdr) +static void fill_udp_checksum(struct iphdr *ipv4_hdr) { - int i; + unsigned i; unsigned long checksum = 0; struct iphdr ip_hdr; char *ptr; @@ -585,8 +566,7 @@ fill_udp_checksum(struct iphdr *ipv4_hdr) * @return Checksum * @see iphdr */ -static unsigned short -checksum(unsigned short * packet, int words) +static unsigned short checksum(unsigned short * packet, int words) { unsigned long checksum; @@ -598,8 +578,7 @@ checksum(unsigned short * packet, int words) return ~checksum; } -static arp_entry_t* -lookup_mac_addr(uint32_t ipv4_addr) +static arp_entry_t* lookup_mac_addr(uint32_t ipv4_addr) { unsigned int i; @@ -618,8 +597,7 @@ lookup_mac_addr(uint32_t ipv4_addr) * @param fd socket fd * @param dest_ip IP of the host which MAC should be obtained */ -static void -arp_send_request(int fd, uint32_t dest_ip) +static void arp_send_request(int fd, uint32_t dest_ip) { arp_entry_t *arp_entry = &arp_table[arp_producer]; @@ -642,8 +620,7 @@ arp_send_request(int fd, uint32_t dest_ip) * @param src_ip requester IP address (foreign IP) * @param src_mac requester MAC address (foreign MAC) */ -static void -arp_send_reply(int fd, uint32_t src_ip, uint8_t * src_mac) +static void arp_send_reply(int fd, uint32_t src_ip, uint8_t * src_mac) { arp_entry_t *arp_entry = &arp_table[arp_producer]; @@ -674,10 +651,9 @@ arp_send_reply(int fd, uint32_t src_ip, uint8_t * src_mac) * @see arphdr * @see fill_ethhdr */ -static void -fill_arphdr(uint8_t * packet, uint8_t opcode, - const uint8_t * src_mac, uint32_t src_ip, - const uint8_t * dest_mac, uint32_t dest_ip) +static void fill_arphdr(uint8_t * packet, uint8_t opcode, + const uint8_t * src_mac, uint32_t src_ip, + const uint8_t * dest_mac, uint32_t dest_ip) { struct arphdr * arph = (struct arphdr *) packet; @@ -706,8 +682,7 @@ fill_arphdr(uint8_t * packet, uint8_t opcode, * @see receive_ether * @see arphdr */ -int8_t -handle_arp(int fd, uint8_t * packet, int32_t packetsize) +int8_t handle_arp(int fd, uint8_t * packet, int32_t packetsize) { struct arphdr * arph = (struct arphdr *) packet; @@ -780,8 +755,7 @@ handle_arp(int fd, uint8_t * packet, int32_t packetsize) * @param fd socket descriptor * @param _ping_dst_ip destination IPv4 address */ -void -ping_ipv4(int fd, uint32_t _ping_dst_ip) +void ping_ipv4(int fd, uint32_t _ping_dst_ip) { unsigned char packet[sizeof(struct iphdr) + sizeof(struct icmphdr)]; struct icmphdr *icmp; @@ -814,8 +788,7 @@ ping_ipv4(int fd, uint32_t _ping_dst_ip) * * @return ping_dst_ip host IPv4 address */ -uint32_t -pong_ipv4(void) +uint32_t pong_ipv4(void) { return ping_dst_ip; } @@ -830,8 +803,8 @@ pong_ipv4(void) * NON ZERO - packet was not handled (e.g. bad format) * @see handle_ipv4 */ -static int8_t -handle_icmp(int fd, struct iphdr * iph, uint8_t * packet, int32_t packetsize) +static int8_t handle_icmp(int fd, struct iphdr * iph, uint8_t * packet, + int32_t packetsize) { struct icmphdr *icmp = (struct icmphdr *) packet; diff --git a/clients/net-snk/app/netlib/ipv4.h b/clients/net-snk/app/netlib/ipv4.h index eb719f8..008f6de 100644 --- a/clients/net-snk/app/netlib/ipv4.h +++ b/clients/net-snk/app/netlib/ipv4.h @@ -60,7 +60,7 @@ struct arphdr { uint32_t dest_ip; /**< Proto address of target of this packet */ } __attribute((packed)); -/*>>>>>>>>>>>>> Initialization of the IPv4 network layer. <<<<<<<<<<<<<*/ +/************** Initialization of the IPv4 network layer. **************/ extern void set_ipv4_address(uint32_t own_ip); extern uint32_t get_ipv4_address(void); extern void set_ipv4_multicast(uint32_t multicast_ip); diff --git a/clients/net-snk/app/netlib/ipv6.c b/clients/net-snk/app/netlib/ipv6.c index 3579dc9..4269fe9 100644 --- a/clients/net-snk/app/netlib/ipv6.c +++ b/clients/net-snk/app/netlib/ipv6.c @@ -63,8 +63,7 @@ struct ip6_config ip6_state; * @param fd Socket descriptor * @param _own_ip client IPv6 address (e.g. ::1) */ -void -set_ipv6_address (int fd, ip6_addr_t *_own_ip6) +void set_ipv6_address(int fd, ip6_addr_t *_own_ip6) { struct ip6addr_list_entry *ile; @@ -104,8 +103,7 @@ set_ipv6_address (int fd, ip6_addr_t *_own_ip6) * * @return pointer to client IPv6 address (e.g. ::1) */ -ip6_addr_t * -get_ipv6_address (void) +ip6_addr_t *get_ipv6_address(void) { return (ip6_addr_t *) &(own_ip6->addr); } @@ -116,8 +114,7 @@ get_ipv6_address (void) * @return 0 - IPv6 address is not in list * 1 - IPv6 address is in list */ -static int8_t -find_ip6addr (ip6_addr_t *ip) +static int8_t find_ip6addr(ip6_addr_t *ip) { struct ip6addr_list_entry *n = NULL; @@ -143,8 +140,7 @@ find_ip6addr (ip6_addr_t *ip) * @see handle_udp * @see ip6hdr */ -int8_t -handle_ipv6 (int fd, uint8_t * ip6_packet, int32_t packetsize) +int8_t handle_ipv6(int fd, uint8_t * ip6_packet, int32_t packetsize) { struct ip6hdr *ip6 = NULL; @@ -188,11 +184,9 @@ handle_ipv6 (int fd, uint8_t * ip6_packet, int32_t packetsize) * @see fill_dnshdr * @see fill_btphdr */ -void -fill_ip6hdr (uint8_t * packet, uint16_t packetsize, - uint8_t ip_proto, ip6_addr_t *ip6_src, ip6_addr_t *ip6_dst) +void fill_ip6hdr(uint8_t * packet, uint16_t packetsize, + uint8_t ip_proto, ip6_addr_t *ip6_src, ip6_addr_t *ip6_dst) { - struct ip6hdr * ip6h = (struct ip6hdr *) packet; ip6h->ver_tc_fl = 6 << 28; // set version to 6 @@ -208,8 +202,7 @@ fill_ip6hdr (uint8_t * packet, uint16_t packetsize, * See RFC 4291 "IP Version 6 Addressing Architecture" * */ -uint64_t -mac2eui64 (const uint8_t *mac) +uint64_t mac2eui64(const uint8_t *mac) { uint8_t eui64id[8]; uint64_t retid; @@ -229,8 +222,7 @@ mac2eui64 (const uint8_t *mac) * @param own_mac MAC of NIC * @return ll_addr pointer to newly created link-local address */ -ip6_addr_t * -ip6_create_ll_address (const uint8_t *own_mac) +ip6_addr_t *ip6_create_ll_address(const uint8_t *own_mac) { ip6_addr_t *ll_addr; @@ -247,8 +239,7 @@ ip6_create_ll_address (const uint8_t *own_mac) * @param struct ip6_addr_list_entry *ip6 * @return true or false */ -int8_t -unknown_prefix (ip6_addr_t *ip) +int8_t unknown_prefix(ip6_addr_t *ip) { struct ip6addr_list_entry *node; @@ -264,8 +255,7 @@ unknown_prefix (ip6_addr_t *ip) * @return NULL - malloc failed * ! NULL - pointer to new prefix_info */ -struct prefix_info * -ip6_create_prefix_info () +struct prefix_info *ip6_create_prefix_info() { struct prefix_info *prfx_info; @@ -283,8 +273,7 @@ ip6_create_prefix_info () * @param ip6_addr prefix (as received in RA) * @return NULL - pointer to new ip6addr_list entry */ -void * -ip6_prefix2addr (ip6_addr_t prefix) +void *ip6_prefix2addr(ip6_addr_t prefix) { struct ip6addr_list_entry *new_address; uint64_t interface_id; @@ -311,8 +300,7 @@ ip6_prefix2addr (ip6_addr_t prefix) * @return 0 - passed pointer = NULL; * 1 - ok */ -int8_t -ip6addr_add (struct ip6addr_list_entry *new_address) +int8_t ip6addr_add(struct ip6addr_list_entry *new_address) { struct ip6addr_list_entry *solicited_node; @@ -356,8 +344,7 @@ ip6addr_add (struct ip6addr_list_entry *new_address) * * @param fd socket fd */ -static void -ipv6_init (int fd) +static void ipv6_init(int fd) { int i = 0; @@ -394,8 +381,7 @@ ipv6_init (int fd) * @param ip6_addr ip_1 * @param ip6_addr ip_2 */ -int8_t -ip6_cmp (ip6_addr_t *ip_1, ip6_addr_t *ip_2) +int8_t ip6_cmp(ip6_addr_t *ip_1, ip6_addr_t *ip_2) { return ((int8_t) !memcmp( &(ip_1->addr[0]), &(ip_2->addr[0]), IPV6_ADDR_LENGTH )); @@ -408,8 +394,7 @@ ip6_cmp (ip6_addr_t *ip_1, ip6_addr_t *ip_2) * @param *ip - pointer to IPv6 address * @return true or false */ -int -ip6_is_multicast (ip6_addr_t * ip) +int ip6_is_multicast(ip6_addr_t * ip) { return ip->addr[0] == 0xFF; } @@ -422,8 +407,7 @@ ip6_is_multicast (ip6_addr_t * ip) * @param *mc_mac pointer to an array with 6 bytes (for the MAC address) * @return pointer to Multicast MAC address */ -static uint8_t * -ip6_to_multicast_mac (ip6_addr_t * ip, uint8_t *mc_mac) +static uint8_t *ip6_to_multicast_mac(ip6_addr_t * ip, uint8_t *mc_mac) { mc_mac[0] = 0x33; mc_mac[1] = 0x33; @@ -443,8 +427,8 @@ ip6_to_multicast_mac (ip6_addr_t * ip, uint8_t *mc_mac) * starting from *packet * @return checksum */ -static unsigned short -ip6_checksum (struct ip6hdr *ip6h, unsigned short *packet, int words) +static unsigned short ip6_checksum(struct ip6hdr *ip6h, unsigned short *packet, + int words) { int i=0; unsigned long checksum; @@ -484,8 +468,7 @@ ip6_checksum (struct ip6hdr *ip6h, unsigned short *packet, int words) * @see receive_ether * @see ip6hdr */ -int -send_ipv6 (int fd, void* buffer, int len) +int send_ipv6(int fd, void* buffer, int len) { struct neighbor *n; struct ip6hdr *ip6h; @@ -570,8 +553,7 @@ send_ipv6 (int fd, void* buffer, int len) return send_ether (fd, n->eth_frame, len + sizeof(struct ethhdr)); } -static int -check_colons(const char *str) +static int check_colons(const char *str) { char *pch, *prv; int col = 0; @@ -593,7 +575,7 @@ check_colons(const char *str) dprintf("The number of col : %d \n",col); dprintf("The number of dcol : %d \n",dcol); - if((dcol > 1) || /* Cannot have 2 "::" */ + if((dcol > 1) || /* Cannot have 2 "::" */ ((dcol == 1) && (col > 5)) || /* Too many ':'s */ ((dcol == 0) && (col != 7)) ) { /* Too few ':'s */ dprintf(" exiting for check_colons \n"); @@ -603,8 +585,7 @@ check_colons(const char *str) return (col+dcol); } -static int -ipv6str_to_bytes(const char *str, char *ip) +static int ipv6str_to_bytes(const char *str, char *ip) { char block[5]; int res; diff --git a/clients/net-snk/app/netlib/tcp.c b/clients/net-snk/app/netlib/tcp.c index 5511aa0..faa0b83 100644 --- a/clients/net-snk/app/netlib/tcp.c +++ b/clients/net-snk/app/netlib/tcp.c @@ -10,16 +10,14 @@ * IBM Corporation - initial implementation *****************************************************************************/ -/*>>>>>>>>>>>>>>>>>>>>>>> DEFINITIONS & DECLARATIONS <<<<<<<<<<<<<<<<<<<<*/ +/************************ DEFINITIONS & DECLARATIONS *********************/ #include <tcp.h> #include <sys/socket.h> +/****************************** LOCAL VARIABLES **************************/ -/*>>>>>>>>>>>>>>>>>>>>>>>>>>>>> LOCAL VARIABLES <<<<<<<<<<<<<<<<<<<<<<<<<*/ - -/*>>>>>>>>>>>>>>>>>>>>>>>>>>>>> IMPLEMENTATION <<<<<<<<<<<<<<<<<<<<<<<<<<*/ - +/****************************** IMPLEMENTATION ***************************/ /** * TCP: Handles TCP-packets according to Receive-handle diagram. @@ -29,13 +27,11 @@ * @return ZERO - packet handled successfully; * NON ZERO - packet was not handled (e.g. bad format) */ -int8_t -handle_tcp(uint8_t * tcp_packet, int32_t packetsize) +int8_t handle_tcp(uint8_t * tcp_packet, int32_t packetsize) { return -1; } - /** * NET: This function handles situation when "Destination unreachable" * ICMP-error occurs during sending TCP-packet. @@ -45,6 +41,6 @@ handle_tcp(uint8_t * tcp_packet, int32_t packetsize) * @param packetsize length of the packet * @see handle_icmp */ -void -handle_tcp_dun(uint8_t * tcp_packet, uint32_t packetsize, uint8_t err_code) { +void handle_tcp_dun(uint8_t * tcp_packet, uint32_t packetsize, uint8_t err_code) +{ } diff --git a/clients/net-snk/app/netlib/tftp.c b/clients/net-snk/app/netlib/tftp.c index 0dfd23f..c1197cf 100644 --- a/clients/net-snk/app/netlib/tftp.c +++ b/clients/net-snk/app/netlib/tftp.c @@ -50,13 +50,13 @@ static unsigned short block = 0; static unsigned short blocksize; static char blocksize_str[6]; /* Blocksize string for read request */ static int received_len = 0; -static int retries = 0; +static unsigned int retries = 0; static int huge_load; static int len; static int tftp_finished = 0; static int lost_packets = 0; -static int tftp_errno = 0; -static int ip_version = 0; +static int tftp_errno = 0; +static int ip_version = 0; static short port_number = -1; static tftp_err_t *tftp_err; static filename_ip_t *fn_ip; @@ -69,8 +69,7 @@ static filename_ip_t *fn_ip; */ #ifdef __DEBUG__ -static void -dump_package(unsigned char *buffer, unsigned int len) +static void dump_package(unsigned char *buffer, unsigned int len) { int i; @@ -89,8 +88,7 @@ dump_package(unsigned char *buffer, unsigned int len) * * @fd: Socket Descriptor */ -static void -send_rrq(int fd) +static void send_rrq(int fd) { int ip_len = 0; int ip6_payload_len = 0; @@ -121,7 +119,7 @@ send_rrq(int fd) + strlen("blksize") + strlen(blocksize_str) + 2; ip_len = sizeof(struct ip6hdr) + ip6_payload_len; fill_ip6hdr ((uint8_t *) ip6, ip6_payload_len, IPTYPE_UDP, get_ipv6_address(), - &(fn_ip->server_ip6)); + &(fn_ip->server_ip6)); } udp_len = htons(sizeof(struct udphdr) @@ -158,8 +156,7 @@ send_rrq(int fd) * @blckno: block number * @dport: UDP destination port */ -static void -send_ack(int fd, int blckno, unsigned short dport) +static void send_ack(int fd, int blckno, unsigned short dport) { int ip_len = 0; int ip6_payload_len = 0; @@ -209,8 +206,7 @@ send_ack(int fd, int blckno, unsigned short dport) * @error_code: Used sub code for error packet * @dport: UDP destination port */ -static void -send_error(int fd, int error_code, unsigned short dport) +static void send_error(int fd, int error_code, unsigned short dport) { int ip_len = 0; int ip6_payload_len = 0; @@ -254,8 +250,7 @@ send_error(int fd, int error_code, unsigned short dport) return; } -static void -print_progress(int urgent, int received_bytes) +static void print_progress(int urgent, int received_bytes) { static unsigned int i = 1; static int first = -1; @@ -263,7 +258,7 @@ print_progress(int urgent, int received_bytes) char buffer[100]; char *ptr; - // 1MB steps or 0x400 times or urgent + // 1MB steps or 0x400 times or urgent if(((received_bytes - last_bytes) >> 20) > 0 || (i & 0x3FF) == 0 || urgent) { if(!first) { @@ -293,8 +288,7 @@ print_progress(int urgent, int received_bytes) * @param len the length of the network packet * @return the blocksize the server supports or 0 for error */ -static int -get_blksize(unsigned char *buffer, unsigned int len) +static int get_blksize(unsigned char *buffer, unsigned int len) { unsigned char *orig = buffer; /* skip all headers until tftp has been reached */ @@ -323,7 +317,7 @@ get_blksize(unsigned char *buffer, unsigned int len) } /** - * Handle incoming tftp packets after read request was sent + * Handle incoming tftp packets after read request was sent * * this function also prints out some status characters * \|-/ for each packet received @@ -332,13 +326,12 @@ get_blksize(unsigned char *buffer, unsigned int len) * #+* for different unexpected TFTP packets (not very good) * * @param fd socket descriptor - * @param packet points to the UDP header of the packet + * @param packet points to the UDP header of the packet * @param len the length of the network packet * @return ZERO if packet was handled successfully - * ERRORCODE if error occurred + * ERRORCODE if error occurred */ -int32_t -handle_tftp(int fd, uint8_t *pkt, int32_t packetsize) +int32_t handle_tftp(int fd, uint8_t *pkt, int32_t packetsize) { struct udphdr *udph; struct tftphdr *tftp; @@ -395,7 +388,7 @@ handle_tftp(int fd, uint8_t *pkt, int32_t packetsize) case ENOUSER: tftp_errno = -7; // ERROR: no such user break; - default: + default: tftp_errno = -1; // ERROR: unknown error } goto error; @@ -487,8 +480,7 @@ error: * * @param err_code Error Code (e.g. "Host unreachable") */ -void -handle_tftp_dun(uint8_t err_code) +void handle_tftp_dun(uint8_t err_code) { tftp_errno = - err_code - 10; tftp_finished = 1; @@ -508,10 +500,9 @@ handle_tftp_dun(uint8_t err_code) * @return ZERO - error condition occurs * NON ZERO - size of received file */ -int -tftp(filename_ip_t * _fn_ip, unsigned char *_buffer, int _len, - unsigned int _retries, tftp_err_t * _tftp_err, - int32_t _mode, int32_t _blocksize, int _ip_version) +int tftp(filename_ip_t * _fn_ip, unsigned char *_buffer, int _len, + unsigned int _retries, tftp_err_t * _tftp_err, + int32_t _mode, int32_t _blocksize, int _ip_version) { retries = _retries; fn_ip = _fn_ip; @@ -590,6 +581,6 @@ tftp(filename_ip_t * _fn_ip, unsigned char *_buffer, int _len, printf("\n"); if (lost_packets) printf("Lost ACK packets: %d\n", lost_packets); - + return received_len; } diff --git a/clients/net-snk/app/netlib/udp.c b/clients/net-snk/app/netlib/udp.c index db29bc9..f5c6be9 100644 --- a/clients/net-snk/app/netlib/udp.c +++ b/clients/net-snk/app/netlib/udp.c @@ -10,7 +10,7 @@ * IBM Corporation - initial implementation *****************************************************************************/ -/*>>>>>>>>>>>>>>>>>>>>>>> DEFINITIONS & DECLARATIONS <<<<<<<<<<<<<<<<<<<<*/ +/************************ DEFINITIONS & DECLARATIONS *********************/ #include <udp.h> #include <sys/socket.h> @@ -25,7 +25,7 @@ -/*>>>>>>>>>>>>>>>>>>>>>>>>>>>>> LOCAL VARIABLES <<<<<<<<<<<<<<<<<<<<<<<<<*/ +/****************************** LOCAL VARIABLES **************************/ #ifdef USE_MTFTP @@ -33,17 +33,19 @@ uint16_t net_tftp_uport; uint16_t net_mtftp_uport; -void net_set_tftp_port(uint16_t tftp_port) { +void net_set_tftp_port(uint16_t tftp_port) +{ net_tftp_uport = tftp_port; } -void net_set_mtftp_port(uint16_t tftp_port) { +void net_set_mtftp_port(uint16_t tftp_port) +{ net_mtftp_uport = tftp_port; } #endif -/*>>>>>>>>>>>>>>>>>>>>>>>>>>>>> IMPLEMENTATION <<<<<<<<<<<<<<<<<<<<<<<<<<*/ +/****************************** IMPLEMENTATION ***************************/ /** @@ -56,8 +58,8 @@ void net_set_mtftp_port(uint16_t tftp_port) { * @see receive_ether * @see udphdr */ -int8_t -handle_udp(int fd, uint8_t * udp_packet, int32_t packetsize) { +int8_t handle_udp(int fd, uint8_t * udp_packet, int32_t packetsize) +{ struct udphdr * udph = (struct udphdr *) udp_packet; if (packetsize < sizeof(struct udphdr)) @@ -108,8 +110,8 @@ handle_udp(int fd, uint8_t * udp_packet, int32_t packetsize) { * @param packetsize length of the packet * @see handle_icmp */ -void -handle_udp_dun(uint8_t * udp_packet, uint32_t packetsize, uint8_t err_code) { +void handle_udp_dun(uint8_t * udp_packet, uint32_t packetsize, uint8_t err_code) +{ struct udphdr * udph = (struct udphdr *) udp_packet; if (packetsize < sizeof(struct udphdr)) @@ -139,9 +141,9 @@ handle_udp_dun(uint8_t * udp_packet, uint32_t packetsize, uint8_t err_code) { * @see fill_dnshdr * @see fill_btphdr */ -void -fill_udphdr(uint8_t * packet, uint16_t packetsize, - uint16_t src_port, uint16_t dest_port) { +void fill_udphdr(uint8_t * packet, uint16_t packetsize, + uint16_t src_port, uint16_t dest_port) +{ struct udphdr * udph = (struct udphdr *) packet; udph -> uh_sport = htons(src_port); |