Changeset 25171e5 in mainline
- Timestamp:
- 2010-10-17T21:52:12Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 84c20da
- Parents:
- 3a609e0
- Location:
- uspace/lib
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/c/include/net/icmp_codes.h
r3a609e0 r25171e5 42 42 #define LIBC_ICMP_CODES_H_ 43 43 44 #include <sys/types.h> 45 44 46 /** ICMP type type definition. */ 45 47 typedef uint8_t icmp_type_t; -
uspace/lib/net/include/icmp_client.h
r3a609e0 r25171e5 27 27 */ 28 28 29 /** @addtogroup icmp30 * 29 /** @addtogroup libnet 30 * @{ 31 31 */ 32 32 33 33 /** @file 34 * 34 * ICMP client interface. 35 35 */ 36 36 37 #ifndef __NET_ICMP_CLIENT_H__38 #define __NET_ICMP_CLIENT_H__37 #ifndef LIBNET_ICMP_CLIENT_H_ 38 #define LIBNET_ICMP_CLIENT_H_ 39 39 40 40 #include <net/icmp_codes.h> 41 41 #include <net/packet.h> 42 42 43 /** Processes the received packet prefixed with an ICMP header. 44 * @param[in] packet The received packet. 45 * @param[out] type The ICMP header type. 46 * @param[out] code The ICMP header code. 47 * @param[out] pointer The ICMP header pointer. 48 * @param[out] mtu The ICMP header MTU. 49 * @returns The ICMP header length. 50 * @returns Zero (0) if the packet contains no data. 51 */ 52 extern int icmp_client_process_packet(packet_t packet, icmp_type_t * type, icmp_code_t * code, icmp_param_t * pointer, icmp_param_t * mtu); 53 54 /** Returns the ICMP header length. 55 * @param[in] packet The packet. 56 * @returns The ICMP header length in bytes. 57 */ 58 extern size_t icmp_client_header_length(packet_t packet); 43 extern int icmp_client_process_packet(packet_t, icmp_type_t *, icmp_code_t *, 44 icmp_param_t *, icmp_param_t *); 45 extern size_t icmp_client_header_length(packet_t); 59 46 60 47 #endif -
uspace/lib/net/tl/icmp_client.c
r3a609e0 r25171e5 27 27 */ 28 28 29 /** @addtogroup icmp30 * 29 /** @addtogroup libnet 30 * @{ 31 31 */ 32 32 33 33 /** @file 34 * 35 * 34 * ICMP client interface implementation. 35 * @see icmp_client.h 36 36 */ 37 37 38 #include <icmp_client.h> 39 #include <icmp_header.h> 40 #include <packet_client.h> 41 38 42 #ifdef CONFIG_DEBUG 39 43 #include <stdio.h> 40 44 #endif 41 45 … … 44 48 45 49 #include <net/icmp_codes.h> 46 #include <icmp_client.h>47 50 #include <net/packet.h> 48 #include <packet_client.h>49 #include <icmp_header.h>50 51 51 int icmp_client_process_packet(packet_t packet, icmp_type_t * type, icmp_code_t * code, icmp_param_t * pointer, icmp_param_t * mtu){ 52 /** Processes the received packet prefixed with an ICMP header. 53 * 54 * @param[in] packet The received packet. 55 * @param[out] type The ICMP header type. 56 * @param[out] code The ICMP header code. 57 * @param[out] pointer The ICMP header pointer. 58 * @param[out] mtu The ICMP header MTU. 59 * @returns The ICMP header length. 60 * @returns Zero if the packet contains no data. 61 */ 62 int 63 icmp_client_process_packet(packet_t packet, icmp_type_t *type, 64 icmp_code_t *code, icmp_param_t *pointer, icmp_param_t *mtu) 65 { 52 66 icmp_header_ref header; 53 67 54 68 header = (icmp_header_ref) packet_get_data(packet); 55 if ((! header)56 || (packet_get_data_length(packet) < sizeof(icmp_header_t))){69 if (!header || 70 (packet_get_data_length(packet) < sizeof(icmp_header_t))) { 57 71 return 0; 58 72 } 59 if(type){ 73 74 if (type) 60 75 *type = header->type; 61 } 62 if(code){ 76 if (code) 63 77 *code = header->code; 64 } 65 if(pointer){ 78 if (pointer) 66 79 *pointer = header->un.param.pointer; 67 } 68 if(mtu){ 80 if (mtu) 69 81 *mtu = header->un.frag.mtu; 70 } 82 71 83 // remove debug dump 72 84 #ifdef CONFIG_DEBUG 73 printf("ICMP error %d (%d) in packet %d\n", header->type, header->code, packet_get_id(packet)); 85 printf("ICMP error %d (%d) in packet %d\n", header->type, header->code, 86 packet_get_id(packet)); 74 87 #endif 75 88 return sizeof(icmp_header_t); 76 89 } 77 90 78 size_t icmp_client_header_length(packet_t packet){ 79 if(packet_get_data_length(packet) < sizeof(icmp_header_t)){ 91 /** Returns the ICMP header length. 92 * 93 * @param[in] packet The packet. 94 * @returns The ICMP header length in bytes. 95 */ 96 size_t icmp_client_header_length(packet_t packet) 97 { 98 if (packet_get_data_length(packet) < sizeof(icmp_header_t)) 80 99 return 0; 81 } 100 82 101 return sizeof(icmp_header_t); 83 102 }
Note:
See TracChangeset
for help on using the changeset viewer.