Ignore:
Timestamp:
Oct 10, 2003, 5:12:30 PM (21 years ago)
Author:
James M. Kretchmar <kretch@mit.edu>
Branches:
master, barnowl_perlaim, debian, owl, release-1.10, release-1.4, release-1.5, release-1.6, release-1.7, release-1.8, release-1.9
Children:
fe6f1d3
Parents:
f4d0975
Message:
*** empty log message ***
File:
1 edited

Legend:

Unmodified
Added
Removed
  • libfaim/rxhandlers.c

    r862371b re374dee  
    1515        fu16_t type;
    1616        aim_rxcallback_t handler;
    17         u_short flags;
     17        fu16_t flags;
    1818        struct aim_rxcblist_s *next;
    1919};
     
    108108        snac.flags = aimbs_get16(&rx->data);
    109109        snac.id = aimbs_get32(&rx->data);
     110
     111        /* SNAC flags are apparently uniform across all SNACs, so we handle them here */
     112        if (snac.flags & 0x0001) {
     113                /*
     114                 * This means the SNAC will be followed by another SNAC with
     115                 * related information.  We don't need to do anything about
     116                 * this here.
     117                 */
     118        }
     119        if (snac.flags & 0x8000) {
     120                /*
     121                 * This packet contains the version of the family that this SNAC is
     122                 * in.  You get this when your SSI module is version 2 or higher. 
     123                 * For now we have no need for this, but you could always save
     124                 * it as a part of aim_modnsac_t, or something.  The format is...
     125                 * 2 byte length of total mini-header (which is 6 bytes), then TLV
     126                 * of  type 0x0001, length 0x0002, value is the 2 byte version
     127                 * number
     128                 */
     129                aim_bstream_advance(&rx->data, aimbs_get16(&rx->data));
     130        }
    110131
    111132        for (cur = (aim_module_t *)sess->modlistv; cur; cur = cur->next) {
     
    371392}
    372393
    373 /*
    374  * Some SNACs we do not allow to be hooked, for good reason.
    375  */
    376 static int checkdisallowed(fu16_t group, fu16_t type)
    377 {
    378         static const struct {
    379                 fu16_t group;
    380                 fu16_t type;
    381         } dontuse[] = {
    382                 {0x0001, 0x0002},
    383                 {0x0001, 0x0003},
    384                 {0x0001, 0x0006},
    385                 {0x0001, 0x0007},
    386                 {0x0001, 0x0008},
    387                 {0x0001, 0x0017},
    388                 {0x0001, 0x0018},
    389                 {0x0000, 0x0000}
    390         };
    391         int i;
    392 
    393         for (i = 0; dontuse[i].group != 0x0000; i++) {
    394                 if ((dontuse[i].group == group) && (dontuse[i].type == type))
    395                         return 1;
    396         }
    397 
    398         return 0;
    399 }
    400 
    401394faim_export int aim_conn_addhandler(aim_session_t *sess, aim_conn_t *conn, fu16_t family, fu16_t type, aim_rxcallback_t newhandler, fu16_t flags)
    402395{
     
    407400
    408401        faimdprintf(sess, 1, "aim_conn_addhandler: adding for %04x/%04x\n", family, type);
    409 
    410         if (checkdisallowed(family, type)) {
    411                 faimdprintf(sess, 0, "aim_conn_addhandler: client tried to hook %x/%x -- BUG!!!\n", family, type);
    412                 return -1;
    413         }
    414402
    415403        if (!(newcb = (struct aim_rxcblist_s *)calloc(1, sizeof(struct aim_rxcblist_s))))
     
    529517                        continue;
    530518
    531                 /*
    532                  * This is a debugging/sanity check only and probably
    533                  * could/should be removed for stable code.
    534                  */
    535                 if (((cur->hdrtype == AIM_FRAMETYPE_OFT) &&
    536                    (cur->conn->type != AIM_CONN_TYPE_RENDEZVOUS)) ||
    537                   ((cur->hdrtype == AIM_FRAMETYPE_FLAP) &&
    538                    (cur->conn->type == AIM_CONN_TYPE_RENDEZVOUS))) {
    539                         faimdprintf(sess, 0, "rxhandlers: incompatible frame type %d on connection type 0x%04x\n", cur->hdrtype, cur->conn->type);
    540                         cur->handled = 1;
    541                         continue;
    542                 }
    543 
    544                 if (cur->conn->type == AIM_CONN_TYPE_RENDEZVOUS) {
    545                         if (cur->hdrtype != AIM_FRAMETYPE_OFT) {
    546                                 faimdprintf(sess, 0, "internal error: non-OFT frames on OFT connection\n");
    547                                 cur->handled = 1; /* get rid of it */
    548                         } else {
     519                if (cur->hdrtype == AIM_FRAMETYPE_FLAP) {
     520                        if (cur->hdr.flap.type == 0x01) {
     521                                cur->handled = aim_callhandler_noparam(sess, cur->conn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_FLAPVER, cur); /* XXX use consumenonsnac */
     522                                continue;
     523
     524                        } else if (cur->hdr.flap.type == 0x02) {
     525                                if ((cur->handled = consumesnac(sess, cur)))
     526                                        continue;
     527
     528                        } else if (cur->hdr.flap.type == 0x04) {
     529                                cur->handled = negchan_middle(sess, cur);
     530                                continue;
     531
     532                        } else if (cur->hdr.flap.type == 0x05) {
     533
     534                        }
     535
     536                } else if (cur->hdrtype == AIM_FRAMETYPE_OFT) {
     537                        if (cur->conn->type == AIM_CONN_TYPE_RENDEZVOUS) {
    549538                                aim_rxdispatch_rendezvous(sess, cur);
    550539                                cur->handled = 1;
     540                                continue;
     541
     542                        } else if (cur->conn->type == AIM_CONN_TYPE_LISTENER) {
     543                                /* not possible */
     544                                faimdprintf(sess, 0, "rxdispatch called on LISTENER connection!\n");
     545                                cur->handled = 1;
     546                                continue;
    551547                        }
    552                         continue;
    553548                }
    554549
    555                 if (cur->conn->type == AIM_CONN_TYPE_RENDEZVOUS_OUT) {
    556                         /* not possible */
    557                         faimdprintf(sess, 0, "rxdispatch called on RENDEZVOUS_OUT connection!\n");
    558                         cur->handled = 1;
    559                         continue;
    560                 }
    561 
    562                 if (cur->hdr.flap.type == 0x01) {
    563                        
    564                         cur->handled = aim_callhandler_noparam(sess, cur->conn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_FLAPVER, cur); /* XXX use consumenonsnac */
    565                        
    566                         continue;
    567                        
    568                 } else if (cur->hdr.flap.type == 0x02) {
    569 
    570                         if ((cur->handled = consumesnac(sess, cur)))
    571                                 continue;
    572 
    573                 } else if (cur->hdr.flap.type == 0x04) {
    574 
    575                         cur->handled = negchan_middle(sess, cur);
    576                         continue;
    577 
    578                 } else if (cur->hdr.flap.type == 0x05)
    579                         ;
    580                
    581550                if (!cur->handled) {
    582551                        consumenonsnac(sess, cur, 0xffff, 0xffff); /* last chance! */
Note: See TracChangeset for help on using the changeset viewer.