cidr.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704
  1. /* $Id: cidr.c 2284 2009-05-03 07:24:10Z aturner $ */
  2. /*
  3. * Copyright (c) 2001-2004 Aaron Turner.
  4. * All rights reserved.
  5. *
  6. * Redistribution and use in source and binary forms, with or without
  7. * modification, are permitted provided that the following conditions
  8. * are met:
  9. *
  10. * 1. Redistributions of source code must retain the above copyright
  11. * notice, this list of conditions and the following disclaimer.
  12. * 2. Redistributions in binary form must reproduce the above copyright
  13. * notice, this list of conditions and the following disclaimer in the
  14. * documentation and/or other materials provided with the distribution.
  15. * 3. Neither the names of the copyright owners nor the names of its
  16. * contributors may be used to endorse or promote products derived from
  17. * this software without specific prior written permission.
  18. *
  19. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
  20. * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
  21. * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  22. * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
  23. * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  24. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
  25. * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  26. * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
  27. * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
  28. * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
  29. * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  30. */
  31. #include "config.h"
  32. #include "defines.h"
  33. #include "common.h"
  34. #include "lib/strlcpy.h"
  35. #include <stdio.h>
  36. #include <stdlib.h>
  37. #include <string.h>
  38. /* required for inet_aton() */
  39. #include <sys/socket.h>
  40. #include <netinet/in.h>
  41. #include <arpa/inet.h>
  42. #ifdef DEBUG
  43. extern int debug;
  44. #endif
  45. static tcpr_cidr_t *cidr2cidr(char *);
  46. /**
  47. * prints to the given fd all the entries in mycidr
  48. */
  49. void
  50. print_cidr(tcpr_cidr_t * mycidr)
  51. {
  52. tcpr_cidr_t *cidr_ptr;
  53. fprintf(stderr, "Cidr List: ");
  54. cidr_ptr = mycidr;
  55. while (cidr_ptr != NULL) {
  56. /* print it */
  57. fprintf(stderr, "%s/%d, ", get_cidr2name(cidr_ptr, RESOLVE),
  58. cidr_ptr->masklen);
  59. /* go to the next */
  60. if (cidr_ptr->next != NULL) {
  61. cidr_ptr = cidr_ptr->next;
  62. }
  63. else {
  64. break;
  65. }
  66. }
  67. fprintf(stderr, "\n");
  68. }
  69. /**
  70. * deletes all entries in a cidr and destroys the datastructure
  71. */
  72. void
  73. destroy_cidr(tcpr_cidr_t * cidr)
  74. {
  75. if (cidr != NULL)
  76. if (cidr->next != NULL)
  77. destroy_cidr(cidr->next);
  78. safe_free(cidr);
  79. return;
  80. }
  81. /**
  82. * adds a new tcpr_cidr_t entry to cidrdata
  83. */
  84. void
  85. add_cidr(tcpr_cidr_t ** cidrdata, tcpr_cidr_t ** newcidr)
  86. {
  87. tcpr_cidr_t *cidr_ptr;
  88. dbg(1, "Running new_cidr()");
  89. if (*cidrdata == NULL) {
  90. *cidrdata = *newcidr;
  91. } else {
  92. cidr_ptr = *cidrdata;
  93. while (cidr_ptr->next != NULL)
  94. cidr_ptr = cidr_ptr->next;
  95. cidr_ptr->next = *newcidr;
  96. }
  97. }
  98. /**
  99. * takes in an IP and masklen, and returns a string in
  100. * cidr format: x.x.x.x/y. This malloc's memory.
  101. */
  102. u_char *
  103. ip2cidr(const unsigned long ip, const int masklen)
  104. {
  105. u_char *network;
  106. char mask[3];
  107. network = (u_char *)safe_malloc(20);
  108. strlcpy((char *)network, (char *)get_addr2name4(ip, RESOLVE),
  109. sizeof(network));
  110. strcat((char *)network, "/");
  111. if (masklen < 10) {
  112. snprintf(mask, 1, "%d", masklen);
  113. strncat((char *)network, mask, 1);
  114. } else {
  115. snprintf(mask, 2, "%d", masklen);
  116. strncat((char *)network, mask, 2);
  117. }
  118. return (network);
  119. }
  120. /**
  121. * Mallocs and sets to sane defaults a tcpr_cidr_t structure
  122. */
  123. tcpr_cidr_t *
  124. new_cidr(void)
  125. {
  126. tcpr_cidr_t *newcidr;
  127. newcidr = (tcpr_cidr_t *)safe_malloc(sizeof(tcpr_cidr_t));
  128. memset(newcidr, '\0', sizeof(tcpr_cidr_t));
  129. newcidr->masklen = 99;
  130. newcidr->next = NULL;
  131. return (newcidr);
  132. }
  133. /**
  134. * Creates a new tcpr_cidrmap_t structure. Malloc's memory
  135. */
  136. tcpr_cidrmap_t *
  137. new_cidr_map(void)
  138. {
  139. tcpr_cidrmap_t *new;
  140. new = (tcpr_cidrmap_t *)safe_malloc(sizeof(tcpr_cidrmap_t));
  141. memset(new, '\0', sizeof(tcpr_cidrmap_t));
  142. new->next = NULL;
  143. return (new);
  144. }
  145. /**
  146. * Converts a single cidr (string) in the form of x.x.x.x/y into a
  147. * tcpr_cidr_t structure. Will malloc the tcpr_cidr_t structure.
  148. */
  149. static tcpr_cidr_t *
  150. cidr2cidr(char *cidr)
  151. {
  152. int count = 0;
  153. unsigned int octets[4]; /* used in sscanf */
  154. tcpr_cidr_t *newcidr;
  155. char networkip[16], tempoctet[4], ebuf[EBUF_SIZE];
  156. int family;
  157. char* p;
  158. assert(cidr);
  159. assert(strlen(cidr) <= EBUF_SIZE);
  160. newcidr = new_cidr();
  161. for (p = cidr; *p; ++p) {
  162. if (*p == '#') {
  163. *p = ':';
  164. } else if (*p == ']') {
  165. *p = 0;
  166. break;
  167. }
  168. }
  169. /*
  170. * scan it, and make sure it scanned correctly, also copy over the
  171. * masklen
  172. */
  173. count = sscanf(cidr, "%u.%u.%u.%u/%d", &octets[0], &octets[1],
  174. &octets[2], &octets[3], &newcidr->masklen);
  175. if (count == 4) {
  176. newcidr->masklen = 32;
  177. family = AF_INET;
  178. } else if (count == 5) {
  179. family = AF_INET;
  180. } else {
  181. p = strstr(cidr, "/");
  182. if (p) {
  183. *p = 0;
  184. ++p;
  185. count = sscanf(p, "%d", &newcidr->masklen);
  186. } else {
  187. newcidr->masklen = 128;
  188. }
  189. if (newcidr->masklen < 0 || newcidr->masklen > 128)
  190. goto error;
  191. if (get_name2addr6(cidr, RESOLVE, &newcidr->u.network6) > 0) {
  192. family = AF_INET6;
  193. } else {
  194. goto error;
  195. }
  196. }
  197. if (family == AF_INET) {
  198. /* masklen better be 0 =< masklen <= 32 */
  199. if (newcidr->masklen > 32)
  200. goto error;
  201. /* copy in the ip address */
  202. memset(networkip, '\0', 16);
  203. for (count = 0; count < 4; count++) {
  204. if (octets[count] > 255)
  205. goto error;
  206. snprintf(tempoctet, sizeof(octets[count]), "%d", octets[count]);
  207. strcat(networkip, tempoctet);
  208. /* we don't want a '.' at the end of the last octet */
  209. if (count < 3)
  210. strcat(networkip, ".");
  211. }
  212. /* copy over the network address and return */
  213. #ifdef HAVE_INET_ATON
  214. inet_aton(networkip, (struct in_addr *)&newcidr->u.network);
  215. #elif HAVE_INET_ADDR
  216. newcidr->network = inet_addr(networkip);
  217. #endif
  218. } else if (family == AF_INET6) {
  219. /* Everything's done */
  220. } else {
  221. goto error;
  222. }
  223. newcidr->family = family;
  224. return (newcidr);
  225. /* we only get here on error parsing input */
  226. error:
  227. memset(ebuf, '\0', EBUF_SIZE);
  228. strcpy(ebuf, "Unable to parse as a vaild CIDR: ");
  229. strlcat(ebuf, cidr, EBUF_SIZE);
  230. errx(-1, "%s", ebuf);
  231. return NULL;
  232. }
  233. static void
  234. mask_cidr6(char **cidrin, char* delim)
  235. {
  236. char *p;
  237. if (**cidrin == '[' && *delim == ':') {
  238. ++*cidrin;
  239. /* make strtok happy */
  240. for (p = *cidrin; *p && *p != ']'; ++p) {
  241. if (*p == ':') {
  242. *p = '#';
  243. }
  244. }
  245. }
  246. }
  247. /**
  248. * parses a list of tcpr_cidr_t's input from the user which should be in the form
  249. * of x.x.x.x/y,x.x.x.x/y...
  250. * returns 1 for success, or fails to return on failure (exit 1)
  251. * since we use strtok to process cidr, it gets zeroed out.
  252. */
  253. int
  254. parse_cidr(tcpr_cidr_t ** cidrdata, char *cidrin, char *delim)
  255. {
  256. tcpr_cidr_t *cidr_ptr; /* ptr to current cidr record */
  257. char *network = NULL;
  258. char *token = NULL;
  259. mask_cidr6(&cidrin, delim);
  260. /* first itteration of input using strtok */
  261. network = strtok_r(cidrin, delim, &token);
  262. *cidrdata = cidr2cidr(network);
  263. cidr_ptr = *cidrdata;
  264. /* do the same with the rest of the input */
  265. while (1) {
  266. if (token)
  267. mask_cidr6(&token, delim);
  268. network = strtok_r(NULL, delim, &token);
  269. /* if that was the last CIDR, then kickout */
  270. if (network == NULL)
  271. break;
  272. /* next record */
  273. cidr_ptr->next = cidr2cidr(network);
  274. cidr_ptr = cidr_ptr->next;
  275. }
  276. return 1;
  277. }
  278. /**
  279. * parses a pair of IP addresses: <IP1>:<IP2> and processes it like:
  280. * -N 0.0.0.0/0:<IP1> -N 0.0.0.0/0:<IP2>
  281. * returns 1 for success or returns 0 on failure
  282. * since we use strtok to process optarg, it gets zeroed out
  283. */
  284. int
  285. parse_endpoints(tcpr_cidrmap_t ** cidrmap1, tcpr_cidrmap_t ** cidrmap2, const char *optarg)
  286. {
  287. #define NEWMAP_LEN (INET6_ADDRSTRLEN * 2)
  288. char *map = NULL, newmap[NEWMAP_LEN];
  289. char *token = NULL;
  290. char *string;
  291. char *p;
  292. string = safe_strdup(optarg);
  293. if (*string == '[') {
  294. /* ipv6 mode */
  295. memset(newmap, '\0', NEWMAP_LEN);
  296. p = strstr(string, "]:[");
  297. if (!p)
  298. return 0;
  299. *p = 0;
  300. strlcpy(newmap, "[::/0]:", NEWMAP_LEN);
  301. strlcat(newmap, string, NEWMAP_LEN);
  302. strlcat(newmap, "]", NEWMAP_LEN);
  303. if (! parse_cidr_map(cidrmap1, newmap))
  304. return 0;
  305. /* do again with the second IP */
  306. memset(newmap, '\0', NEWMAP_LEN);
  307. strlcpy(newmap, "[::/0]:", NEWMAP_LEN);
  308. strlcat(newmap, p + 2, NEWMAP_LEN);
  309. if (! parse_cidr_map(cidrmap2, newmap))
  310. return 0;
  311. } else {
  312. /* ipv4 mode */
  313. memset(newmap, '\0', NEWMAP_LEN);
  314. map = strtok_r(string, ":", &token);
  315. strlcpy(newmap, "0.0.0.0/0:", NEWMAP_LEN);
  316. strlcat(newmap, map, NEWMAP_LEN);
  317. if (! parse_cidr_map(cidrmap1, newmap))
  318. return 0;
  319. /* do again with the second IP */
  320. memset(newmap, '\0', NEWMAP_LEN);
  321. map = strtok_r(NULL, ":", &token);
  322. strlcpy(newmap, "0.0.0.0/0:", NEWMAP_LEN);
  323. strlcat(newmap, map, NEWMAP_LEN);
  324. if (! parse_cidr_map(cidrmap2, newmap))
  325. return 0;
  326. }
  327. safe_free(string);
  328. return 1; /* success */
  329. }
  330. /**
  331. * parses a list of tcpr_cidrmap_t's input from the user which should be in the form
  332. * of x.x.x.x/y:x.x.x.x/y,...
  333. * IPv6 syntax: [addr/y]:[addr/y],...
  334. * returns 1 for success, or returns 0 on failure
  335. * since we use strtok to process optarg, it gets zeroed out.
  336. */
  337. int
  338. parse_cidr_map(tcpr_cidrmap_t **cidrmap, const char *optarg)
  339. {
  340. tcpr_cidr_t *cidr = NULL;
  341. char *map = NULL;
  342. char *token = NULL, *string = NULL;
  343. tcpr_cidrmap_t *ptr;
  344. string = safe_strdup(optarg);
  345. /* first iteration */
  346. map = strtok_r(string, ",", &token);
  347. if (! parse_cidr(&cidr, map, ":"))
  348. return 0;
  349. /* must return a linked list of two */
  350. if (cidr->next == NULL)
  351. return 0;
  352. /* copy over */
  353. *cidrmap = new_cidr_map();
  354. ptr = *cidrmap;
  355. ptr->from = cidr;
  356. ptr->to = cidr->next;
  357. ptr->from->next = NULL;
  358. /* do the same with the reset of the input */
  359. while(1) {
  360. map = strtok_r(NULL, ",", &token);
  361. if (map == NULL)
  362. break;
  363. if (! parse_cidr(&cidr, map, ":"))
  364. return 0;
  365. /* must return a linked list of two */
  366. if (cidr->next == NULL)
  367. return 0;
  368. /* copy over */
  369. ptr->next = new_cidr_map();
  370. ptr = ptr->next;
  371. ptr->from = cidr;
  372. ptr->to = cidr->next;
  373. ptr->from->next = NULL;
  374. }
  375. safe_free(string);
  376. return 1; /* success */
  377. }
  378. /**
  379. * checks to see if the ip address is in the cidr
  380. * returns 1 for true, 0 for false
  381. */
  382. int
  383. ip_in_cidr(const tcpr_cidr_t * mycidr, const unsigned long ip)
  384. {
  385. unsigned long ipaddr = 0, network = 0, mask = 0;
  386. int ret = 0;
  387. #ifdef DEBUG
  388. char netstr[20];
  389. #endif
  390. if (mycidr->family != AF_INET)
  391. return 0;
  392. /* always return 1 if 0.0.0.0/0 */
  393. if (mycidr->masklen == 0 && mycidr->u.network == 0)
  394. return 1;
  395. mask = ~0; /* turn on all the bits */
  396. /* shift over by the correct number of bits */
  397. mask = mask << (32 - mycidr->masklen);
  398. /* apply the mask to the network and ip */
  399. ipaddr = ntohl(ip) & mask;
  400. network = htonl(mycidr->u.network) & mask;
  401. #ifdef DEBUG
  402. /* copy this for debug purposes, since it's not re-entrant */
  403. strlcpy(netstr, get_addr2name4(htonl(mycidr->u.network), RESOLVE), 20);
  404. #endif
  405. /* if they're the same, then ip is in network */
  406. if (network == ipaddr) {
  407. #ifdef DEBUG
  408. dbgx(1, "The ip %s is inside of %s/%d",
  409. get_addr2name4(ip, RESOLVE), netstr, mycidr->masklen);
  410. #endif
  411. ret = 1;
  412. } else {
  413. #ifdef DEBUG
  414. dbgx(1, "The ip %s is not inside of %s/%d",
  415. get_addr2name4(ip, RESOLVE), netstr, mycidr->masklen);
  416. #endif
  417. ret = 0;
  418. }
  419. return ret;
  420. }
  421. static int
  422. ip6_addr_is_unspec(const struct tcpr_in6_addr *addr)
  423. {
  424. return addr->tcpr_s6_addr32[0] == 0 && addr->tcpr_s6_addr32[1] == 0 &&
  425. addr->tcpr_s6_addr32[2] == 0 && addr->tcpr_s6_addr32[3] == 0;
  426. }
  427. int
  428. ip6_in_cidr(const tcpr_cidr_t * mycidr, const struct tcpr_in6_addr *addr)
  429. {
  430. int ret = 0;
  431. #ifdef DEBUG
  432. char netstr[INET6_ADDRSTRLEN];
  433. #endif
  434. int i, j, k;
  435. if (mycidr->family != AF_INET6)
  436. return 0;
  437. /* always return 1 if ::/0 */
  438. if (mycidr->masklen == 0 && ip6_addr_is_unspec(addr))
  439. return 1;
  440. j = mycidr->masklen / 8;
  441. for (i = 0; i < j; i++) {
  442. if (addr->tcpr_s6_addr[i] != mycidr->u.network6.tcpr_s6_addr[i]) {
  443. ret = 0;
  444. goto out;
  445. }
  446. }
  447. if ((k = mycidr->masklen % 8) == 0) {
  448. ret = 1;
  449. goto out;
  450. }
  451. k = ~0 << (8 - k);
  452. i = addr->tcpr_s6_addr[j] & k;
  453. j = mycidr->u.network6.tcpr_s6_addr[j] & k;
  454. ret = i == j;
  455. out:
  456. #ifdef DEBUG
  457. /* copy this for debug purposes, since it's not re-entrant */
  458. strlcpy(netstr, get_addr2name6(&mycidr->u.network6, RESOLVE), INET6_ADDRSTRLEN);
  459. #endif
  460. /* if they're the same, then ip is in network */
  461. if (ret) {
  462. #ifdef DEBUG
  463. dbgx(1, "The ip %s is inside of %s/%d",
  464. get_addr2name6(addr, RESOLVE), netstr, mycidr->masklen);
  465. #endif
  466. } else {
  467. #ifdef DEBUG
  468. dbgx(1, "The ip %s is not inside of %s/%d",
  469. get_addr2name6(addr, RESOLVE), netstr, mycidr->masklen);
  470. #endif
  471. }
  472. return ret;
  473. }
  474. /**
  475. * iterates over cidrdata to find if a given ip matches
  476. * returns 1 for true, 0 for false
  477. */
  478. int
  479. check_ip_cidr(tcpr_cidr_t * cidrdata, const unsigned long ip)
  480. {
  481. tcpr_cidr_t *mycidr;
  482. /* if we have no cidrdata, of course it isn't in there
  483. * this actually should happen occasionally, so don't put an assert here
  484. */
  485. if (cidrdata == NULL)
  486. return 1;
  487. mycidr = cidrdata;
  488. /* loop through cidr */
  489. while (1) {
  490. /* if match, return 1 */
  491. if (ip_in_cidr(mycidr, ip)) {
  492. dbgx(3, "Found %s in cidr", get_addr2name4(ip, RESOLVE));
  493. return 1;
  494. }
  495. /* check for next record */
  496. if (mycidr->next != NULL) {
  497. mycidr = mycidr->next;
  498. } else {
  499. break;
  500. }
  501. }
  502. /* if we get here, no match */
  503. dbgx(3, "Didn't find %s in cidr", get_addr2name4(ip, RESOLVE));
  504. return 0;
  505. }
  506. int
  507. check_ip6_cidr(tcpr_cidr_t * cidrdata, const struct tcpr_in6_addr *addr)
  508. {
  509. tcpr_cidr_t *mycidr;
  510. /* if we have no cidrdata, of course it isn't in there
  511. * this actually should happen occasionally, so don't put an assert here
  512. */
  513. if (cidrdata == NULL) {
  514. return 1;
  515. }
  516. mycidr = cidrdata;
  517. /* loop through cidr */
  518. while (1) {
  519. /* if match, return 1 */
  520. if (ip6_in_cidr(mycidr, addr)) {
  521. dbgx(3, "Found %s in cidr", get_addr2name6(addr, RESOLVE));
  522. return 1;
  523. }
  524. /* check for next record */
  525. if (mycidr->next != NULL) {
  526. mycidr = mycidr->next;
  527. } else {
  528. break;
  529. }
  530. }
  531. /* if we get here, no match */
  532. dbgx(3, "Didn't find %s in cidr", get_addr2name6(addr, RESOLVE));
  533. return 0;
  534. }
  535. /**
  536. * cidr2ip takes a tcpr_cidr_t and a delimiter
  537. * and returns a string which lists all the IP addresses in the cidr
  538. * deliminated by the given char
  539. */
  540. char *
  541. cidr2iplist(tcpr_cidr_t * cidr, char delim)
  542. {
  543. char *list = NULL;
  544. char ipaddr[16];
  545. u_int32_t size, addr, first, last, numips;
  546. struct in_addr in;
  547. /*
  548. * 16 bytes per IP + delim
  549. * # of IP's = 2^(32-masklen)
  550. */
  551. numips = 2;
  552. for (int i = 2; i <= (32 - cidr->masklen); i++)
  553. numips *= 2;
  554. size = 16 * numips;
  555. list = (char *)safe_malloc(size);
  556. memset(list, 0, size);
  557. /* first and last should not include network or broadcast */
  558. first = ntohl(cidr->u.network) + 1;
  559. last = first + numips - 3;
  560. dbgx(1, "First: %u\t\tLast: %u", first, last);
  561. /* loop through all but the last one */
  562. for (addr = first; addr < last; addr++) {
  563. in.s_addr = htonl(addr);
  564. snprintf(ipaddr, 17, "%s%c", inet_ntoa(in), delim);
  565. dbgx(2, "%s", ipaddr);
  566. strlcat(list, ipaddr, size);
  567. }
  568. /* last is a special case, end in \0 */
  569. in.s_addr = htonl(addr);
  570. snprintf(ipaddr, 16, "%s", inet_ntoa(in));
  571. strlcat(list, ipaddr, size);
  572. return list;
  573. }