Changeset ffaba00 in mainline
- Timestamp:
- 2011-01-17T16:04:26Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- a2d8d59
- Parents:
- f1938c6
- Location:
- uspace
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/net/include/icmp_header.h
rf1938c6 rffaba00 45 45 46 46 /** ICMP header size in bytes. */ 47 #define ICMP_HEADER_SIZE sizeof(icmp_header_t) 48 49 /** Type definition of the echo specific data. 50 * @see icmp_echo 51 */ 52 typedef struct icmp_echo icmp_echo_t; 47 #define ICMP_HEADER_SIZE sizeof(icmp_header_t) 53 48 54 49 /** Echo specific data. */ 55 struct icmp_echo {50 typedef struct icmp_echo { 56 51 /** Message idintifier. */ 57 52 icmp_param_t identifier; 58 53 /** Message sequence number. */ 59 54 icmp_param_t sequence_number; 60 } __attribute__ ((packed)); 61 62 /** Type definition of the internet control message header. 63 * @see icmp_header 64 */ 65 typedef struct icmp_header icmp_header_t; 55 } __attribute__((packed)) icmp_echo_t; 66 56 67 57 /** Internet control message header. */ 68 struct icmp_header {58 typedef struct icmp_header { 69 59 /** The type of the message. */ 70 60 uint8_t type; … … 83 73 */ 84 74 uint16_t checksum; 85 75 86 76 /** Message specific data. */ 87 77 union { 88 78 /** Echo specific data. */ 89 icmp_echo_t 79 icmp_echo_t echo; 90 80 /** Proposed gateway value. */ 91 81 in_addr_t gateway; … … 107 97 } param; 108 98 } un; 109 } __attribute__ ((packed));99 } __attribute__((packed)) icmp_header_t; 110 100 111 101 #endif -
uspace/srv/net/tl/icmp/icmp.c
rf1938c6 rffaba00 123 123 static bool error_reporting = true; 124 124 static bool echo_replying = true; 125 static packet_dimension_t icmp_dimension; 125 126 126 127 /** ICMP client identification counter */ 127 128 static atomic_t icmp_client; 128 static packet_dimension_t icmp_dimension; 129 130 /** ICMP identifier and sequence number */ 129 130 /** ICMP identifier and sequence number (client-specific) */ 131 131 static fibril_local icmp_param_t icmp_id; 132 132 static fibril_local icmp_param_t icmp_seq; … … 142 142 * are 16-bit values. 143 143 */ 144 hash_index_t index = ( key[0] & 0xffff) << 16| (key[1] & 0xffff);145 return index % REPLY_BUCKETS;144 hash_index_t index = ((key[0] & 0xffff) << 16) | (key[1] & 0xffff); 145 return (index % REPLY_BUCKETS); 146 146 } 147 147 … … 209 209 header->type = type; 210 210 header->code = code; 211 212 /* 213 * The checksum needs to be calculated 214 * with a virtual checksum field set to 215 * zero. 216 */ 211 217 header->checksum = 0; 212 218 header->checksum = ICMP_CHECKSUM(header, … … 281 287 * zero. 282 288 * @return ENOMEM if there is not enough memory left. 283 * @return EPARTY if there was an internal error.284 289 * 285 290 */ … … 328 333 } 329 334 330 bzero(header, sizeof( *header));335 bzero(header, sizeof(icmp_header_t)); 331 336 header->un.echo.identifier = id; 332 337 header->un.echo.sequence_number = sequence; … … 439 444 unsigned long key[REPLY_KEYS] = 440 445 {header->un.echo.identifier, header->un.echo.sequence_number}; 446 447 /* The packet is no longer needed */ 441 448 icmp_release(packet); 442 449 … … 698 705 /** Per-connection initialization 699 706 * 707 * Initialize client-specific global variables. 708 * 700 709 */ 701 710 void tl_connection(void)
Note:
See TracChangeset
for help on using the changeset viewer.