|
jabberd14
1.6.2
|
00001 /* 00002 * Copyrights 00003 * 00004 * Portions created by or assigned to Jabber.com, Inc. are 00005 * Copyright (c) 1999-2002 Jabber.com, Inc. All Rights Reserved. Contact 00006 * information for Jabber.com, Inc. is available at http://www.jabber.com/. 00007 * 00008 * Portions Copyright (c) 1998-1999 Jeremie Miller. 00009 * 00010 * Portions Copyright (c) 2006-2007 Matthias Wimmer 00011 * 00012 * This file is part of jabberd14. 00013 * 00014 * This software is free software; you can redistribute it and/or 00015 * modify it under the terms of the GNU General Public License as 00016 * published by the Free Software Foundation; either version 2 of the 00017 * License, or (at your option) any later version. 00018 * 00019 * This software is distributed in the hope that it will be useful, but 00020 * WITHOUT ANY WARRANTY; without even the implied warranty of 00021 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00022 * General Public License for more details. 00023 * 00024 * You should have received a copy of the GNU General Public License 00025 * along with this software; if not, write to the Free Software 00026 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 00027 * 02110-1301, USA. 00028 * 00029 */ 00030 00031 #include "jabberd.h" 00032 00152 #define SESSION_WAITERS 10 00153 00154 #define HOSTS_PRIME 17 00155 #define USERS_PRIME 3001 00158 typedef int event; 00159 00167 #define e_SESSION 0 00168 00177 #define e_OFFLINE 1 00178 00191 #define e_SERVER 2 00192 00207 #define e_DELIVER 3 00208 00222 #define e_SHUTDOWN 4 00223 00248 #define e_AUTH 5 00249 00262 #define e_REGISTER 6 00263 00276 #define e_CREATE 7 00277 00288 #define e_DELETE 8 00289 00301 #define e_DESERIALIZE 9 00302 00316 #define e_PRE_REGISTER 10 00317 00330 #define e_PASSWORDCHANGE 11 00331 00340 #define e_FILTER_IN 12 00341 00349 #define e_FILTER_OUT 13 00350 00358 #define e_ROSTERCHANGE 14 00359 00360 /* always add new event types here, to maintain backwards binary compatibility */ 00361 #define e_LAST 15 00363 /* session event types */ 00364 00377 #define es_IN 0 00378 00391 #define es_OUT 1 00392 00403 #define es_END 2 00404 00416 #define es_SERIALIZE 3 00417 00432 #define es_FILTER_IN 4 00433 00448 #define es_FILTER_OUT 5 00449 00450 /* always add new event types here, to maintain backwards binary compatibility */ 00451 #define es_LAST 6 00453 /* admin user account flags */ 00454 #define ADMIN_MOTD "motd" 00455 #define ADMIN_LISTSESSIONS "listsessions" 00456 #define ADMIN_ADMINMSG "adminmsg" 00457 #define ADMIN_SHOWPRES "showpres" 00458 #define ADMIN_DYNAMIC "dynamic" 00461 typedef enum { 00462 M_PASS, 00463 M_IGNORE, 00464 M_HANDLED 00465 } mreturn; 00466 00467 typedef struct udata_struct *udata, 00468 _udata; 00469 typedef struct session_struct *session, 00470 _session; 00471 typedef struct jsmi_struct *jsmi, 00472 _jsmi; 00475 typedef struct mapi_struct { 00476 jsmi si; 00477 jpacket packet; 00478 event e; 00479 udata user; 00480 session s; 00481 xmlnode serialization_node; 00482 jpacket additional_result; 00483 } *mapi, _mapi; 00484 00486 typedef mreturn (*mcall)(mapi m, void *arg); 00487 00489 typedef struct mlist_struct 00490 { 00491 mcall c; 00492 void *arg; 00493 unsigned char mask; 00494 struct mlist_struct *next; 00495 } *mlist, _mlist; 00496 00498 struct history_storage_conf { 00499 int general:1; 00500 int offline:1; 00501 int special:1; 00502 }; 00503 00505 struct jsmi_struct { 00506 instance i; 00507 /* xmlnode config; */ 00508 xht hosts; 00509 xht sc_sessions; 00510 xht std_namespace_prefixes; 00511 xdbcache xc; 00512 mlist events[e_LAST]; 00513 pool p; 00514 struct history_storage_conf history_sent; 00515 struct history_storage_conf history_recv; 00516 char *statefile; 00517 char *auth; 00518 }; 00519 00521 struct udata_struct 00522 { 00523 jid id; 00524 jid utrust; 00525 jid useen; 00526 jsmi si; 00527 session sessions; 00528 int ref; 00529 pool p; 00530 xht aux_data; 00531 }; 00532 00533 xmlnode js_config(jsmi si, const char* query, const char* lang); 00534 00535 udata js_user(jsmi si, jid id, xht ht); 00536 int js_user_create(jsmi si, jid id); 00537 int js_user_delete(jsmi si, jid id); 00538 void js_deliver(jsmi si, jpacket p, session sending_s); 00539 00540 00542 struct session_struct { 00543 /* general session data */ 00544 jsmi si; 00545 char *res; 00546 jid id; 00547 udata u; 00548 xmlnode presence; 00549 int priority; 00550 int roster; 00551 int c_in; 00552 int c_out; 00553 time_t started; 00555 /* mechanics */ 00556 pool p; 00557 int exit_flag; 00558 mlist events[es_LAST]; 00559 mtq q; 00561 /* our routed id, and remote session id */ 00562 jid route; 00563 jid sid; 00564 char *sc_c2s; 00565 char *sc_sm; 00567 xht aux_data; 00569 struct session_struct *next; 00570 }; 00571 00573 #define PACKET_FROM_OFFLINE_MAGIC 1768189505 00574 00576 #define PACKET_FORCE_SENT_MAGIC 1836017748 00577 00579 #define PACKET_PASS_FILTERS_MAGIC 20060704 00580 00581 session js_session_new(jsmi si, dpacket p); 00582 session js_sc_session_new(jsmi si, dpacket p, xmlnode sc_session); 00583 void js_session_end(session s, char *reason); 00584 session js_session_get(udata user, char const* res); 00585 session js_session_primary(udata user); 00586 void js_session_to(session s, jpacket p); 00587 void js_session_from(session s, jpacket p); 00588 void js_session_free_aux_data(void* arg); 00589 00590 void js_server_main(void *arg); 00591 void js_offline_main(void *arg); 00592 result js_users_gc(void *arg); 00593 00595 typedef struct jpq_struct { 00596 jsmi si; 00597 jpacket p; 00598 } _jpq, *jpq; 00599 00600 void js_psend(jsmi si, jpacket p, mtq_callback f); /* sends p to a function */ 00601 00602 void js_bounce_xmpp(jsmi si, session s, xmlnode x, xterror xterr); /* logic to bounce packets w/o looping, eats x and delivers error */ 00603 00604 void js_mapi_register(jsmi si, event e, mcall c, void *arg); 00605 void js_mapi_session(event e, session s, mcall c, void *arg); 00606 int js_mapi_call(jsmi si, event e, jpacket packet, udata user, session s); 00607 int js_mapi_call2(jsmi si, event e, jpacket packet, udata user, session s, xmlnode serialization_node); 00608 void js_mapi_create_additional_iq_result(mapi m, const char* name, const char *prefix, const char *ns_iri); 00609 00610 void js_authreg(void *arg); 00611 00612 /* we have acl.c now 00613 int js_admin(udata u, int flag); 00614 */ 00615 00616 result js_packet(instance i, dpacket p, void *arg); 00617 int js_islocal(jsmi si, jid id); 00618 int js_trust(udata u, jid id); /* checks if id is trusted by user u */ 00619 jid js_trustees(udata u); /* returns list of trusted jids */ 00620 jid js_seen_jids(udata u); /* returns list of trusted jids */ 00621 void js_remove_trustee(udata u, jid id); /* removes a user from the list of trustees */ 00622 int js_seen(udata u, jid id); /* checks if a ID is seen by user u */ 00623 void js_remove_seen(udata u, jid id); /* removes a user from the list of seen JIDs */ 00624 int js_online(mapi m); /* logic to tell if this is a go-online call */ 00625 00626 void jsm_shutdown(void *arg); 00627 00628 void jsm_serialize(jsmi si); 00629 void jsm_deserialize(jsmi si, const char *host);
1.7.6.1