📄 dsmcc-biop.c
字号:
voidBiop::ProcessBiopData(Cache *cache, struct cache_module_data *cachep) { struct biop_message bm; struct descriptor *desc; int ret; unsigned int len;// bd_fd = fopen("/tmp/biop_data", "a"); for(desc = cachep->descriptors; desc != NULL; desc=desc->next) { if(desc->tag == 0x09) { break; } } if(desc != NULL) { len = desc->data.compressed.original_size; } else { len = cachep->size; } cachep->curp = 0;// fprintf(bd_fd, "Full Length - %d\n", len); /* Replace off with cachep->curp.... */ while(cachep->curp < len) {// fprintf(bd_fd, "Current %ld / Full %d\n", cachep->curp, len);// fprintf(bd_fd, "Processing header\n"); /* Parse header */ ret = ProcessBiopMsgHdr(&bm, cachep); if(ret < 0) { /* not valid, skip rest of data */ break; } /* Handle each message type */ if(strcmp(bm.hdr.objkind, "fil") == 0) {// esyslog("Processing file"); ProcessBiopFile(&bm, cachep, cache); } else if(strcmp(bm.hdr.objkind, "dir") == 0) {// esyslog("Processing directory"); ProcessBiopDir(&bm, cachep, cache); } else if(strcmp(bm.hdr.objkind, "srg") == 0) {// esyslog("Processing gateway"); ProcessBiopSrg(&bm, cachep, cache); } else if(strcmp(bm.hdr.objkind, "str") == 0) {// esyslog("Processing stream"); /*ProcessBiopStream(&bm, cachep); */ } else if(strcmp(bm.hdr.objkind, "ste") == 0) {// fprintf(bd_fd, "Processing events\n"); /*ProcessBiopEvent(&bm, cachep); */ } else { /* Error */ } free(bm.hdr.objkey); free(bm.hdr.objkind); free(bm.hdr.objinfo); }// fclose(bd_fd);}intBiop::ProcessBiopModuleInfo(struct biop_module_info *modinfo, uchar *Data) { int off, ret;// biop_fd = fopen("/tmp/biop2.debug", "a"); modinfo->mod_timeout = (Data[0] << 24 ) | (Data[1] << 16) | (Data[2] << 8 ) | Data[3];// fprintf(biop_fd, "Module Info -> Mod Timeout = %ld\n", modinfo->mod_timeout); modinfo->block_timeout = (Data[4] << 24) | (Data[5] << 16) | (Data[6] << 8) | Data[7];// fprintf(biop_fd, "Module Info -> BLock Timeout = %ld\n", modinfo->block_timeout); modinfo->min_blocktime = (Data[8] << 24) | (Data[9] << 16) | (Data[10] << 8) | Data[11];// fprintf(biop_fd, "Module Info -> Min Block Timeout = %ld\n", modinfo->min_blocktime); modinfo->taps_count = Data[12];// fprintf(biop_fd,"Module Info -> Taps Count = %d\n",modinfo->taps_count); off = 13; /* only 1 allowed TODO - may not be first though ? */ ret = ProcessBiopTap(&modinfo->tap, Data+off); if(ret > 0) { off += ret; } else { /* TODO error */ } modinfo->userinfo_len = Data[off++];// fprintf(biop_fd, "Module Info -> UserInfo Len = %d\n", modinfo->userinfo_len); if(modinfo->userinfo_len > 0) { modinfo->descriptors = ProcessDescriptors(Data+off,modinfo->userinfo_len,&off); } else { modinfo->descriptors = NULL; }// fclose(biop_fd); return off;}intBiop::ProcessBiopTap(struct biop_tap *tap, uchar *Data) { int off=0; tap->id = (Data[0] << 8) | Data[1];// fprintf(biop_fd, "Tap -> ID = %X\n",tap->id); off+=2; tap->use = (Data[off] << 8) | Data[off+1];// fprintf(biop_fd, "Tap -> Use = %X\n",tap->use); off+=2; tap->assoc_tag = (Data[off] << 8) | Data[off+1];// esyslog("Tap for stream %X", tap->assoc_tag);// fprintf(biop_fd, "Tap -> Assoc = %X\n",tap->assoc_tag); off+=2; tap->selector_len = Data[off++];// fprintf(biop_fd, "Tap -> Selector Length= %d\n",tap->selector_len); tap->selector_data = (char *)malloc(tap->selector_len); memcpy(tap->selector_data, Data+off, tap->selector_len); off+=tap->selector_len; return off;}intBiop::ProcessBiopBinder(struct biop_dsm_connbinder *binder, uchar *Data) { int off = 0, ret; binder->component_tag = (Data[0] << 24) | (Data[1] << 16) | (Data[2] << 8) | Data[3]; off+=4;// fprintf(biop_fd, "Binder -> Component_tag = %lX\n", binder->component_tag); binder->component_data_len = Data[off++];// fprintf(biop_fd, "Binder -> Component data len = %d\n", binder->component_data_len); binder->taps_count = Data[off++];// fprintf(biop_fd, "Binder -> Taps count = %d\n",binder->taps_count); /* UKProfile - only first tap read */ ret = ProcessBiopTap(&binder->tap, Data+off); if(ret > 0) { off += ret; } else { /* TODO error */ } return off;}intBiop::ProcessBiopObject(struct biop_obj_location *loc, uchar *Data) { int off = 0; loc->component_tag = (Data[0] << 24) | (Data[1] << 16) | (Data[2] << 8) | Data[3];// fprintf(biop_fd, "Object -> Component_tag = %lX\n",loc->component_tag); off+=4; loc->component_data_len = Data[off++];// fprintf(biop_fd, "Object -> Component data len = %d\n", loc->component_data_len); loc->carousel_id = (Data[off] << 24) | (Data[off+1] << 16) | (Data[off+2] << 8) | Data[off+3];// fprintf(biop_fd, "Object -> Carousel id = %ld\n",loc->carousel_id); off+=4; loc->module_id = (Data[off] << 8) | Data[off+1];// fprintf(biop_fd, "Object -> Module id = %d\n",loc->module_id); off+=2; loc->version_major = Data[off++]; loc->version_minor = Data[off++];// fprintf(biop_fd, "Object -> Version = (%d/%d)\n", loc->version_major, loc->version_minor); loc->objkey_len = Data[off++]; /* <= 4 */// fprintf(biop_fd, "Object -> Key Length = %d\n",loc->objkey_len ); loc->objkey = (char *)malloc(loc->objkey_len); memcpy(loc->objkey, Data+off, loc->objkey_len); off+=loc->objkey_len; return off;}intBiop::ProcessBiopLite(struct biop_profile_lite *, uchar *Data) { esyslog("BiopLite - Not Implemented Yet"); return 0; }intBiop::ProcessBiopBody(struct biop_profile_body *body, uchar *Data) { int off = 0, ret; body->data_len = (Data[off] << 24) | (Data[off+1] << 16) | (Data[off+2] << 8) | Data[off+3];// fprintf(biop_fd, "Body -> Data Length = %ld\n", body->data_len); off+=4; /* skip bit order */ off+=1; body->lite_components_count = Data[off++];// fprintf(biop_fd, "Body -> Lite Components Count= %x\n", body->lite_components_count); ret = ProcessBiopObject(&body->obj_loc, Data+off); if(ret > 0) { off += ret; } else { /* TODO error */ } ret = ProcessBiopBinder(&body->dsm_conn, Data+off); if(ret > 0) { off += ret; } else { /* TODO error */ } /* UKProfile - ignore anything else */ return off;}intBiop::ProcessBiopIor(struct biop_ior *ior, uchar *Data) { int off = 0, ret;// biop_fd = fopen("/tmp/biop.debug", "a");// fprintf(biop_fd, "New BIOP IOR\n"); ior->type_id_len = (Data[0] << 24) | (Data[1] << 16) | (Data[2] << 8) | (Data[3]);// fprintf(biop_fd, "Type id length = %ld\n", ior->type_id_len); ior->type_id = (char *)malloc(ior->type_id_len); off+=4; memcpy(ior->type_id, Data+off, ior->type_id_len); off+=ior->type_id_len; ior->tagged_profiles_count = (Data[off] << 24) | (Data[off+1] << 16) | (Data[off+2] << 8) | (Data[off+3]);// fprintf(biop_fd,"Tagged Profiles Count= %ld\n", ior->tagged_profiles_count); off+=4; ior->profile_id_tag = (Data[off] << 24) | (Data[off+1] << 16) | (Data[off+2] << 8) | Data[off+3];// fprintf(biop_fd, "Profile Id Tag= %lX\n", ior->profile_id_tag); off+=4;// fprintf(biop_fd, "Profile Id Tag last= %lX\n", (ior->profile_id_tag & 0xFF)); if((ior->profile_id_tag & 0xFF) == 0x06) { ret = ProcessBiopBody(&ior->body.full, Data+off); if(ret > 0) { off += ret; } else { /* TODO error */ } } else if((ior->profile_id_tag & 0xFF) == 0x05) { ret = ProcessBiopLite(&ior->body.lite, Data+off); if(ret > 0) { off += ret; } else { /* TODO error */ } } /* UKProfile - receiver may ignore other profiles */// fclose(biop_fd); return off;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -