udp_server.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603
  1. /*
  2. * $Id$
  3. *
  4. * Copyright (C) 2001-2003 FhG Fokus
  5. *
  6. * This file is part of ser, a free SIP server.
  7. *
  8. * ser is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation; either version 2 of the License, or
  11. * (at your option) any later version
  12. *
  13. * For a license to use the ser software under conditions
  14. * other than those described here, or to purchase support for this
  15. * software, please contact iptel.org by e-mail at the following addresses:
  16. * [email protected]
  17. *
  18. * ser is distributed in the hope that it will be useful,
  19. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  20. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  21. * GNU General Public License for more details.
  22. *
  23. * You should have received a copy of the GNU General Public License
  24. * along with this program; if not, write to the Free Software
  25. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  26. *
  27. * History
  28. * --------
  29. * 2003-01-28 packet zero-termination moved to receive_msg (jiri)
  30. * 2003-02-10 undoed the above changes (andrei)
  31. * 2003-03-19 replaced all the mallocs/frees w/ pkg_malloc/pkg_free (andrei)
  32. * 2003-04-14 set sockopts to TOS low delay (andrei)
  33. * 2004-05-03 applied multicast support patch from janakj
  34. * added set multicast ttl support (andrei)
  35. * 2004-07-05 udp_rcv_loop: drop packets with 0 src port + error msg.
  36. * cleanups (andrei)
  37. * 2005-03-10 multicast options are now set for all the udp sockets (andrei)
  38. * 2005-06-26 failure to set mcast options is not an error anymore (andrei)
  39. * 2006-04-12 udp_send() switched to struct dest_info (andrei)
  40. * 2006-10-13 added STUN support (vlada)
  41. * 2007-08-28 disable/set MTU discover option for the udp sockets
  42. * (in linux it's enabled by default which produces udp packets
  43. * with the DF flag ser) (patch from hscholz)
  44. * 2010-06-15 support for using raw sockets for sending (andrei)
  45. */
  46. /** udp send and loop-receive functions.
  47. * @file udp_server.c
  48. * @ingroup core
  49. * Module: @ref core
  50. */
  51. #include <stdlib.h>
  52. #include <string.h>
  53. #include <sys/types.h>
  54. #include <sys/socket.h>
  55. #include <netinet/in.h>
  56. #include <netinet/in_systm.h>
  57. #include <netinet/ip.h>
  58. #include <errno.h>
  59. #include <arpa/inet.h>
  60. #ifdef __linux__
  61. #include <linux/types.h>
  62. #include <linux/errqueue.h>
  63. #endif
  64. #include "udp_server.h"
  65. #include "compiler_opt.h"
  66. #include "globals.h"
  67. #include "config.h"
  68. #include "dprint.h"
  69. #include "receive.h"
  70. #include "mem/mem.h"
  71. #include "ip_addr.h"
  72. #include "cfg/cfg_struct.h"
  73. #include "events.h"
  74. #include "stun.h"
  75. #ifdef USE_RAW_SOCKS
  76. #include "raw_sock.h"
  77. #endif /* USE_RAW_SOCKS */
  78. #ifdef DBG_MSG_QA
  79. /* message quality assurance -- frequently, bugs in ser have
  80. been indicated by zero characters or long whitespaces
  81. in generated messages; this debugging option aborts if
  82. any such message is sighted
  83. */
  84. static int dbg_msg_qa(char *buf, int len)
  85. {
  86. #define _DBG_WS_LEN 3
  87. #define _DBG_WS " "
  88. char *scan;
  89. int my_len;
  90. int space_cnt;
  91. enum { QA_ANY, QA_SPACE, QA_EOL1 } state;
  92. /* is there a zero character in there ? */
  93. if (memchr(buf, 0, len)) {
  94. LM_CRIT("message with 0 in it\n");
  95. return 0;
  96. }
  97. my_len=len;
  98. scan=buf;
  99. state=QA_ANY;
  100. space_cnt=0;
  101. while(my_len) {
  102. switch(*scan) {
  103. case ' ': if (state==QA_SPACE) {
  104. space_cnt++;
  105. if (space_cnt==4) {
  106. LM_CRIT("DBG_MSG_QA: too many spaces\n");
  107. return 0;
  108. }
  109. } else space_cnt=0;
  110. state=QA_SPACE;
  111. break;
  112. case '\r': /* ignore */
  113. space_cnt=0;
  114. break;
  115. case '\n': /* don't proceed to body on EoH */
  116. if (state==QA_EOL1) goto qa_passed;
  117. space_cnt=0;
  118. state=QA_EOL1;
  119. break;
  120. default: space_cnt=0;
  121. state=QA_ANY;
  122. break;
  123. }
  124. scan++;
  125. my_len--;
  126. }
  127. qa_passed:
  128. return 1;
  129. }
  130. #endif
  131. int probe_max_receive_buffer( int udp_sock )
  132. {
  133. int optval;
  134. int ioptval;
  135. unsigned int ioptvallen;
  136. int foptval;
  137. unsigned int foptvallen;
  138. int voptval;
  139. unsigned int voptvallen;
  140. int phase=0;
  141. /* jku: try to increase buffer size as much as we can */
  142. ioptvallen=sizeof(ioptval);
  143. if (getsockopt( udp_sock, SOL_SOCKET, SO_RCVBUF, (void*) &ioptval,
  144. &ioptvallen) == -1 )
  145. {
  146. LM_ERR("getsockopt: %s\n", strerror(errno));
  147. return -1;
  148. }
  149. if ( ioptval==0 )
  150. {
  151. LM_DBG("SO_RCVBUF initially set to 0; resetting to %d\n",
  152. BUFFER_INCREMENT );
  153. ioptval=BUFFER_INCREMENT;
  154. } else LM_INFO("SO_RCVBUF is initially %d\n", ioptval );
  155. for (optval=ioptval; ; ) {
  156. /* increase size; double in initial phase, add linearly later */
  157. if (phase==0) optval <<= 1; else optval+=BUFFER_INCREMENT;
  158. if (optval > maxbuffer){
  159. if (phase==1) break;
  160. else { phase=1; optval >>=1; continue; }
  161. }
  162. LM_DBG("trying SO_RCVBUF: %d\n", optval );
  163. if (setsockopt( udp_sock, SOL_SOCKET, SO_RCVBUF,
  164. (void*)&optval, sizeof(optval)) ==-1){
  165. /* Solaris returns -1 if asked size too big; Linux ignores */
  166. LM_DBG("SOL_SOCKET failed for %d, phase %d: %s\n", optval, phase, strerror(errno));
  167. /* if setting buffer size failed and still in the aggressive
  168. phase, try less aggressively; otherwise give up
  169. */
  170. if (phase==0) { phase=1; optval >>=1 ; continue; }
  171. else break;
  172. }
  173. /* verify if change has taken effect */
  174. /* Linux note -- otherwise I would never know that; funny thing: Linux
  175. doubles size for which we asked in setsockopt
  176. */
  177. voptvallen=sizeof(voptval);
  178. if (getsockopt( udp_sock, SOL_SOCKET, SO_RCVBUF, (void*) &voptval,
  179. &voptvallen) == -1 )
  180. {
  181. LM_ERR("getsockopt: %s\n", strerror(errno));
  182. return -1;
  183. } else {
  184. LM_DBG("setting SO_RCVBUF; set=%d,verify=%d\n",
  185. optval, voptval);
  186. if (voptval<optval) {
  187. LM_DBG("setting SO_RCVBUF has no effect\n");
  188. /* if setting buffer size failed and still in the aggressive
  189. phase, try less aggressively; otherwise give up
  190. */
  191. if (phase==0) { phase=1; optval >>=1 ; continue; }
  192. else break;
  193. }
  194. }
  195. } /* for ... */
  196. foptvallen=sizeof(foptval);
  197. if (getsockopt( udp_sock, SOL_SOCKET, SO_RCVBUF, (void*) &foptval,
  198. &foptvallen) == -1 )
  199. {
  200. LM_ERR("getsockopt: %s\n", strerror(errno));
  201. return -1;
  202. }
  203. LM_INFO("SO_RCVBUF is finally %d\n", foptval );
  204. return 0;
  205. /* EoJKU */
  206. }
  207. #ifdef USE_MCAST
  208. /*
  209. * Setup multicast receiver
  210. */
  211. static int setup_mcast_rcvr(int sock, union sockaddr_union* addr)
  212. {
  213. struct ip_mreq mreq;
  214. struct ipv6_mreq mreq6;
  215. if (addr->s.sa_family==AF_INET){
  216. memcpy(&mreq.imr_multiaddr, &addr->sin.sin_addr,
  217. sizeof(struct in_addr));
  218. mreq.imr_interface.s_addr = htonl(INADDR_ANY);
  219. if (setsockopt(sock, IPPROTO_IP, IP_ADD_MEMBERSHIP,&mreq,
  220. sizeof(mreq))==-1){
  221. LM_ERR("setsockopt: %s\n", strerror(errno));
  222. return -1;
  223. }
  224. } else if (addr->s.sa_family==AF_INET6){
  225. memcpy(&mreq6.ipv6mr_multiaddr, &addr->sin6.sin6_addr,
  226. sizeof(struct in6_addr));
  227. mreq6.ipv6mr_interface = 0;
  228. #ifdef __OS_linux
  229. if (setsockopt(sock, IPPROTO_IPV6, IPV6_ADD_MEMBERSHIP, &mreq6,
  230. #else
  231. if (setsockopt(sock, IPPROTO_IPV6, IPV6_JOIN_GROUP, &mreq6,
  232. #endif
  233. sizeof(mreq6))==-1){
  234. LM_ERR("setsockopt:%s\n", strerror(errno));
  235. return -1;
  236. }
  237. } else {
  238. LM_ERR("setup_mcast_rcvr: Unsupported protocol family\n");
  239. return -1;
  240. }
  241. return 0;
  242. }
  243. #endif /* USE_MCAST */
  244. int udp_init(struct socket_info* sock_info)
  245. {
  246. union sockaddr_union* addr;
  247. int optval;
  248. #ifdef USE_MCAST
  249. unsigned char m_ttl, m_loop;
  250. #endif
  251. addr=&sock_info->su;
  252. /*
  253. addr=(union sockaddr_union*)pkg_malloc(sizeof(union sockaddr_union));
  254. if (addr==0){
  255. LM_ERR("out of memory\n");
  256. goto error;
  257. }
  258. */
  259. sock_info->proto=PROTO_UDP;
  260. if (init_su(addr, &sock_info->address, sock_info->port_no)<0){
  261. LM_ERR("could not init sockaddr_union\n");
  262. goto error;
  263. }
  264. sock_info->socket = socket(AF2PF(addr->s.sa_family), SOCK_DGRAM, 0);
  265. if (sock_info->socket==-1){
  266. LM_ERR("socket: %s\n", strerror(errno));
  267. goto error;
  268. }
  269. /* set sock opts? */
  270. optval=1;
  271. if (setsockopt(sock_info->socket, SOL_SOCKET, SO_REUSEADDR ,
  272. (void*)&optval, sizeof(optval)) ==-1){
  273. LM_ERR("setsockopt: %s\n", strerror(errno));
  274. goto error;
  275. }
  276. /* tos */
  277. optval = tos;
  278. if (addr->s.sa_family==AF_INET){
  279. if (setsockopt(sock_info->socket, IPPROTO_IP, IP_TOS, (void*)&optval,
  280. sizeof(optval)) ==-1){
  281. LM_WARN("setsockopt tos: %s\n", strerror(errno));
  282. /* continue since this is not critical */
  283. }
  284. } else if (addr->s.sa_family==AF_INET6){
  285. if (setsockopt(sock_info->socket, IPPROTO_IPV6, IPV6_TCLASS,
  286. (void*)&optval, sizeof(optval)) ==-1) {
  287. LM_WARN("setsockopt v6 tos: %s\n", strerror(errno));
  288. /* continue since this is not critical */
  289. }
  290. }
  291. #if defined (__OS_linux) && defined(UDP_ERRORS)
  292. optval=1;
  293. /* enable error receiving on unconnected sockets */
  294. if(setsockopt(sock_info->socket, SOL_IP, IP_RECVERR,
  295. (void*)&optval, sizeof(optval)) ==-1){
  296. LM_ERR("setsockopt: %s\n", strerror(errno));
  297. goto error;
  298. }
  299. #endif
  300. #if defined (__OS_linux)
  301. /* if pmtu_discovery=1 then set DF bit and do Path MTU discovery
  302. * disabled by default */
  303. optval= (pmtu_discovery) ? IP_PMTUDISC_DO : IP_PMTUDISC_DONT;
  304. if(setsockopt(sock_info->socket, IPPROTO_IP, IP_MTU_DISCOVER,
  305. (void*)&optval, sizeof(optval)) ==-1){
  306. LM_ERR("setsockopt: %s\n", strerror(errno));
  307. goto error;
  308. }
  309. #endif
  310. #ifdef USE_MCAST
  311. if ((sock_info->flags & SI_IS_MCAST)
  312. && (setup_mcast_rcvr(sock_info->socket, addr)<0)){
  313. goto error;
  314. }
  315. /* set the multicast options */
  316. if (addr->s.sa_family==AF_INET){
  317. m_loop=mcast_loopback;
  318. if (setsockopt(sock_info->socket, IPPROTO_IP, IP_MULTICAST_LOOP,
  319. &m_loop, sizeof(m_loop))==-1){
  320. LM_WARN("setsockopt(IP_MULTICAST_LOOP): %s\n", strerror(errno));
  321. /* it's only a warning because we might get this error if the
  322. network interface doesn't support multicasting -- andrei */
  323. }
  324. if (mcast_ttl>=0){
  325. m_ttl=mcast_ttl;
  326. if (setsockopt(sock_info->socket, IPPROTO_IP, IP_MULTICAST_TTL,
  327. &m_ttl, sizeof(m_ttl))==-1){
  328. LM_WARN("setsockopt (IP_MULTICAST_TTL): %s\n", strerror(errno));
  329. }
  330. }
  331. } else if (addr->s.sa_family==AF_INET6){
  332. if (setsockopt(sock_info->socket, IPPROTO_IPV6, IPV6_MULTICAST_LOOP,
  333. &mcast_loopback, sizeof(mcast_loopback))==-1){
  334. LM_WARN("setsockopt (IPV6_MULTICAST_LOOP): %s\n", strerror(errno));
  335. }
  336. if (mcast_ttl>=0){
  337. if (setsockopt(sock_info->socket, IPPROTO_IP, IPV6_MULTICAST_HOPS,
  338. &mcast_ttl, sizeof(mcast_ttl))==-1){
  339. LM_WARN("setssckopt (IPV6_MULTICAST_HOPS): %s\n", strerror(errno));
  340. }
  341. }
  342. } else {
  343. LM_ERR("Unsupported protocol family %d\n", addr->s.sa_family);
  344. goto error;
  345. }
  346. #endif /* USE_MCAST */
  347. if ( probe_max_receive_buffer(sock_info->socket)==-1) goto error;
  348. if (bind(sock_info->socket, &addr->s, sockaddru_len(*addr))==-1){
  349. LM_ERR("bind(%x, %p, %d) on %s: %s\n",
  350. sock_info->socket, &addr->s,
  351. (unsigned)sockaddru_len(*addr),
  352. sock_info->address_str.s,
  353. strerror(errno));
  354. if (addr->s.sa_family==AF_INET6)
  355. LM_ERR("might be caused by using a link local address, try site local or global\n");
  356. goto error;
  357. }
  358. /* pkg_free(addr);*/
  359. return 0;
  360. error:
  361. /* if (addr) pkg_free(addr);*/
  362. return -1;
  363. }
  364. int udp_rcv_loop()
  365. {
  366. unsigned len;
  367. #ifdef DYN_BUF
  368. char* buf;
  369. #else
  370. static char buf [BUF_SIZE+1];
  371. #endif
  372. char *tmp;
  373. union sockaddr_union* from;
  374. unsigned int fromlen;
  375. struct receive_info ri;
  376. from=(union sockaddr_union*) pkg_malloc(sizeof(union sockaddr_union));
  377. if (from==0){
  378. LM_ERR("out of memory\n");
  379. goto error;
  380. }
  381. memset(from, 0 , sizeof(union sockaddr_union));
  382. ri.bind_address=bind_address; /* this will not change, we do it only once*/
  383. ri.dst_port=bind_address->port_no;
  384. ri.dst_ip=bind_address->address;
  385. ri.proto=PROTO_UDP;
  386. ri.proto_reserved1=ri.proto_reserved2=0;
  387. /* initialize the config framework */
  388. if (cfg_child_init()) goto error;
  389. for(;;){
  390. #ifdef DYN_BUF
  391. buf=pkg_malloc(BUF_SIZE+1);
  392. if (buf==0){
  393. LM_ERR("could not allocate receive buffer\n");
  394. goto error;
  395. }
  396. #endif
  397. fromlen=sockaddru_len(bind_address->su);
  398. len=recvfrom(bind_address->socket, buf, BUF_SIZE, 0, &from->s,
  399. &fromlen);
  400. if (len==-1){
  401. if (errno==EAGAIN){
  402. DBG("udp_rcv_loop: packet with bad checksum received\n");
  403. continue;
  404. }
  405. LM_ERR("recvfrom:[%d] %s\n", errno, strerror(errno));
  406. if ((errno==EINTR)||(errno==EWOULDBLOCK)|| (errno==ECONNREFUSED))
  407. continue; /* goto skip;*/
  408. else goto error;
  409. }
  410. /* we must 0-term the messages, receive_msg expects it */
  411. buf[len]=0; /* no need to save the previous char */
  412. ri.src_su=*from;
  413. su2ip_addr(&ri.src_ip, from);
  414. ri.src_port=su_getport(from);
  415. if(unlikely(sr_event_enabled(SREV_NET_DGRAM_IN)))
  416. {
  417. void *sredp[3];
  418. sredp[0] = (void*)buf;
  419. sredp[1] = (void*)(&len);
  420. sredp[2] = (void*)(&ri);
  421. if(sr_event_exec(SREV_NET_DGRAM_IN, (void*)sredp)<0) {
  422. /* data handled by callback - continue to next packet */
  423. continue;
  424. }
  425. }
  426. #ifndef NO_ZERO_CHECKS
  427. if (!unlikely(sr_event_enabled(SREV_STUN_IN)) || (unsigned char)*buf != 0x00) {
  428. if (len<MIN_UDP_PACKET) {
  429. tmp=ip_addr2a(&ri.src_ip);
  430. DBG("udp_rcv_loop: probing packet received from %s %d\n",
  431. tmp, htons(ri.src_port));
  432. continue;
  433. }
  434. }
  435. /* historically, zero-terminated packets indicated a bug in clients
  436. * that calculated wrongly packet length and included string-terminating
  437. * zero; today clients exist with legitimate binary payloads and we
  438. * shall not check for zero-terminated payloads
  439. */
  440. #ifdef TRASH_ZEROTERMINATED_PACKETS
  441. if (buf[len-1]==0) {
  442. tmp=ip_addr2a(&ri.src_ip);
  443. LM_WARN("upstream bug - 0-terminated packet from %s %d\n",
  444. tmp, htons(ri.src_port));
  445. len--;
  446. }
  447. #endif
  448. #endif
  449. #ifdef DBG_MSG_QA
  450. if (!dbg_msg_qa(buf, len)) {
  451. LM_WARN("an incoming message didn't pass test,"
  452. " drop it: %.*s\n", len, buf );
  453. continue;
  454. }
  455. #endif
  456. if (ri.src_port==0){
  457. tmp=ip_addr2a(&ri.src_ip);
  458. LM_INFO("dropping 0 port packet from %s\n", tmp);
  459. continue;
  460. }
  461. /* update the local config */
  462. cfg_update();
  463. if (unlikely(sr_event_enabled(SREV_STUN_IN)) && (unsigned char)*buf == 0x00) {
  464. /* stun_process_msg releases buf memory if necessary */
  465. if ((stun_process_msg(buf, len, &ri)) != 0) {
  466. continue; /* some error occurred */
  467. }
  468. } else {
  469. /* receive_msg must free buf too!*/
  470. receive_msg(buf, len, &ri);
  471. }
  472. /* skip: do other stuff */
  473. }
  474. /*
  475. if (from) pkg_free(from);
  476. return 0;
  477. */
  478. error:
  479. if (from) pkg_free(from);
  480. return -1;
  481. }
  482. /* send buf:len over udp to dst (uses only the to and send_sock dst members)
  483. * returns the numbers of bytes sent on success (>=0) and -1 on error
  484. */
  485. int udp_send(struct dest_info* dst, char *buf, unsigned len)
  486. {
  487. int n;
  488. int tolen;
  489. struct ip_addr ip; /* used only on error, for debugging */
  490. #ifdef USE_RAW_SOCKS
  491. int mtu;
  492. #endif /* USE_RAW_SOCKS */
  493. #ifdef DBG_MSG_QA
  494. /* aborts on error, does nothing otherwise */
  495. if (!dbg_msg_qa( buf, len )) {
  496. LM_ERR("dbg_msg_qa failed\n");
  497. abort();
  498. }
  499. #endif
  500. #ifdef USE_RAW_SOCKS
  501. if (likely( ! (raw_udp4_send_sock >= 0 &&
  502. cfg_get(core, core_cfg, udp4_raw) &&
  503. dst->send_sock->address.af == AF_INET) )) {
  504. #endif /* USE_RAW_SOCKS */
  505. /* normal send over udp socket */
  506. tolen=sockaddru_len(dst->to);
  507. again:
  508. n=sendto(dst->send_sock->socket, buf, len, 0, &dst->to.s, tolen);
  509. #ifdef XL_DEBUG
  510. LM_INFO("send status: %d\n", n);
  511. #endif
  512. if (unlikely(n==-1)){
  513. su2ip_addr(&ip, &dst->to);
  514. LM_ERR("sendto(sock,%p,%u,0,%s:%d,%d): %s(%d)\n",
  515. buf,len, ip_addr2a(&ip),
  516. su_getport(&dst->to), tolen, strerror(errno), errno);
  517. if (errno==EINTR) goto again;
  518. if (errno==EINVAL) {
  519. LM_CRIT("invalid sendtoparameters\n"
  520. "one possible reason is the server is bound to localhost and\n"
  521. "attempts to send to the net\n");
  522. }
  523. }
  524. #ifdef USE_RAW_SOCKS
  525. } else {
  526. /* send over a raw socket */
  527. mtu = cfg_get(core, core_cfg, udp4_raw_mtu);
  528. raw_again:
  529. n=raw_iphdr_udp4_send(raw_udp4_send_sock, buf, len,
  530. &dst->send_sock->su,
  531. &dst->to,
  532. mtu);
  533. if (unlikely(n==-1)){
  534. su2ip_addr(&ip, &dst->to);
  535. LM_ERR("raw_iphdr_udp4_send(%d,%p,%u,...,%s:%d,%d): %s(%d)\n",
  536. raw_udp4_send_sock, buf,len, ip_addr2a(&ip),
  537. su_getport(&dst->to), mtu, strerror(errno), errno);
  538. if (errno==EINTR) goto raw_again;
  539. }
  540. }
  541. #endif /* USE_RAW_SOCKS */
  542. return n;
  543. }