/* ** Detect the controller and register the SIM with the CAM layer. ** returns the number of controllers installed... */ static int sim_install_symbios(void) { int i, j, iobase, irq; int cardcount = 0; pci_info h; CAM_SIM_ENTRY entry; dprintf("symbios: sim_install()\n"); for (i = 0; ; i++) { if ((*pci->get_nth_pci_info) (i, &h) != B_NO_ERROR) { /*if(!cardcount) d_printf("symbios: no controller found\n");*/ break; } // d_printf("scan: %04x %04x %02x\n", h.device_id, h.vendor_id, h.revision); #define PCI_VENDOR_SYMBIOS 0x1000 if(h.vendor_id == PCI_VENDOR_SYMBIOS) { for(j=0;devinfo[j].id;j++){ if((devinfo[j].id == h.device_id) && (h.revision >= devinfo[j].rev)){ iobase = h.u.h0.base_registers[0]; irq = h.u.h0.interrupt_line; d_printf("symbios%d: %s controller @ 0x%08x, irq %d\n", cardcount, devinfo[j].name, iobase, irq); if(cardcount == MAXCARDS){ d_printf("symbios: too many controllers!\n"); return cardcount; } if((cardinfo[cardcount]=create_cardinfo(cardcount,&h,devinfo[j].flags)) != NULL){ cardinfo[cardcount]->name = devinfo[j].name; entry.sim_init = sim_init_funcs[cardcount]; entry.sim_action = sim_action_funcs[cardcount]; cardinfo[cardcount]->registered = 0; register_stats(cardinfo[cardcount]); (*cam->xpt_bus_register)(&entry); cardcount++; } else { d_printf("symbios%d: cannot allocate cardinfo\n",cardcount); } break; } } } } return cardcount; }
/* ** sim_path_inquiry returns info on the target/lun. */ static long sim_path_inquiry(Symbios *s, CCB_HEADER *ccbh) { CCB_PATHINQ *ccb; ccb = (CCB_PATHINQ *) ccbh; ccb->cam_version_num = SIM_VERSION; ccb->cam_target_sprt = 0; ccb->cam_hba_eng_cnt = 0; memset (ccb->cam_vuhba_flags, 0, VUHBA); ccb->cam_sim_priv = SIM_PRIV; ccb->cam_async_flags = 0; ccb->cam_initiator_id = s->host_targ_id; ccb->cam_hba_inquiry = s->max_targ_id > 7 ? PI_WIDE_16 : 0 ; strncpy (ccb->cam_sim_vid, sim_vendor_name, SIM_ID); strncpy (ccb->cam_hba_vid, hba_vendor_name, HBA_ID); ccb->cam_osd_usage = 0; ccbh->cam_status = CAM_REQ_CMP; register_stats(s); return 0; }
static int mod_init(void) { registration_default_algorithm_type = get_algorithm_type(registration_default_algorithm); #ifdef STATISTICS /* register statistics */ if (register_module_stats( exports.name, mod_stats)!=0 ) { LM_ERR("failed to register core statistics\n"); return -1; } if (!register_stats()){ LM_ERR("Unable to register statistics\n"); return -1; } #endif /* check the max_nonce_reuse param */ if (auth_used_vector_timeout < 0) { LM_WARN("bad value for auth_used_vector_timeout parameter (=%d), must be positive. Fixed to 3600\n", auth_used_vector_timeout); auth_used_vector_timeout = 3600; } /* check the max_nonce_reuse param */ if (max_nonce_reuse < 0) { LM_WARN("bad value for max_nonce_reuse parameter (=%d), must be positive. Fixed to 0\n", max_nonce_reuse); max_nonce_reuse = 0; } /* load the CDP API */ if (load_cdp_api(&cdpb) != 0) { LM_ERR("can't load CDP API\n"); return -1; } /* load the TM API */ if (load_tm_api(&tmb) != 0) { LM_ERR("can't load TM API\n"); return -1; } /* Init the authorization data storage */ if (!auth_data_init(auth_data_hash_size)) { LM_ERR("Unable to init auth data\n"); return -1; } /* set default qop */ if (registration_qop.s && registration_qop.len > 0) { registration_qop_str.len = s_qop_s.len + registration_qop.len + s_qop_e.len; registration_qop_str.s = pkg_malloc(registration_qop_str.len); if (!registration_qop_str.s) { LM_ERR("Error allocating %d bytes\n", registration_qop_str.len); registration_qop_str.len = 0; return 0; } registration_qop_str.len = 0; STR_APPEND(registration_qop_str, s_qop_s); memcpy(registration_qop_str.s + registration_qop_str.len, registration_qop.s, registration_qop.len); registration_qop_str.len += registration_qop.len; STR_APPEND(registration_qop_str, s_qop_e); } else { registration_qop_str.len = 0; registration_qop_str.s = 0; } /* Register the auth vector timer */ if (register_timer(reg_await_timer, auth_data, 10) < 0) { LM_ERR("Unable to register auth vector timer\n"); return -1; } return 0; }
static int mod_init(void) { pv_spec_t avp_spec; str s; bind_usrloc_t bind_usrloc; qvalue_t dq; callback_singleton = shm_malloc(sizeof (int)); *callback_singleton = 0; /*build the required strings */ scscf_serviceroute_uri_str.s = (char*) pkg_malloc(orig_prefix.len + scscf_name_str.len); if (!scscf_serviceroute_uri_str.s) { LM_ERR("Unable to allocate memory for service route uri\n"); return -1; } if (contact_expires_buffer_percentage < 0 || contact_expires_buffer_percentage > 90) { LM_ERR("contact expires percentage not valid, must be >0 and <=90"); return -1; } memcpy(scscf_serviceroute_uri_str.s, orig_prefix.s, orig_prefix.len); scscf_serviceroute_uri_str.len = orig_prefix.len; if (scscf_name_str.len > 4 && strncasecmp(scscf_name_str.s, "sip:", 4) == 0) { memcpy(scscf_serviceroute_uri_str.s + scscf_serviceroute_uri_str.len, scscf_name_str.s + 4, scscf_name_str.len - 4); scscf_serviceroute_uri_str.len += scscf_name_str.len - 4; } else { memcpy(scscf_serviceroute_uri_str.s + scscf_serviceroute_uri_str.len, scscf_name_str.s, scscf_name_str.len); scscf_serviceroute_uri_str.len += scscf_name_str.len; } pv_tmx_data_init(); /* </build required strings> */ #ifdef STATISTICS /* register statistics */ if (register_module_stats(exports.name, mod_stats) != 0) { LM_ERR("failed to register core statistics\n"); return -1; } if (!register_stats()) { LM_ERR("Unable to register statistics\n"); return -1; } #endif /*register space for notification processors*/ register_procs(notification_processes); cfg_register_child(notification_processes); /* bind the SL API */ if (sl_load_api(&slb) != 0) { LM_ERR("cannot bind to SL API\n"); return -1; } /* load the TM API */ if (load_tm_api(&tmb) != 0) { LM_ERR("can't load TM API\n"); return -1; } /* load the CDP API */ if (load_cdp_api(&cdpb) != 0) { LM_ERR("can't load CDP API\n"); return -1; } cdp_avp = load_cdp_avp(); if (!cdp_avp) { LM_ERR("can't load CDP_AVP API\n"); return -1; } if (cfg_declare("registrar", registrar_cfg_def, &default_registrar_cfg, cfg_sizeof(registrar), ®istrar_cfg)) { LM_ERR("Fail to declare the configuration\n"); return -1; } if (rcv_avp_param && *rcv_avp_param) { s.s = rcv_avp_param; s.len = strlen(s.s); if (pv_parse_spec(&s, &avp_spec) == 0 || avp_spec.type != PVT_AVP) { LM_ERR("malformed or non AVP %s AVP definition\n", rcv_avp_param); return -1; } if (pv_get_avp_name(0, &avp_spec.pvp, &rcv_avp_name, &rcv_avp_type) != 0) { LM_ERR("[%s]- invalid AVP definition\n", rcv_avp_param); return -1; } } else { rcv_avp_name.n = 0; rcv_avp_type = 0; } if (aor_avp_param && *aor_avp_param) { s.s = aor_avp_param; s.len = strlen(s.s); if (pv_parse_spec(&s, &avp_spec) == 0 || avp_spec.type != PVT_AVP) { LM_ERR("malformed or non AVP %s AVP definition\n", aor_avp_param); return -1; } if (pv_get_avp_name(0, &avp_spec.pvp, &aor_avp_name, &aor_avp_type) != 0) { LM_ERR("[%s]- invalid AVP definition\n", aor_avp_param); return -1; } } else { aor_avp_name.n = 0; aor_avp_type = 0; } if (reg_callid_avp_param && *reg_callid_avp_param) { s.s = reg_callid_avp_param; s.len = strlen(s.s); if (pv_parse_spec(&s, &avp_spec) == 0 || avp_spec.type != PVT_AVP) { LM_ERR("malformed or non AVP %s AVP definition\n", reg_callid_avp_param); return -1; } if (pv_get_avp_name(0, &avp_spec.pvp, ®_callid_avp_name, ®_callid_avp_type) != 0) { LM_ERR("[%s]- invalid AVP definition\n", reg_callid_avp_param); return -1; } } else { reg_callid_avp_name.n = 0; reg_callid_avp_type = 0; } bind_usrloc = (bind_usrloc_t) find_export("ul_bind_usrloc", 1, 0); if (!bind_usrloc) { LM_ERR("can't bind usrloc\n"); return -1; } /* Normalize default_q parameter */ dq = cfg_get(registrar, registrar_cfg, default_q); if (dq != Q_UNSPECIFIED) { if (dq > MAX_Q) { LM_DBG("default_q = %d, lowering to MAX_Q: %d\n", dq, MAX_Q); dq = MAX_Q; } else if (dq < MIN_Q) { LM_DBG("default_q = %d, raising to MIN_Q: %d\n", dq, MIN_Q); dq = MIN_Q; } } cfg_get(registrar, registrar_cfg, default_q) = dq; if (bind_usrloc(&ul) < 0) { return -1; } /*Register for callback of URECORD being deleted - so we can send a SAR*/ if (ul.register_ulcb == NULL) { LM_ERR("Could not import ul_register_ulcb\n"); return -1; } if (ul.register_ulcb(0, 0, UL_IMPU_INSERT, ul_impu_inserted, 0) < 0) { LM_ERR("can not register callback for insert\n"); return -1; } if (sock_hdr_name.s) { if (sock_hdr_name.len == 0 || sock_flag == -1) { LM_WARN("empty sock_hdr_name or sock_flag no set -> reseting\n"); sock_hdr_name.len = 0; sock_flag = -1; } } else if (sock_flag != -1) { LM_WARN("sock_flag defined but no sock_hdr_name -> reseting flag\n"); sock_flag = -1; } /* fix the flags */ sock_flag = (sock_flag != -1) ? (1 << sock_flag) : 0; tcp_persistent_flag = (tcp_persistent_flag != -1) ? (1 << tcp_persistent_flag) : 0; /* init the registrar notifications */ if (!notify_init()) return -1; /* register the registrar notifications timer */ //Currently we do not use this - we send notifies immediately //if (register_timer(notification_timer, notification_list, 5) < 0) return -1; return 0; }
/** * init module function */ static int mod_init(void) { /* fix the parameters */ if (!fix_parameters()) goto error; #ifdef STATISTICS /* register statistics */ if (register_module_stats(exports.name, mod_stats) != 0) { LM_ERR("failed to register core statistics\n"); goto error; } if (!register_stats()) { LM_ERR("Unable to register statistics\n"); goto error; } #endif callback_singleton = shm_malloc(sizeof (int)); *callback_singleton = 0; /*register space for event processor*/ register_procs(1); cdp_avp = 0; /* load the TM API */ if (load_tm_api(&tmb) != 0) { LM_ERR("can't load TM API\n"); goto error; } /* load the CDP API */ if (load_cdp_api(&cdpb) != 0) { LM_ERR("can't load CDP API\n"); goto error; } /* load the dialog API */ if (load_dlg_api(&dlgb) != 0) { LM_ERR("can't load Dialog API\n"); goto error; } cdp_avp = load_cdp_avp(); if (!cdp_avp) { LM_ERR("can't load CDP_AVP API\n"); goto error; } /* load the usrloc API */ bind_usrloc = (bind_usrloc_t) find_export("ul_bind_ims_usrloc_pcscf", 1, 0); if (!bind_usrloc) { LM_ERR("can't bind usrloc_pcscf\n"); return CSCF_RETURN_FALSE; } if (bind_usrloc(&ul) < 0) { LM_ERR("can't bind to usrloc pcscf\n"); return CSCF_RETURN_FALSE; } LM_DBG("Successfully bound to PCSCF Usrloc module\n"); LM_DBG("Diameter RX interface successfully bound to TM, Dialog, Usrloc and CDP modules\n"); /*init cdb cb event list*/ if (!init_cdp_cb_event_list()) { LM_ERR("unable to initialise cdp callback event list\n"); return -1; } return 0; error: LM_ERR("Failed to initialise ims_qos module\n"); return CSCF_RETURN_FALSE; }