| 1 | /* |
| 2 | * Copyright (C) 2001 sousou ([email protected]) |
| 3 | * |
| 4 | * This program is free software; you can redistribute it and/or |
| 5 | * modify it under the terms of the GNU General Public License |
| 6 | * as published by the Free Software Foundation; either version 2 |
| 7 | * of the License, or (at your option) any later version. |
| 8 | * |
| 9 | * This program is distributed in the hope that it will be useful, |
| 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 | * GNU General Public License for more details. |
| 13 | * |
| 14 | * You should have received a copy of the GNU General Public License |
| 15 | * along with this program; if not, write to the Free Software |
| 16 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
| 17 | */ |
| 18 | #include "common/setup_before.h" |
| 19 | #include "setup.h" |
| 20 | #include "dbserver.h" |
| 21 | |
| 22 | #include <cstring> |
| 23 | #include <ctime> |
| 24 | |
| 25 | #ifdef WIN32 |
| 26 | # include <conio.h> |
| 27 | #endif |
| 28 | |
| 29 | #include "compat/psock.h" |
| 30 | #include "compat/strerror.h" |
| 31 | #include "common/eventlog.h" |
| 32 | #include "common/addr.h" |
| 33 | #include "common/xalloc.h" |
| 34 | #include "common/network.h" |
| 35 | #include "d2ladder.h" |
| 36 | #include "prefs.h" |
| 37 | #include "charlock.h" |
| 38 | #include "dbspacket.h" |
| 39 | #include "handle_signal.h" |
| 40 | |
| 41 | #ifdef HAVE_ARPA_INET_H |
| 42 | # include <arpa/inet.h> |
| 43 | #endif |
| 44 | #ifdef HAVE_WS2TCPIP_H |
| 45 | # include <Ws2tcpip.h> |
| 46 | #endif |
| 47 | |
| 48 | #include "common/setup_after.h" |
| 49 | |
| 50 | #ifdef WIN32 |
| 51 | extern int g_ServiceStatus; |
| 52 | #endif |
| 53 | |
| 54 | namespace pvpgn |
| 55 | { |
| 56 | |
| 57 | namespace d2dbs |
| 58 | { |
| 59 | |
| 60 | static int dbs_packet_gs_id = 0; |
| 61 | static t_preset_d2gsid *preset_d2gsid_head = NULL; |
| 62 | t_list * dbs_server_connection_list = NULL; |
| 63 | int dbs_server_listen_socket = -1; |
| 64 | |
| 65 | /* dbs_server_main |
| 66 | * The module's driver function -- we just call other functions and |
| 67 | * interpret their results. |
| 68 | */ |
| 69 | |
| 70 | static int dbs_handle_timed_events(void); |
| 71 | static void dbs_on_exit(void); |
| 72 | |
| 73 | int dbs_server_init(void); |
| 74 | void dbs_server_loop(int ListeningSocket); |
| 75 | int dbs_server_setup_fdsets(fd_set * pReadFDs, fd_set * pWriteFDs, |
| 76 | fd_set * pExceptFDs, int ListeningSocket); |
| 77 | bool dbs_server_read_data(t_d2dbs_connection* conn); |
| 78 | bool dbs_server_write_data(t_d2dbs_connection* conn); |
| 79 | int dbs_server_list_add_socket(int sd, unsigned int ipaddr); |
| 80 | static int setsockopt_keepalive(int sock); |
| 81 | static unsigned int get_preset_d2gsid(unsigned int ipaddr); |
| 82 | |
| 83 | |
| 84 | int dbs_server_main(void) |
| 85 | { |
| 86 | eventlog(eventlog_level_info, __FUNCTION__, "establishing the listener..."); |
| 87 | dbs_server_listen_socket = dbs_server_init(); |
| 88 | if (dbs_server_listen_socket < 0) { |
| 89 | eventlog(eventlog_level_error, __FUNCTION__, "dbs_server_init error "); |
| 90 | return 3; |
| 91 | } |
| 92 | eventlog(eventlog_level_info, __FUNCTION__, "waiting for connections..."); |
| 93 | dbs_server_loop(dbs_server_listen_socket); |
| 94 | dbs_on_exit(); |
| 95 | return 0; |
| 96 | } |
| 97 | |
| 98 | /* dbs_server_init |
| 99 | * Sets up a listener on the given interface and port, returning the |
| 100 | * listening socket if successful; if not, returns -1. |
| 101 | */ |
| 102 | /* FIXME: No it doesn't! pcAddress is not ever referenced in this |
| 103 | * function. |
| 104 | * CreepLord: Fixed much better way (will accept dns hostnames) |
| 105 | */ |
| 106 | int dbs_server_init(void) |
| 107 | { |
| 108 | int sd; |
| 109 | struct sockaddr_in sinInterface; |
| 110 | int val; |
| 111 | t_addr * servaddr; |
| 112 | |
| 113 | dbs_server_connection_list = list_create(); |
| 114 | |
| 115 | if (d2dbs_d2ladder_init() == -1) |
| 116 | { |
| 117 | eventlog(eventlog_level_error, __FUNCTION__, "d2ladder_init() failed"); |
| 118 | return -1; |
| 119 | } |
| 120 | |
| 121 | if (cl_init(DEFAULT_HASHTBL_LEN, DEFAULT_GS_MAX) == -1) |
| 122 | { |
| 123 | eventlog(eventlog_level_error, __FUNCTION__, "cl_init() failed"); |
| 124 | return -1; |
| 125 | } |
| 126 | |
| 127 | if (psock_init() < 0) |
| 128 | { |
| 129 | eventlog(eventlog_level_error, __FUNCTION__, "psock_init() failed"); |
| 130 | return -1; |
| 131 | } |
| 132 | |
| 133 | sd = psock_socket(PSOCK_PF_INET, PSOCK_SOCK_STREAM, PSOCK_IPPROTO_TCP); |
| 134 | if (sd == -1) |
| 135 | { |
| 136 | eventlog(eventlog_level_error, __FUNCTION__, "psock_socket() failed : {}", pstrerror(psock_errno())); |
| 137 | return -1; |
| 138 | } |
| 139 | |
| 140 | val = 1; |
| 141 | if (psock_setsockopt(sd, PSOCK_SOL_SOCKET, PSOCK_SO_REUSEADDR, &val, sizeof(val)) < 0) |
| 142 | { |
| 143 | eventlog(eventlog_level_error, __FUNCTION__, "psock_setsockopt() failed : {}", pstrerror(psock_errno())); |
| 144 | } |
| 145 | |
| 146 | if (!(servaddr = addr_create_str(d2dbs_prefs_get_servaddrs(), INADDR_ANY, DEFAULT_LISTEN_PORT))) |
| 147 | { |
| 148 | eventlog(eventlog_level_error, __FUNCTION__, "could not get servaddr"); |
| 149 | return -1; |
| 150 | } |
| 151 | |
| 152 | sinInterface.sin_family = PSOCK_AF_INET; |
| 153 | sinInterface.sin_addr.s_addr = htonl(addr_get_ip(servaddr)); |
| 154 | sinInterface.sin_port = htons(addr_get_port(servaddr)); |
| 155 | if (psock_bind(sd, (struct sockaddr*)&sinInterface, (psock_t_socklen)sizeof(struct sockaddr_in)) < 0) |
| 156 | { |
| 157 | eventlog(eventlog_level_error, __FUNCTION__, "psock_bind() failed : {}", pstrerror(psock_errno())); |
| 158 | return -1; |
| 159 | } |
| 160 | if (psock_listen(sd, LISTEN_QUEUE) < 0) |
| 161 | { |
| 162 | eventlog(eventlog_level_error, __FUNCTION__, "psock_listen() failed : {}", pstrerror(psock_errno())); |
| 163 | return -1; |
| 164 | } |
| 165 | addr_destroy(servaddr); |
| 166 | return sd; |
| 167 | } |
| 168 | |
| 169 | |
| 170 | /* dbs_server_setup_fdsets |
| 171 | * Set up the three FD sets used with select() with the sockets in the |
| 172 | * connection list. Also add one for the listener socket, if we have |
| 173 | * one. |
| 174 | */ |
| 175 | |
| 176 | int dbs_server_setup_fdsets(t_psock_fd_set * pReadFDs, t_psock_fd_set * pWriteFDs, t_psock_fd_set * pExceptFDs, int lsocket) |
| 177 | { |
| 178 | t_elem const * elem; |
| 179 | t_d2dbs_connection* it; |
| 180 | int highest_fd; |
| 181 | |
| 182 | PSOCK_FD_ZERO(pReadFDs); |
| 183 | PSOCK_FD_ZERO(pWriteFDs); |
| 184 | PSOCK_FD_ZERO(pExceptFDs); /* FIXME: don't check these... remove this code */ |
| 185 | /* Add the listener socket to the read and except FD sets, if there is one. */ |
| 186 | if (lsocket >= 0) { |
| 187 | PSOCK_FD_SET(lsocket, pReadFDs); |
| 188 | PSOCK_FD_SET(lsocket, pExceptFDs); |
| 189 | } |
| 190 | highest_fd = lsocket; |
| 191 | |
| 192 | LIST_TRAVERSE_CONST(dbs_server_connection_list, elem) |
| 193 | { |
| 194 | if (!(it = (t_d2dbs_connection*)elem_get_data(elem))) continue; |
| 195 | if (it->nCharsInReadBuffer < (kBufferSize - kMaxPacketLength)) { |
| 196 | /* There's space in the read buffer, so pay attention to incoming data. */ |
| 197 | PSOCK_FD_SET(it->sd, pReadFDs); |
| 198 | } |
| 199 | if (it->nCharsInWriteBuffer > 0) { |
| 200 | PSOCK_FD_SET(it->sd, pWriteFDs); |
| 201 | } |
| 202 | PSOCK_FD_SET(it->sd, pExceptFDs); |
| 203 | if (highest_fd < it->sd) highest_fd = it->sd; |
| 204 | } |
| 205 | return highest_fd; |
| 206 | } |
| 207 | |
| 208 | /* dbs_server_read_data |
| 209 | * Data came in on a client socket, so read it into the buffer. Returns |
| 210 | * false on failure, or when the client closes its half of the |
| 211 | * connection. (EAGAIN doesn't count as a failure.) |
| 212 | */ |
| 213 | bool dbs_server_read_data(t_d2dbs_connection* conn) |
| 214 | { |
| 215 | int nBytes; |
| 216 | |
| 217 | nBytes = net_recv(conn->sd, conn->ReadBuf + conn->nCharsInReadBuffer, |
| 218 | kBufferSize - conn->nCharsInReadBuffer); |
| 219 | |
| 220 | if (nBytes < 0) return false; |
| 221 | conn->nCharsInReadBuffer += nBytes; |
| 222 | return true; |
| 223 | } |
| 224 | |
| 225 | |
| 226 | /* dbs_server_write_data |
| 227 | * The connection is writable, so send any pending data. Returns |
| 228 | * false on failure. (EAGAIN doesn't count as a failure.) |
| 229 | */ |
| 230 | bool dbs_server_write_data(t_d2dbs_connection* conn) |
| 231 | { |
| 232 | int nBytes; |
| 233 | |
| 234 | nBytes = net_send(conn->sd, conn->WriteBuf, |
| 235 | conn->nCharsInWriteBuffer > kMaxPacketLength ? kMaxPacketLength : conn->nCharsInWriteBuffer); |
| 236 | |
| 237 | if (nBytes < 0) return false; |
| 238 | |
| 239 | conn->nCharsInWriteBuffer -= nBytes; |
| 240 | if (conn->nCharsInWriteBuffer) |
| 241 | std::memmove(conn->WriteBuf, conn->WriteBuf + nBytes, conn->nCharsInWriteBuffer); |
| 242 | |
| 243 | return true; |
| 244 | } |
| 245 | |
| 246 | int dbs_server_list_add_socket(int sd, unsigned int ipaddr) |
| 247 | { |
| 248 | t_d2dbs_connection *it; |
| 249 | struct in_addr in; |
| 250 | |
| 251 | it = (t_d2dbs_connection*)xmalloc(sizeof(t_d2dbs_connection)); |
| 252 | std::memset(it, 0, sizeof(t_d2dbs_connection)); |
| 253 | it->sd = sd; |
| 254 | it->ipaddr = ipaddr; |
| 255 | it->major = 0; |
| 256 | it->minor = 0; |
| 257 | it->type = 0; |
| 258 | it->stats = 0; |
| 259 | it->verified = 0; |
| 260 | it->serverid = get_preset_d2gsid(ipaddr); |
| 261 | it->last_active = std::time(NULL); |
| 262 | it->nCharsInReadBuffer = 0; |
| 263 | it->nCharsInWriteBuffer = 0; |
| 264 | list_append_data(dbs_server_connection_list, it); |
| 265 | in.s_addr = htonl(ipaddr); |
| 266 | char addrstr[INET_ADDRSTRLEN] = { 0 }; |
| 267 | inet_ntop(AF_INET, &(in), addrstr, sizeof(addrstr)); |
| 268 | std::strncpy((char*)it->serverip, addrstr, sizeof(it->serverip) - 1); |
| 269 | |
| 270 | return 1; |
| 271 | } |
| 272 | |
| 273 | static int dbs_handle_timed_events(void) |
| 274 | { |
| 275 | static std::time_t prev_ladder_save_time = 0; |
| 276 | static std::time_t prev_keepalive_save_time = 0; |
| 277 | static std::time_t prev_timeout_checktime = 0; |
| 278 | std::time_t now; |
| 279 | |
| 280 | now = std::time(NULL); |
| 281 | if (now - prev_ladder_save_time > (signed)prefs_get_laddersave_interval()) { |
| 282 | d2ladder_saveladder(); |
| 283 | prev_ladder_save_time = now; |
| 284 | } |
| 285 | if (now - prev_keepalive_save_time > (signed)prefs_get_keepalive_interval()) { |
| 286 | dbs_keepalive(); |
| 287 | prev_keepalive_save_time = now; |
| 288 | } |
| 289 | if (now - prev_timeout_checktime > (signed)d2dbs_prefs_get_timeout_checkinterval()) { |
| 290 | dbs_check_timeout(); |
| 291 | prev_timeout_checktime = now; |
| 292 | } |
| 293 | return 0; |
| 294 | } |
| 295 | |
| 296 | void dbs_server_loop(int lsocket) |
| 297 | { |
| 298 | struct sockaddr_in sinRemote; |
| 299 | int sd; |
| 300 | fd_set ReadFDs, WriteFDs, ExceptFDs; |
| 301 | t_elem * elem; |
| 302 | t_d2dbs_connection* it; |
| 303 | bool bOK; |
| 304 | const char* pcErrorType; |
| 305 | struct timeval tv; |
| 306 | int highest_fd; |
| 307 | psock_t_socklen nAddrSize = sizeof(sinRemote); |
| 308 | |
| 309 | while (1) { |
| 310 | |
| 311 | #ifdef WIN32 |
| 312 | if (g_ServiceStatus < 0 && kbhit() && getch() == 'q') |
| 313 | d2dbs_signal_quit_wrapper(); |
| 314 | if (g_ServiceStatus == 0) d2dbs_signal_quit_wrapper(); |
| 315 | |
| 316 | while (g_ServiceStatus == 2) Sleep(1000); |
| 317 | #endif |
| 318 | |
| 319 | if (d2dbs_handle_signal() < 0) break; |
| 320 | |
| 321 | dbs_handle_timed_events(); |
| 322 | highest_fd = dbs_server_setup_fdsets(&ReadFDs, &WriteFDs, &ExceptFDs, lsocket); |
| 323 | |
| 324 | tv.tv_sec = 0; |
| 325 | tv.tv_usec = SELECT_TIME_OUT; |
| 326 | switch (psock_select(highest_fd + 1, &ReadFDs, &WriteFDs, &ExceptFDs, &tv)) { |
| 327 | case -1: |
| 328 | eventlog(eventlog_level_error, __FUNCTION__, "psock_select() failed : {}", pstrerror(psock_errno())); |
| 329 | continue; |
| 330 | case 0: |
| 331 | continue; |
| 332 | default: |
| 333 | break; |
| 334 | } |
| 335 | |
| 336 | if (PSOCK_FD_ISSET(lsocket, &ReadFDs)) { |
| 337 | sd = psock_accept(lsocket, (struct sockaddr*)&sinRemote, &nAddrSize); |
| 338 | if (sd == -1) { |
| 339 | eventlog(eventlog_level_error, __FUNCTION__, "psock_accept() failed : {}", pstrerror(psock_errno())); |
| 340 | return; |
| 341 | } |
| 342 | |
| 343 | char addrstr[INET_ADDRSTRLEN] = { 0 }; |
| 344 | inet_ntop(AF_INET, &(sinRemote.sin_addr), addrstr, sizeof(addrstr)); |
| 345 | eventlog(eventlog_level_info, __FUNCTION__, "accepted connection from {}:{} , socket {} .", |
| 346 | addrstr, ntohs(sinRemote.sin_port), sd); |
| 347 | eventlog_step(prefs_get_logfile_gs(), eventlog_level_info, __FUNCTION__, "accepted connection from %s:%d , socket %d .", |
| 348 | addrstr, ntohs(sinRemote.sin_port), sd); |
| 349 | setsockopt_keepalive(sd); |
| 350 | dbs_server_list_add_socket(sd, ntohl(sinRemote.sin_addr.s_addr)); |
| 351 | if (psock_ctl(sd, PSOCK_NONBLOCK) < 0) { |
| 352 | eventlog(eventlog_level_error, __FUNCTION__, "could not set TCP socket [{}] to non-blocking mode (closing connection) (psock_ctl: {})", sd, pstrerror(psock_errno())); |
| 353 | psock_close(sd); |
| 354 | } |
| 355 | } |
| 356 | else if (PSOCK_FD_ISSET(lsocket, &ExceptFDs)) { |
| 357 | eventlog(eventlog_level_error, __FUNCTION__, "exception on listening socket"); |
| 358 | /* FIXME: exceptions are not errors with TCP, they are out-of-band data */ |
| 359 | return; |
| 360 | } |
| 361 | |
| 362 | LIST_TRAVERSE(dbs_server_connection_list, elem) |
| 363 | { |
| 364 | bOK = true; |
| 365 | pcErrorType = 0; |
| 366 | |
| 367 | if (!(it = (t_d2dbs_connection*)elem_get_data(elem))) continue; |
| 368 | if (PSOCK_FD_ISSET(it->sd, &ExceptFDs)) { |
| 369 | bOK = false; |
| 370 | pcErrorType = "General socket error"; /* FIXME: no no no no no */ |
| 371 | PSOCK_FD_CLR(it->sd, &ExceptFDs); |
| 372 | } |
| 373 | else { |
| 374 | |
| 375 | if (PSOCK_FD_ISSET(it->sd, &ReadFDs)) { |
| 376 | bOK = dbs_server_read_data(it); |
| 377 | pcErrorType = "Read error"; |
| 378 | PSOCK_FD_CLR(it->sd, &ReadFDs); |
| 379 | } |
| 380 | |
| 381 | if (PSOCK_FD_ISSET(it->sd, &WriteFDs)) { |
| 382 | bOK = dbs_server_write_data(it); |
| 383 | pcErrorType = "Write error"; |
| 384 | PSOCK_FD_CLR(it->sd, &WriteFDs); |
| 385 | } |
| 386 | } |
| 387 | |
| 388 | if (!bOK) { |
| 389 | int err, errno2; |
| 390 | psock_t_socklen errlen; |
| 391 | |
| 392 | err = 0; |
| 393 | errlen = sizeof(err); |
| 394 | errno2 = psock_errno(); |
| 395 | |
| 396 | if (psock_getsockopt(it->sd, PSOCK_SOL_SOCKET, PSOCK_SO_ERROR, &err, &errlen) == 0) { |
| 397 | if (errlen && err != 0) { |
| 398 | err = err ? err : errno2; |
| 399 | eventlog(eventlog_level_error, __FUNCTION__, "data socket error : {}({})", pstrerror(err), err); |
| 400 | } |
| 401 | } |
| 402 | dbs_server_shutdown_connection(it); |
| 403 | list_remove_elem(dbs_server_connection_list, &elem); |
| 404 | } |
| 405 | else { |
| 406 | if (dbs_packet_handle(it) == -1) { |
| 407 | eventlog(eventlog_level_error, __FUNCTION__, "dbs_packet_handle() failed"); |
| 408 | dbs_server_shutdown_connection(it); |
| 409 | list_remove_elem(dbs_server_connection_list, &elem); |
| 410 | } |
| 411 | } |
| 412 | } |
| 413 | } |
| 414 | } |
| 415 | |
| 416 | static void dbs_on_exit(void) |
| 417 | { |
| 418 | t_elem * elem; |
| 419 | t_d2dbs_connection * it; |
| 420 | |
| 421 | if (dbs_server_listen_socket >= 0) |
| 422 | psock_close(dbs_server_listen_socket); |
| 423 | dbs_server_listen_socket = -1; |
| 424 | |
| 425 | LIST_TRAVERSE(dbs_server_connection_list, elem) |
| 426 | { |
| 427 | if (!(it = (t_d2dbs_connection*)elem_get_data(elem))) continue; |
| 428 | dbs_server_shutdown_connection(it); |
| 429 | list_remove_elem(dbs_server_connection_list, &elem); |
| 430 | } |
| 431 | cl_destroy(); |
| 432 | d2dbs_d2ladder_destroy(); |
| 433 | list_destroy(dbs_server_connection_list); |
| 434 | if (preset_d2gsid_head) |
| 435 | { |
| 436 | t_preset_d2gsid * curr; |
| 437 | t_preset_d2gsid * next; |
| 438 | |
| 439 | for (curr = preset_d2gsid_head; curr; curr = next) |
| 440 | { |
| 441 | next = curr->next; |
| 442 | xfree(curr); |
| 443 | } |
| 444 | } |
| 445 | eventlog(eventlog_level_info, __FUNCTION__, "dbserver stopped"); |
| 446 | } |
| 447 | |
| 448 | int dbs_server_shutdown_connection(t_d2dbs_connection* conn) |
| 449 | { |
| 450 | psock_shutdown(conn->sd, PSOCK_SHUT_RDWR); |
| 451 | psock_close(conn->sd); |
| 452 | if (conn->verified && conn->type == CONNECT_CLASS_D2GS_TO_D2DBS) { |
| 453 | eventlog(eventlog_level_info, __FUNCTION__, "unlock all characters on gs {}({})", conn->serverip, conn->serverid); |
| 454 | eventlog_step(prefs_get_logfile_gs(), eventlog_level_info, __FUNCTION__, "unlock all characters on gs %s(%d)", conn->serverip, conn->serverid); |
| 455 | eventlog_step(prefs_get_logfile_gs(), eventlog_level_info, __FUNCTION__, "close connection to gs on socket %d", conn->sd); |
| 456 | cl_unlock_all_char_by_gsid(conn->serverid); |
| 457 | } |
| 458 | xfree(conn); |
| 459 | return 1; |
| 460 | } |
| 461 | |
| 462 | static int setsockopt_keepalive(int sock) |
| 463 | { |
| 464 | int optval; |
| 465 | psock_t_socklen optlen; |
| 466 | |
| 467 | optval = 1; |
| 468 | optlen = sizeof(optval); |
| 469 | if (psock_setsockopt(sock, PSOCK_SOL_SOCKET, PSOCK_SO_KEEPALIVE, &optval, optlen)) { |
| 470 | eventlog(eventlog_level_info, __FUNCTION__, "failed set KEEPALIVE for socket {}, errno={}", sock, psock_errno()); |
| 471 | return -1; |
| 472 | } |
| 473 | else { |
| 474 | eventlog(eventlog_level_info, __FUNCTION__, "set KEEPALIVE option for socket {}", sock); |
| 475 | return 0; |
| 476 | } |
| 477 | } |
| 478 | |
| 479 | static unsigned int get_preset_d2gsid(unsigned int ipaddr) |
| 480 | { |
| 481 | t_preset_d2gsid *pgsid; |
| 482 | |
| 483 | pgsid = preset_d2gsid_head; |
| 484 | while (pgsid) |
| 485 | { |
| 486 | if (pgsid->ipaddr == ipaddr) |
| 487 | return pgsid->d2gsid; |
| 488 | pgsid = pgsid->next; |
| 489 | } |
| 490 | /* not found, build a new item */ |
| 491 | pgsid = (t_preset_d2gsid*)xmalloc(sizeof(t_preset_d2gsid)); |
| 492 | pgsid->ipaddr = ipaddr; |
| 493 | pgsid->d2gsid = ++dbs_packet_gs_id; |
| 494 | /* add to list */ |
| 495 | pgsid->next = preset_d2gsid_head; |
| 496 | preset_d2gsid_head = pgsid; |
| 497 | return preset_d2gsid_head->d2gsid; |
| 498 | } |
| 499 | |
| 500 | } |
| 501 | |
| 502 | } |