input.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560
  1. /*
  2. * net/dccp/input.c
  3. *
  4. * An implementation of the DCCP protocol
  5. * Arnaldo Carvalho de Melo <acme@conectiva.com.br>
  6. *
  7. * This program is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU General Public License
  9. * as published by the Free Software Foundation; either version
  10. * 2 of the License, or (at your option) any later version.
  11. */
  12. #include <linux/config.h>
  13. #include <linux/dccp.h>
  14. #include <linux/skbuff.h>
  15. #include <net/sock.h>
  16. #include "ccid.h"
  17. #include "dccp.h"
  18. static void dccp_fin(struct sock *sk, struct sk_buff *skb)
  19. {
  20. sk->sk_shutdown |= RCV_SHUTDOWN;
  21. sock_set_flag(sk, SOCK_DONE);
  22. __skb_pull(skb, dccp_hdr(skb)->dccph_doff * 4);
  23. __skb_queue_tail(&sk->sk_receive_queue, skb);
  24. skb_set_owner_r(skb, sk);
  25. sk->sk_data_ready(sk, 0);
  26. }
  27. static void dccp_rcv_close(struct sock *sk, struct sk_buff *skb)
  28. {
  29. switch (sk->sk_state) {
  30. case DCCP_PARTOPEN:
  31. case DCCP_OPEN:
  32. dccp_v4_send_reset(sk, DCCP_RESET_CODE_CLOSED);
  33. dccp_fin(sk, skb);
  34. dccp_set_state(sk, DCCP_CLOSED);
  35. break;
  36. }
  37. }
  38. static void dccp_rcv_closereq(struct sock *sk, struct sk_buff *skb)
  39. {
  40. /*
  41. * Step 7: Check for unexpected packet types
  42. * If (S.is_server and P.type == CloseReq)
  43. * Send Sync packet acknowledging P.seqno
  44. * Drop packet and return
  45. */
  46. if (dccp_sk(sk)->dccps_role != DCCP_ROLE_CLIENT) {
  47. dccp_send_sync(sk, DCCP_SKB_CB(skb)->dccpd_seq);
  48. return;
  49. }
  50. switch (sk->sk_state) {
  51. case DCCP_PARTOPEN:
  52. case DCCP_OPEN:
  53. dccp_set_state(sk, DCCP_CLOSING);
  54. dccp_send_close(sk);
  55. break;
  56. }
  57. }
  58. static inline void dccp_event_ack_recv(struct sock *sk, struct sk_buff *skb)
  59. {
  60. struct dccp_sock *dp = dccp_sk(sk);
  61. if (dp->dccps_options.dccpo_send_ack_vector)
  62. dccp_ackpkts_check_rcv_ackno(dp->dccps_hc_rx_ackpkts, sk,
  63. DCCP_SKB_CB(skb)->dccpd_ack_seq);
  64. }
  65. static int dccp_check_seqno(struct sock *sk, struct sk_buff *skb)
  66. {
  67. const struct dccp_hdr *dh = dccp_hdr(skb);
  68. struct dccp_sock *dp = dccp_sk(sk);
  69. u64 lswl = dp->dccps_swl;
  70. u64 lawl = dp->dccps_awl;
  71. /*
  72. * Step 5: Prepare sequence numbers for Sync
  73. * If P.type == Sync or P.type == SyncAck,
  74. * If S.AWL <= P.ackno <= S.AWH and P.seqno >= S.SWL,
  75. * / * P is valid, so update sequence number variables
  76. * accordingly. After this update, P will pass the tests
  77. * in Step 6. A SyncAck is generated if necessary in
  78. * Step 15 * /
  79. * Update S.GSR, S.SWL, S.SWH
  80. * Otherwise,
  81. * Drop packet and return
  82. */
  83. if (dh->dccph_type == DCCP_PKT_SYNC ||
  84. dh->dccph_type == DCCP_PKT_SYNCACK) {
  85. if (between48(DCCP_SKB_CB(skb)->dccpd_ack_seq,
  86. dp->dccps_awl, dp->dccps_awh) &&
  87. !before48(DCCP_SKB_CB(skb)->dccpd_seq, dp->dccps_swl))
  88. dccp_update_gsr(sk, DCCP_SKB_CB(skb)->dccpd_seq);
  89. else
  90. return -1;
  91. /*
  92. * Step 6: Check sequence numbers
  93. * Let LSWL = S.SWL and LAWL = S.AWL
  94. * If P.type == CloseReq or P.type == Close or P.type == Reset,
  95. * LSWL := S.GSR + 1, LAWL := S.GAR
  96. * If LSWL <= P.seqno <= S.SWH
  97. * and (P.ackno does not exist or LAWL <= P.ackno <= S.AWH),
  98. * Update S.GSR, S.SWL, S.SWH
  99. * If P.type != Sync,
  100. * Update S.GAR
  101. * Otherwise,
  102. * Send Sync packet acknowledging P.seqno
  103. * Drop packet and return
  104. */
  105. } else if (dh->dccph_type == DCCP_PKT_CLOSEREQ ||
  106. dh->dccph_type == DCCP_PKT_CLOSE ||
  107. dh->dccph_type == DCCP_PKT_RESET) {
  108. lswl = dp->dccps_gsr;
  109. dccp_inc_seqno(&lswl);
  110. lawl = dp->dccps_gar;
  111. }
  112. if (between48(DCCP_SKB_CB(skb)->dccpd_seq, lswl, dp->dccps_swh) &&
  113. (DCCP_SKB_CB(skb)->dccpd_ack_seq == DCCP_PKT_WITHOUT_ACK_SEQ ||
  114. between48(DCCP_SKB_CB(skb)->dccpd_ack_seq,
  115. lawl, dp->dccps_awh))) {
  116. dccp_update_gsr(sk, DCCP_SKB_CB(skb)->dccpd_seq);
  117. if (dh->dccph_type != DCCP_PKT_SYNC &&
  118. (DCCP_SKB_CB(skb)->dccpd_ack_seq !=
  119. DCCP_PKT_WITHOUT_ACK_SEQ))
  120. dp->dccps_gar = DCCP_SKB_CB(skb)->dccpd_ack_seq;
  121. } else {
  122. dccp_pr_debug("Step 6 failed, sending SYNC...\n");
  123. dccp_send_sync(sk, DCCP_SKB_CB(skb)->dccpd_seq);
  124. return -1;
  125. }
  126. return 0;
  127. }
  128. int dccp_rcv_established(struct sock *sk, struct sk_buff *skb,
  129. const struct dccp_hdr *dh, const unsigned len)
  130. {
  131. struct dccp_sock *dp = dccp_sk(sk);
  132. if (dccp_check_seqno(sk, skb))
  133. goto discard;
  134. if (dccp_parse_options(sk, skb))
  135. goto discard;
  136. if (DCCP_SKB_CB(skb)->dccpd_ack_seq != DCCP_PKT_WITHOUT_ACK_SEQ)
  137. dccp_event_ack_recv(sk, skb);
  138. /*
  139. * FIXME: check ECN to see if we should use
  140. * DCCP_ACKPKTS_STATE_ECN_MARKED
  141. */
  142. if (dp->dccps_options.dccpo_send_ack_vector) {
  143. struct dccp_ackpkts *ap = dp->dccps_hc_rx_ackpkts;
  144. if (dccp_ackpkts_add(dp->dccps_hc_rx_ackpkts,
  145. DCCP_SKB_CB(skb)->dccpd_seq,
  146. DCCP_ACKPKTS_STATE_RECEIVED)) {
  147. LIMIT_NETDEBUG(KERN_INFO "DCCP: acknowledgeable "
  148. "packets buffer full!\n");
  149. ap->dccpap_ack_seqno = DCCP_MAX_SEQNO + 1;
  150. inet_csk_schedule_ack(sk);
  151. inet_csk_reset_xmit_timer(sk, ICSK_TIME_DACK,
  152. TCP_DELACK_MIN,
  153. DCCP_RTO_MAX);
  154. goto discard;
  155. }
  156. /*
  157. * FIXME: this activation is probably wrong, have to study more
  158. * TCP delack machinery and how it fits into DCCP draft, but
  159. * for now it kinda "works" 8)
  160. */
  161. if (!inet_csk_ack_scheduled(sk)) {
  162. inet_csk_schedule_ack(sk);
  163. inet_csk_reset_xmit_timer(sk, ICSK_TIME_DACK, 5 * HZ,
  164. DCCP_RTO_MAX);
  165. }
  166. }
  167. ccid_hc_rx_packet_recv(dp->dccps_hc_rx_ccid, sk, skb);
  168. ccid_hc_tx_packet_recv(dp->dccps_hc_tx_ccid, sk, skb);
  169. switch (dccp_hdr(skb)->dccph_type) {
  170. case DCCP_PKT_DATAACK:
  171. case DCCP_PKT_DATA:
  172. /*
  173. * FIXME: check if sk_receive_queue is full, schedule DATA_DROPPED
  174. * option if it is.
  175. */
  176. __skb_pull(skb, dh->dccph_doff * 4);
  177. __skb_queue_tail(&sk->sk_receive_queue, skb);
  178. skb_set_owner_r(skb, sk);
  179. sk->sk_data_ready(sk, 0);
  180. return 0;
  181. case DCCP_PKT_ACK:
  182. goto discard;
  183. case DCCP_PKT_RESET:
  184. /*
  185. * Step 9: Process Reset
  186. * If P.type == Reset,
  187. * Tear down connection
  188. * S.state := TIMEWAIT
  189. * Set TIMEWAIT timer
  190. * Drop packet and return
  191. */
  192. dccp_fin(sk, skb);
  193. dccp_time_wait(sk, DCCP_TIME_WAIT, 0);
  194. return 0;
  195. case DCCP_PKT_CLOSEREQ:
  196. dccp_rcv_closereq(sk, skb);
  197. goto discard;
  198. case DCCP_PKT_CLOSE:
  199. dccp_rcv_close(sk, skb);
  200. return 0;
  201. case DCCP_PKT_REQUEST:
  202. /* Step 7
  203. * or (S.is_server and P.type == Response)
  204. * or (S.is_client and P.type == Request)
  205. * or (S.state >= OPEN and P.type == Request
  206. * and P.seqno >= S.OSR)
  207. * or (S.state >= OPEN and P.type == Response
  208. * and P.seqno >= S.OSR)
  209. * or (S.state == RESPOND and P.type == Data),
  210. * Send Sync packet acknowledging P.seqno
  211. * Drop packet and return
  212. */
  213. if (dp->dccps_role != DCCP_ROLE_LISTEN)
  214. goto send_sync;
  215. goto check_seq;
  216. case DCCP_PKT_RESPONSE:
  217. if (dp->dccps_role != DCCP_ROLE_CLIENT)
  218. goto send_sync;
  219. check_seq:
  220. if (!before48(DCCP_SKB_CB(skb)->dccpd_seq, dp->dccps_osr)) {
  221. send_sync:
  222. dccp_send_sync(sk, DCCP_SKB_CB(skb)->dccpd_seq);
  223. }
  224. break;
  225. }
  226. DCCP_INC_STATS_BH(DCCP_MIB_INERRS);
  227. discard:
  228. __kfree_skb(skb);
  229. return 0;
  230. }
  231. static int dccp_rcv_request_sent_state_process(struct sock *sk,
  232. struct sk_buff *skb,
  233. const struct dccp_hdr *dh,
  234. const unsigned len)
  235. {
  236. /*
  237. * Step 4: Prepare sequence numbers in REQUEST
  238. * If S.state == REQUEST,
  239. * If (P.type == Response or P.type == Reset)
  240. * and S.AWL <= P.ackno <= S.AWH,
  241. * / * Set sequence number variables corresponding to the
  242. * other endpoint, so P will pass the tests in Step 6 * /
  243. * Set S.GSR, S.ISR, S.SWL, S.SWH
  244. * / * Response processing continues in Step 10; Reset
  245. * processing continues in Step 9 * /
  246. */
  247. if (dh->dccph_type == DCCP_PKT_RESPONSE) {
  248. const struct inet_connection_sock *icsk = inet_csk(sk);
  249. struct dccp_sock *dp = dccp_sk(sk);
  250. /* Stop the REQUEST timer */
  251. inet_csk_clear_xmit_timer(sk, ICSK_TIME_RETRANS);
  252. BUG_TRAP(sk->sk_send_head != NULL);
  253. __kfree_skb(sk->sk_send_head);
  254. sk->sk_send_head = NULL;
  255. if (!between48(DCCP_SKB_CB(skb)->dccpd_ack_seq,
  256. dp->dccps_awl, dp->dccps_awh)) {
  257. dccp_pr_debug("invalid ackno: S.AWL=%llu, "
  258. "P.ackno=%llu, S.AWH=%llu \n",
  259. (unsigned long long)dp->dccps_awl,
  260. (unsigned long long)DCCP_SKB_CB(skb)->dccpd_ack_seq,
  261. (unsigned long long)dp->dccps_awh);
  262. goto out_invalid_packet;
  263. }
  264. dp->dccps_isr = DCCP_SKB_CB(skb)->dccpd_seq;
  265. dccp_update_gsr(sk, DCCP_SKB_CB(skb)->dccpd_seq);
  266. if (ccid_hc_rx_init(dp->dccps_hc_rx_ccid, sk) != 0 ||
  267. ccid_hc_tx_init(dp->dccps_hc_tx_ccid, sk) != 0) {
  268. ccid_hc_rx_exit(dp->dccps_hc_rx_ccid, sk);
  269. ccid_hc_tx_exit(dp->dccps_hc_tx_ccid, sk);
  270. /* FIXME: send appropriate RESET code */
  271. goto out_invalid_packet;
  272. }
  273. dccp_sync_mss(sk, dp->dccps_pmtu_cookie);
  274. /*
  275. * Step 10: Process REQUEST state (second part)
  276. * If S.state == REQUEST,
  277. * / * If we get here, P is a valid Response from the
  278. * server (see Step 4), and we should move to
  279. * PARTOPEN state. PARTOPEN means send an Ack,
  280. * don't send Data packets, retransmit Acks
  281. * periodically, and always include any Init Cookie
  282. * from the Response * /
  283. * S.state := PARTOPEN
  284. * Set PARTOPEN timer
  285. * Continue with S.state == PARTOPEN
  286. * / * Step 12 will send the Ack completing the
  287. * three-way handshake * /
  288. */
  289. dccp_set_state(sk, DCCP_PARTOPEN);
  290. /* Make sure socket is routed, for correct metrics. */
  291. inet_sk_rebuild_header(sk);
  292. if (!sock_flag(sk, SOCK_DEAD)) {
  293. sk->sk_state_change(sk);
  294. sk_wake_async(sk, 0, POLL_OUT);
  295. }
  296. if (sk->sk_write_pending || icsk->icsk_ack.pingpong ||
  297. icsk->icsk_accept_queue.rskq_defer_accept) {
  298. /* Save one ACK. Data will be ready after
  299. * several ticks, if write_pending is set.
  300. *
  301. * It may be deleted, but with this feature tcpdumps
  302. * look so _wonderfully_ clever, that I was not able
  303. * to stand against the temptation 8) --ANK
  304. */
  305. /*
  306. * OK, in DCCP we can as well do a similar trick, its
  307. * even in the draft, but there is no need for us to
  308. * schedule an ack here, as dccp_sendmsg does this for
  309. * us, also stated in the draft. -acme
  310. */
  311. __kfree_skb(skb);
  312. return 0;
  313. }
  314. dccp_send_ack(sk);
  315. return -1;
  316. }
  317. out_invalid_packet:
  318. return 1; /* dccp_v4_do_rcv will send a reset, but...
  319. FIXME: the reset code should be
  320. DCCP_RESET_CODE_PACKET_ERROR */
  321. }
  322. static int dccp_rcv_respond_partopen_state_process(struct sock *sk,
  323. struct sk_buff *skb,
  324. const struct dccp_hdr *dh,
  325. const unsigned len)
  326. {
  327. int queued = 0;
  328. switch (dh->dccph_type) {
  329. case DCCP_PKT_RESET:
  330. inet_csk_clear_xmit_timer(sk, ICSK_TIME_DACK);
  331. break;
  332. case DCCP_PKT_DATAACK:
  333. case DCCP_PKT_ACK:
  334. /*
  335. * FIXME: we should be reseting the PARTOPEN (DELACK) timer
  336. * here but only if we haven't used the DELACK timer for
  337. * something else, like sending a delayed ack for a TIMESTAMP
  338. * echo, etc, for now were not clearing it, sending an extra
  339. * ACK when there is nothing else to do in DELACK is not a big
  340. * deal after all.
  341. */
  342. /* Stop the PARTOPEN timer */
  343. if (sk->sk_state == DCCP_PARTOPEN)
  344. inet_csk_clear_xmit_timer(sk, ICSK_TIME_DACK);
  345. dccp_sk(sk)->dccps_osr = DCCP_SKB_CB(skb)->dccpd_seq;
  346. dccp_set_state(sk, DCCP_OPEN);
  347. if (dh->dccph_type == DCCP_PKT_DATAACK) {
  348. dccp_rcv_established(sk, skb, dh, len);
  349. queued = 1; /* packet was queued
  350. (by dccp_rcv_established) */
  351. }
  352. break;
  353. }
  354. return queued;
  355. }
  356. int dccp_rcv_state_process(struct sock *sk, struct sk_buff *skb,
  357. struct dccp_hdr *dh, unsigned len)
  358. {
  359. struct dccp_sock *dp = dccp_sk(sk);
  360. const int old_state = sk->sk_state;
  361. int queued = 0;
  362. /*
  363. * Step 3: Process LISTEN state
  364. * (Continuing from dccp_v4_do_rcv and dccp_v6_do_rcv)
  365. *
  366. * If S.state == LISTEN,
  367. * If P.type == Request or P contains a valid Init Cookie
  368. * option,
  369. * * Must scan the packet's options to check for an Init
  370. * Cookie. Only the Init Cookie is processed here,
  371. * however; other options are processed in Step 8. This
  372. * scan need only be performed if the endpoint uses Init
  373. * Cookies *
  374. * * Generate a new socket and switch to that socket *
  375. * Set S := new socket for this port pair
  376. * S.state = RESPOND
  377. * Choose S.ISS (initial seqno) or set from Init Cookie
  378. * Set S.ISR, S.GSR, S.SWL, S.SWH from packet or Init Cookie
  379. * Continue with S.state == RESPOND
  380. * * A Response packet will be generated in Step 11 *
  381. * Otherwise,
  382. * Generate Reset(No Connection) unless P.type == Reset
  383. * Drop packet and return
  384. *
  385. * NOTE: the check for the packet types is done in
  386. * dccp_rcv_state_process
  387. */
  388. if (sk->sk_state == DCCP_LISTEN) {
  389. if (dh->dccph_type == DCCP_PKT_REQUEST) {
  390. if (dccp_v4_conn_request(sk, skb) < 0)
  391. return 1;
  392. /* FIXME: do congestion control initialization */
  393. goto discard;
  394. }
  395. if (dh->dccph_type == DCCP_PKT_RESET)
  396. goto discard;
  397. /* Caller (dccp_v4_do_rcv) will send Reset(No Connection)*/
  398. return 1;
  399. }
  400. if (sk->sk_state != DCCP_REQUESTING) {
  401. if (dccp_check_seqno(sk, skb))
  402. goto discard;
  403. /*
  404. * Step 8: Process options and mark acknowledgeable
  405. */
  406. if (dccp_parse_options(sk, skb))
  407. goto discard;
  408. if (DCCP_SKB_CB(skb)->dccpd_ack_seq !=
  409. DCCP_PKT_WITHOUT_ACK_SEQ)
  410. dccp_event_ack_recv(sk, skb);
  411. ccid_hc_rx_packet_recv(dp->dccps_hc_rx_ccid, sk, skb);
  412. ccid_hc_tx_packet_recv(dp->dccps_hc_tx_ccid, sk, skb);
  413. /*
  414. * FIXME: check ECN to see if we should use
  415. * DCCP_ACKPKTS_STATE_ECN_MARKED
  416. */
  417. if (dp->dccps_options.dccpo_send_ack_vector) {
  418. if (dccp_ackpkts_add(dp->dccps_hc_rx_ackpkts,
  419. DCCP_SKB_CB(skb)->dccpd_seq,
  420. DCCP_ACKPKTS_STATE_RECEIVED))
  421. goto discard;
  422. /*
  423. * FIXME: this activation is probably wrong, have to
  424. * study more TCP delack machinery and how it fits into
  425. * DCCP draft, but for now it kinda "works" 8)
  426. */
  427. if ((dp->dccps_hc_rx_ackpkts->dccpap_ack_seqno ==
  428. DCCP_MAX_SEQNO + 1) &&
  429. !inet_csk_ack_scheduled(sk)) {
  430. inet_csk_schedule_ack(sk);
  431. inet_csk_reset_xmit_timer(sk, ICSK_TIME_DACK,
  432. TCP_DELACK_MIN,
  433. DCCP_RTO_MAX);
  434. }
  435. }
  436. }
  437. /*
  438. * Step 9: Process Reset
  439. * If P.type == Reset,
  440. * Tear down connection
  441. * S.state := TIMEWAIT
  442. * Set TIMEWAIT timer
  443. * Drop packet and return
  444. */
  445. if (dh->dccph_type == DCCP_PKT_RESET) {
  446. /*
  447. * Queue the equivalent of TCP fin so that dccp_recvmsg
  448. * exits the loop
  449. */
  450. dccp_fin(sk, skb);
  451. dccp_time_wait(sk, DCCP_TIME_WAIT, 0);
  452. return 0;
  453. /*
  454. * Step 7: Check for unexpected packet types
  455. * If (S.is_server and P.type == CloseReq)
  456. * or (S.is_server and P.type == Response)
  457. * or (S.is_client and P.type == Request)
  458. * or (S.state == RESPOND and P.type == Data),
  459. * Send Sync packet acknowledging P.seqno
  460. * Drop packet and return
  461. */
  462. } else if ((dp->dccps_role != DCCP_ROLE_CLIENT &&
  463. (dh->dccph_type == DCCP_PKT_RESPONSE ||
  464. dh->dccph_type == DCCP_PKT_CLOSEREQ)) ||
  465. (dp->dccps_role == DCCP_ROLE_CLIENT &&
  466. dh->dccph_type == DCCP_PKT_REQUEST) ||
  467. (sk->sk_state == DCCP_RESPOND &&
  468. dh->dccph_type == DCCP_PKT_DATA)) {
  469. dccp_send_sync(sk, DCCP_SKB_CB(skb)->dccpd_seq);
  470. goto discard;
  471. }
  472. switch (sk->sk_state) {
  473. case DCCP_CLOSED:
  474. return 1;
  475. case DCCP_REQUESTING:
  476. /* FIXME: do congestion control initialization */
  477. queued = dccp_rcv_request_sent_state_process(sk, skb, dh, len);
  478. if (queued >= 0)
  479. return queued;
  480. __kfree_skb(skb);
  481. return 0;
  482. case DCCP_RESPOND:
  483. case DCCP_PARTOPEN:
  484. queued = dccp_rcv_respond_partopen_state_process(sk, skb,
  485. dh, len);
  486. break;
  487. }
  488. if (dh->dccph_type == DCCP_PKT_ACK ||
  489. dh->dccph_type == DCCP_PKT_DATAACK) {
  490. switch (old_state) {
  491. case DCCP_PARTOPEN:
  492. sk->sk_state_change(sk);
  493. sk_wake_async(sk, 0, POLL_OUT);
  494. break;
  495. }
  496. }
  497. if (!queued) {
  498. discard:
  499. __kfree_skb(skb);
  500. }
  501. return 0;
  502. }