int main() { DBus::init(); DBus::Dispatcher::pointer dispatcher; dispatcher = DBus::Dispatcher::create(); DBus::Connection::pointer connection; connection = dispatcher->create_connection( DBus::BUS_SESSION ); //create an object proxy, which stands in for a real object. //a proxy exists over the dbus DBus::ObjectProxy::pointer object; object = connection->create_object_proxy("dbuscxx.quickstart_0.server", "/dbuscxx/quickstart_0"); //a method proxy acts like a real method, but will go over the dbus //to do its work. DBus::MethodProxy<double,double,double>& add_proxy = *(object->create_method<double,double,double>("dbuscxx.Quickstart","add")); double answer; answer = add_proxy( 1.1, 2.2 ); std::cout << "1.1 + 2.2 = " << answer << std::endl; return 0; }
Proxy::Proxy(int port) : proxy_socket(-1), poll_size(0) { proxy_socket = init_socket(port); add_proxy(); threads_num = 0; pthread_mutexattr_t attr; pthread_mutexattr_init(&attr); pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_ERRORCHECK); pthread_mutex_init(&proxy_mutex, &attr); pthread_cond_init(&proxy_cond, NULL); }
void LocationsMgr::add_location( const std::string& name , const CfgPairs& cfg ) { try { if( cfg.at("type") == "szbase" ) add_szbase( name , cfg ); else if( cfg.at("type") == "proxy" ) add_proxy( name , cfg ); else throw invalid_value("Invalid 'type' in section " + name ); } catch( std::out_of_range& e ) { throw missing_option("Missing option in section " + name ); } }
static void add_default_proxy(CFMutableArrayRef proxies, CFDictionaryRef defaultProxy, Boolean *orderAdded) { CFMutableDictionaryRef myDefault; uint32_t myOrder = DEFAULT_MATCH_ORDER; CFNumberRef order = NULL; if (defaultProxy == NULL) { myDefault = CFDictionaryCreateMutable(NULL, 0, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks); } else { myDefault = CFDictionaryCreateMutableCopy(NULL, 0, defaultProxy); CFDictionaryRemoveValue(myDefault, kSCPropInterfaceName); order = CFDictionaryGetValue(myDefault, PROXY_MATCH_ORDER_KEY); } // ensure that the default proxy has a search order if (!isA_CFNumber(order) || !CFNumberGetValue(order, kCFNumberIntType, &myOrder)) { myOrder = DEFAULT_MATCH_ORDER; order = CFNumberCreate(NULL, kCFNumberIntType, &myOrder); CFDictionarySetValue(myDefault, PROXY_MATCH_ORDER_KEY, order); CFRelease(order); *orderAdded = TRUE; } // add the default proxy add_proxy(proxies, myDefault); CFRelease(myDefault); return; }
int pam_sm_authenticate(pam_handle_t *pamh, int flags, int argc, const char **argv) { char *user, *pw; char *service; char **proxies; char netid[14]; int i, success; Flags f = NONE; /* initialize proxy array */ proxies = (char **)malloc(sizeof(char **)); proxies[0] = NULL; /* get username and password */ if (pam_get_user(pamh, (const char**) &user, NULL) != PAM_SUCCESS) return PAM_AUTH_ERR; if (pam_get_item(pamh, PAM_AUTHTOK, (const void**) &pw) != PAM_SUCCESS) return PAM_AUTH_ERR; /* * Abort if the password doesn't look like a ticket. This speeds things * up and reduces the likelihood that the user's password will end up * in an HTTPD log. */ if ((strncmp(CAS_BEGIN_PT, pw, strlen(CAS_BEGIN_PT)) != 0) && (strncmp(CAS_BEGIN_ST, pw, strlen(CAS_BEGIN_ST)) != 0)) return PAM_AUTH_ERR; /* prepare log */ openlog("PAM_cas", LOG_PID, LOG_AUTH); /* check arguments */ for (i = 0; i < argc; i++) { if (!strcmp(argv[i], "debug")) f |= DEBUG; else if (!strncmp(argv[i], "-s", 2)) { service = strdup(argv[i] + 2); } else if (!strncmp(argv[i], "-p", 2)) { proxies = add_proxy(proxies, argv[i] + 2); } else if (!strncmp(argv[i], "-e", 2)) { /* don't let the username pass through if it's excluded */ if (!strcmp(argv[i] + 2, user)) { syslog(LOG_NOTICE, "user '%s' is excluded from the CAS PAM", user); free_proxies(proxies); return PAM_AUTH_ERR; } } else syslog(LOG_ERR, "invalid option '%s'", argv[i]); } /* determine the CAS-authenticated username */ success = cas_validate(pw, service, netid, sizeof(netid), proxies); /* free the memory used by the proxy array */ free_proxies(proxies); /* Confirm the user and return appropriately. */ if ((success == CAS_SUCCESS) && (!strcmp(user, netid))) { closelog(); return PAM_SUCCESS; } else { syslog(LOG_NOTICE, "authentication failure code %d for user '%s'", success, user); closelog(); return PAM_AUTH_ERR; } }
static void add_supplemental(CFMutableArrayRef proxies, CFDictionaryRef proxy, uint32_t defaultOrder) { CFArrayRef domains; CFIndex i; CFIndex n_domains; CFArrayRef orders; domains = CFDictionaryGetValue(proxy, kSCPropNetProxiesSupplementalMatchDomains); n_domains = isA_CFArray(domains) ? CFArrayGetCount(domains) : 0; if (n_domains == 0) { return; } orders = CFDictionaryGetValue(proxy, kSCPropNetProxiesSupplementalMatchOrders); if (orders != NULL) { if (!isA_CFArray(orders) || (n_domains != CFArrayGetCount(orders))) { return; } } /* * yes, this is a "supplemental" proxy configuration, expand * the match domains and add each to the proxies list. */ for (i = 0; i < n_domains; i++) { CFStringRef match_domain; CFNumberRef match_order; CFMutableDictionaryRef match_proxy; match_domain = CFArrayGetValueAtIndex(domains, i); if (!isA_CFString(match_domain)) { continue; } match_proxy = CFDictionaryCreateMutableCopy(NULL, 0, proxy); // set supplemental proxy match "domain" match_domain = _SC_trimDomain(match_domain); if (match_domain != NULL) { CFDictionarySetValue(match_proxy, kSCPropNetProxiesSupplementalMatchDomain, match_domain); CFRelease(match_domain); } else { CFDictionaryRemoveValue(match_proxy, kSCPropNetProxiesSupplementalMatchDomain); } // set supplemental proxy match "order" match_order = (orders != NULL) ? CFArrayGetValueAtIndex(orders, i) : NULL; if (isA_CFNumber(match_order)) { CFDictionarySetValue(match_proxy, PROXY_MATCH_ORDER_KEY, match_order); } else { CFNumberRef num; num = CFNumberCreate(NULL, kCFNumberIntType, &defaultOrder); CFDictionarySetValue(match_proxy, PROXY_MATCH_ORDER_KEY, num); CFRelease(num); defaultOrder++; // if multiple domains, maintain ordering } // remove keys we don't want in a supplemental proxy CFDictionaryRemoveValue(match_proxy, kSCPropNetProxiesSupplementalMatchDomains); CFDictionaryRemoveValue(match_proxy, kSCPropNetProxiesSupplementalMatchOrders); CFDictionaryRemoveValue(match_proxy, kSCPropInterfaceName); add_proxy(proxies, match_proxy); CFRelease(match_proxy); } return; }
/*! \brief Adds the proxies in the proxy list & resolves the hostnames * \return 0 if ok, <0 on error */ static int fix_actions(struct action* a) { struct action *t; int ret; cmd_export_t* cmd; struct hostent* he; struct ip_addr ip; struct socket_info* si; str host; int proto=PROTO_NONE, port; struct proxy_l *p; struct bl_head *blh; int i; str s; pv_elem_t *model=NULL; pv_elem_t *models[5]; xl_level_p xlp; if (a==0){ LM_CRIT("null pointer\n"); return E_BUG; } for(t=a; t!=0; t=t->next){ switch(t->type){ case ROUTE_T: if (t->elem[0].type!=NUMBER_ST){ LM_ALERT("BUG in route() type %d\n", t->elem[0].type); ret = E_BUG; goto error; } if ((t->elem[0].u.number>RT_NO)||(t->elem[0].u.number<0)){ LM_ALERT("invalid routing table number in" "route(%lu)\n", t->elem[0].u.number); ret = E_CFG; goto error; } if ( rlist[t->elem[0].u.number].a==NULL ) { LM_ERR("called route %d is not defined\n", (int)t->elem[0].u.number); ret = E_CFG; goto error; } break; case FORWARD_T: if (sl_fwd_disabled>0) { LM_ERR("stateless forwarding disabled, but forward() " "is used!!\n"); ret = E_CFG; goto error; } sl_fwd_disabled = 0; if (t->elem[0].type==NOSUBTYPE) break; case SEND_T: if (t->elem[0].type!=STRING_ST) { LM_CRIT("invalid type %d (should be string)\n", t->type); ret = E_BUG; goto error; } ret = parse_phostport( t->elem[0].u.string, strlen(t->elem[0].u.string), &host.s, &host.len, &port, &proto); if (ret!=0) { LM_ERR("ERROR:fix_actions: FORWARD/SEND bad " "argument\n"); ret = E_CFG; goto error; } p = add_proxy( &host,(unsigned short)port, proto); if (p==0) { LM_ERR("forward/send failed to add proxy"); ret = E_CFG; goto error; } t->elem[0].type = PROXY_ST; t->elem[0].u.data = (void*)p; break; case IF_T: if (t->elem[0].type!=EXPR_ST){ LM_CRIT("invalid subtype %d for if (should be expr)\n", t->elem[0].type); ret = E_BUG; goto error; }else if( (t->elem[1].type!=ACTIONS_ST) &&(t->elem[1].type!=NOSUBTYPE) ){ LM_CRIT("invalid subtype %d for if() {...} (should be" "action)\n", t->elem[1].type); ret = E_BUG; goto error; }else if( (t->elem[2].type!=ACTIONS_ST) &&(t->elem[2].type!=NOSUBTYPE) ){ LM_CRIT("invalid subtype %d for if() {} else{...}(should" "be action)\n", t->elem[2].type); ret = E_BUG; goto error; } if (t->elem[0].u.data){ if ((ret=fix_expr((struct expr*)t->elem[0].u.data))<0) return ret; } if ( (t->elem[1].type==ACTIONS_ST)&&(t->elem[1].u.data) ){ if ((ret=fix_actions((struct action*)t->elem[1].u.data))<0) return ret; } if ( (t->elem[2].type==ACTIONS_ST)&&(t->elem[2].u.data) ){ if((ret=fix_actions((struct action*)t->elem[2].u.data))<0) return ret; } break; case WHILE_T: if (t->elem[0].type!=EXPR_ST){ LM_CRIT("invalid subtype %d for while (should be expr)\n", t->elem[0].type); ret = E_BUG; goto error; }else if( (t->elem[1].type!=ACTIONS_ST) &&(t->elem[1].type!=NOSUBTYPE) ){ LM_CRIT("invalid subtype %d for while() {...} (should be" "action)\n", t->elem[1].type); ret = E_BUG; goto error; } if (t->elem[0].u.data){ if ((ret=fix_expr((struct expr*)t->elem[0].u.data))<0) return ret; } if ( (t->elem[1].type==ACTIONS_ST)&&(t->elem[1].u.data) ){ if ((ret=fix_actions((struct action*)t->elem[1].u.data))<0) return ret; } break; case SWITCH_T: if ( (t->elem[1].type==ACTIONS_ST)&&(t->elem[1].u.data) ){ if ((ret=fix_actions((struct action*)t->elem[1].u.data))<0) return ret; } break; case CASE_T: if ( (t->elem[1].type==ACTIONS_ST)&&(t->elem[1].u.data) ){ if ((ret=fix_actions((struct action*)t->elem[1].u.data))<0) return ret; } break; case DEFAULT_T: if ( (t->elem[0].type==ACTIONS_ST)&&(t->elem[0].u.data) ){ if ((ret=fix_actions((struct action*)t->elem[0].u.data))<0) return ret; } break; case MODULE_T: cmd = (cmd_export_t*)t->elem[0].u.data; LM_DBG("fixing %s, line %d\n", cmd->name, t->line); if (cmd->fixup){ if (cmd->param_no==0){ ret=cmd->fixup( 0, 0); if (ret<0) goto error; } else { for (i=1; i<=cmd->param_no; i++) { ret=cmd->fixup(&t->elem[i].u.data, i); t->elem[i].type=MODFIXUP_ST; if (ret<0) goto error; } } } break; case FORCE_SEND_SOCKET_T: if (t->elem[0].type!=SOCKID_ST){ LM_CRIT("invalid subtype %d for force_send_socket\n", t->elem[0].type); ret = E_BUG; goto error; } he=resolvehost(((struct socket_id*)t->elem[0].u.data)->name,0); if (he==0){ LM_ERR(" could not resolve %s\n", ((struct socket_id*)t->elem[0].u.data)->name); ret = E_BAD_ADDRESS; goto error; } hostent2ip_addr(&ip, he, 0); si=find_si(&ip, ((struct socket_id*)t->elem[0].u.data)->port, ((struct socket_id*)t->elem[0].u.data)->proto); if (si==0){ LM_ERR("bad force_send_socket" " argument: %s:%d (opensips doesn't listen on it)\n", ((struct socket_id*)t->elem[0].u.data)->name, ((struct socket_id*)t->elem[0].u.data)->port); ret = E_BAD_ADDRESS; goto error; } t->elem[0].u.data=si; t->elem[0].type=SOCKETINFO_ST; break; case SET_DEBUG_T: if (t->elem[0].type==NOSUBTYPE) break; if (t->elem[0].type!=NUMBER_ST) { LM_CRIT("fix_actions: BUG in setdebug() type %d\n", t->elem[0].type ); ret=E_BUG; goto error; } /* normalize the value */ if (t->elem[0].u.number>L_DBG) t->elem[0].u.number = L_DBG; else if (t->elem[0].u.number<L_ALERT) t->elem[0].u.number = L_ALERT; break; case SETFLAG_T: case RESETFLAG_T: case ISFLAGSET_T: if (t->elem[0].type!=NUMBER_ST) { LM_CRIT("bad xxxflag() type %d\n", t->elem[0].type ); ret=E_BUG; goto error; } if (!flag_in_range( t->elem[0].u.number )) { ret=E_CFG; goto error; } break; case SETSFLAG_T: case RESETSFLAG_T: case ISSFLAGSET_T: if (t->elem[0].type!=NUMBER_ST) { LM_CRIT("bad xxxsflag() type %d\n", t->elem[0].type ); ret=E_BUG; goto error; } t->elem[0].u.number = fixup_flag( t->elem[0].u.number ); if (t->elem[0].u.data==0) { ret=E_CFG; goto error; } break; case SETBFLAG_T: case RESETBFLAG_T: case ISBFLAGSET_T: if (t->elem[0].type!=NUMBER_ST || t->elem[1].type!=NUMBER_ST) { LM_CRIT("bad xxxbflag() type " "%d,%d\n", t->elem[0].type, t->elem[0].type); ret=E_BUG; goto error; } t->elem[1].u.number = fixup_flag( t->elem[1].u.number ); if (t->elem[1].u.data==0) { ret=E_CFG; goto error; } break; case EQ_T: case COLONEQ_T: case PLUSEQ_T: case MINUSEQ_T: case DIVEQ_T: case MULTEQ_T: case MODULOEQ_T: case BANDEQ_T: case BOREQ_T: case BXOREQ_T: if (t->elem[1].u.data){ if ((ret=fix_expr((struct expr*)t->elem[1].u.data))<0) return ret; } break; case USE_BLACKLIST_T: case UNUSE_BLACKLIST_T: if (t->elem[0].type!=STRING_ST) { LM_CRIT("bad [UN]USE_BLACKLIST type %d\n",t->elem[0].type); ret=E_BUG; goto error; } host.s = t->elem[0].u.string; host.len = strlen(host.s); if ( strcasecmp(host.s,"all")==0 ) { blh = NULL; } else { blh = get_bl_head_by_name(&host); if (blh==NULL) { LM_ERR("[UN]USE_BLACKLIST - list " "%s not configured\n", t->elem[0].u.string); ret=E_CFG; goto error; } } t->elem[0].type = BLACKLIST_ST; t->elem[0].u.data = blh; break; case CACHE_STORE_T: case CACHE_FETCH_T: case CACHE_REMOVE_T: /* attr name */ s.s = (char*)t->elem[1].u.data; s.len = strlen(s.s); if(s.len==0) { LM_ERR("param 2 is empty string!\n"); return E_CFG; } if(pv_parse_format(&s ,&model) || model==NULL) { LM_ERR("wrong format [%s] for value param!\n", s.s); ret=E_BUG; goto error; } t->elem[1].u.data = (void*)model; if (t->type==CACHE_REMOVE_T) break; /* value */ if (t->type==CACHE_FETCH_T) { if(((pv_spec_p)t->elem[2].u.data)->type!= PVT_AVP) { LM_ERR("Wrong type for the third argument - " "must be an AVP\n"); ret=E_BUG; goto error; } } else { s.s = (char*)t->elem[2].u.data; s.len = strlen(s.s); if(s.len==0) { LM_ERR("param 2 is empty string!\n"); return E_CFG; } if(pv_parse_format(&s ,&model) || model==NULL) { LM_ERR("wrong format [%s] for value param!\n",s.s); ret=E_BUG; goto error; } t->elem[2].u.data = (void*)model; } break; case XDBG_T: case XLOG_T: s.s = (char*)t->elem[1].u.data; if (s.s == NULL) { /* commands have only one parameter */ s.s = (char *)t->elem[0].u.data; s.len = strlen(s.s); if(s.len==0) { LM_ERR("param is empty string!\n"); return E_CFG; } if(pv_parse_format(&s ,&model) || model==NULL) { LM_ERR("wrong format [%s] for value param!\n", s.s); ret=E_BUG; goto error; } t->elem[0].u.data = (void*)model; t->elem[0].type = SCRIPTVAR_ELEM_ST; } else { /* there are two parameters */ s.s = (char *)t->elem[0].u.data; s.len = strlen(s.s); if (s.len == 0) { LM_ERR("param is empty string\n"); return E_CFG; } xlp = (xl_level_p)pkg_malloc(sizeof(xl_level_t)); if(xlp == NULL) { LM_ERR("no more memory\n"); return E_UNSPEC; } memset(xlp, 0, sizeof(xl_level_t)); if(s.s[0]==PV_MARKER) { xlp->type = 1; if(pv_parse_spec(&s, &xlp->v.sp)==NULL) { LM_ERR("invalid level param\n"); return E_UNSPEC; } } else { xlp->type = 0; switch(s.s[2]) { case 'A': xlp->v.level = L_ALERT; break; case 'C': xlp->v.level = L_CRIT; break; case 'E': xlp->v.level = L_ERR; break; case 'W': xlp->v.level = L_WARN; break; case 'N': xlp->v.level = L_NOTICE; break; case 'I': xlp->v.level = L_INFO; break; case 'D': xlp->v.level = L_DBG; break; default: LM_ERR("unknown log level\n"); return E_UNSPEC; } } t->elem[0].u.data = xlp; s.s = t->elem[1].u.data; s.len = strlen(s.s); if (pv_parse_format(&s, &model) || model == NULL) { LM_ERR("wrong fomat [%s] for value param\n",s.s); ret=E_BUG; goto error; } t->elem[1].u.data = model; t->elem[1].type = SCRIPTVAR_ELEM_ST; } break; case CONSTRUCT_URI_T: for (i=0;i<5;i++) { s.s = (char*)t->elem[i].u.data; s.len = strlen(s.s); if(s.len==0) continue; if(pv_parse_format(&s ,&(models[i])) || models[i]==NULL) { LM_ERR("wrong format [%s] for value param!\n",s.s); ret=E_BUG; goto error; } t->elem[i].u.data = (void*)models[i]; } if (((pv_spec_p)t->elem[5].u.data)->type != PVT_AVP) { LM_ERR("Wrong type for the third argument - " "must be an AVP\n"); ret=E_BUG; goto error; } break; } } return 0; error: LM_ERR("fixing failed (code=%d) at cfg line %d\n", ret, t->line); return ret; }
/* returns 0 if ok, <0 on error */ static int fix_actions(struct action* a) { struct action *t; struct proxy_l* p; char *tmp; int ret; cmd_export_t* cmd; struct sr_module* mod; str s; struct hostent* he; struct ip_addr ip; struct socket_info* si; if (a==0){ LOG(L_CRIT,"BUG: fix_actions: null pointer\n"); return E_BUG; } for(t=a; t!=0; t=t->next){ switch(t->type){ case FORWARD_T: case FORWARD_TLS_T: case FORWARD_TCP_T: case FORWARD_UDP_T: case SEND_T: case SEND_TCP_T: switch(t->p1_type){ case IP_ST: tmp=strdup(ip_addr2a( (struct ip_addr*)t->p1.data)); if (tmp==0){ LOG(L_CRIT, "ERROR: fix_actions:" "memory allocation failure\n"); return E_OUT_OF_MEM; } t->p1_type=STRING_ST; t->p1.string=tmp; /* no break */ case STRING_ST: s.s = t->p1.string; s.len = strlen(s.s); p=add_proxy(&s, t->p2.number, 0); /* FIXME proto*/ if (p==0) return E_BAD_ADDRESS; t->p1.data=p; t->p1_type=PROXY_ST; break; case URIHOST_ST: break; default: LOG(L_CRIT, "BUG: fix_actions: invalid type" "%d (should be string or number)\n", t->type); return E_BUG; } break; case IF_T: if (t->p1_type!=EXPR_ST){ LOG(L_CRIT, "BUG: fix_actions: invalid subtype" "%d for if (should be expr)\n", t->p1_type); return E_BUG; }else if( (t->p2_type!=ACTIONS_ST)&&(t->p2_type!=NOSUBTYPE) ){ LOG(L_CRIT, "BUG: fix_actions: invalid subtype" "%d for if() {...} (should be action)\n", t->p2_type); return E_BUG; }else if( (t->p3_type!=ACTIONS_ST)&&(t->p3_type!=NOSUBTYPE) ){ LOG(L_CRIT, "BUG: fix_actions: invalid subtype" "%d for if() {} else{...}(should be action)\n", t->p3_type); return E_BUG; } if (t->p1.data){ if ((ret=fix_expr((struct expr*)t->p1.data))<0) return ret; } if ( (t->p2_type==ACTIONS_ST)&&(t->p2.data) ){ if ((ret=fix_actions((struct action*)t->p2.data))<0) return ret; } if ( (t->p3_type==ACTIONS_ST)&&(t->p3.data) ){ if ((ret=fix_actions((struct action*)t->p3.data))<0) return ret; } break; case MODULE_T: if ((mod=find_module(t->p1.data, &cmd))!=0){ DBG("fixing %s %s\n", mod->path, cmd->name); if (cmd->fixup){ if (cmd->param_no>0){ ret=cmd->fixup(&t->p2.data, 1); t->p2_type=MODFIXUP_ST; if (ret<0) return ret; } if (cmd->param_no>1){ ret=cmd->fixup(&t->p3.data, 2); t->p3_type=MODFIXUP_ST; if (ret<0) return ret; } } } break; case FORCE_SEND_SOCKET_T: if (t->p1_type!=SOCKID_ST){ LOG(L_CRIT, "BUG: fix_actions: invalid subtype" "%d for force_send_socket\n", t->p1_type); return E_BUG; } he=resolvehost(((struct socket_id*)t->p1.data)->name); if (he==0){ LOG(L_ERR, "ERROR: fix_actions: force_send_socket:" " could not resolve %s\n", ((struct socket_id*)t->p1.data)->name); return E_BAD_ADDRESS; } hostent2ip_addr(&ip, he, 0); si=find_si(&ip, ((struct socket_id*)t->p1.data)->port, ((struct socket_id*)t->p1.data)->proto); if (si==0){ LOG(L_ERR, "ERROR: fix_actions: bad force_send_socket" " argument: %s:%d (ser doesn't listen on it)\n", ((struct socket_id*)t->p1.data)->name, ((struct socket_id*)t->p1.data)->port); return E_BAD_ADDRESS; } t->p1.data=si; t->p1_type=SOCKETINFO_ST; break; } } return 0; }
/* returns 0 if ok, <0 on error */ static int fix_actions(struct action* a) { struct action *t; int ret; cmd_export_t* cmd; struct hostent* he; struct ip_addr ip; struct socket_info* si; str host; int proto=PROTO_NONE, port; struct proxy_l *p; struct bl_head *blh; if (a==0){ LM_CRIT("null pointer\n"); return E_BUG; } for(t=a; t!=0; t=t->next){ switch(t->type){ case FORWARD_T: if (t->elem[0].type==NOSUBTYPE) break; case SEND_T: if (t->elem[0].type!=STRING_ST) { LM_CRIT("invalid type %d (should be string)\n", t->type); return E_BUG; } ret = parse_phostport( t->elem[0].u.string, strlen(t->elem[0].u.string), &host.s, &host.len, &port, &proto); if (ret!=0) { LM_ERR("ERROR:fix_actions: FORWARD/SEND bad " "argument\n"); return E_CFG; } p = add_proxy( &host,(unsigned short)port, proto); if (p==0) { LM_ERR("forward/send failed to add proxy"); return E_CFG; } t->elem[0].type = PROXY_ST; t->elem[0].u.data = (void*)p; break; case IF_T: if (t->elem[0].type!=EXPR_ST){ LM_CRIT("invalid subtype %d for if (should be expr)\n", t->elem[0].type); return E_BUG; }else if( (t->elem[1].type!=ACTIONS_ST) &&(t->elem[1].type!=NOSUBTYPE) ){ LM_CRIT("invalid subtype %d for if() {...} (should be" "action)\n", t->elem[1].type); return E_BUG; }else if( (t->elem[2].type!=ACTIONS_ST) &&(t->elem[2].type!=NOSUBTYPE) ){ LM_CRIT("invalid subtype %d for if() {} else{...}(should" "be action)\n", t->elem[2].type); return E_BUG; } if (t->elem[0].u.data){ if ((ret=fix_expr((struct expr*)t->elem[0].u.data))<0) return ret; } if ( (t->elem[1].type==ACTIONS_ST)&&(t->elem[1].u.data) ){ if ((ret=fix_actions((struct action*)t->elem[1].u.data))<0) return ret; } if ( (t->elem[2].type==ACTIONS_ST)&&(t->elem[2].u.data) ){ if((ret=fix_actions((struct action*)t->elem[2].u.data))<0) return ret; } break; case WHILE_T: if (t->elem[0].type!=EXPR_ST){ LM_CRIT("invalid subtype %d for while (should be expr)\n", t->elem[0].type); return E_BUG; }else if( (t->elem[1].type!=ACTIONS_ST) &&(t->elem[1].type!=NOSUBTYPE) ){ LM_CRIT("invalid subtype %d for while() {...} (should be" "action)\n", t->elem[1].type); return E_BUG; } if (t->elem[0].u.data){ if ((ret=fix_expr((struct expr*)t->elem[0].u.data))<0) return ret; } if ( (t->elem[1].type==ACTIONS_ST)&&(t->elem[1].u.data) ){ if ((ret=fix_actions((struct action*)t->elem[1].u.data))<0) return ret; } break; case SWITCH_T: if ( (t->elem[1].type==ACTIONS_ST)&&(t->elem[1].u.data) ){ if ((ret=fix_actions((struct action*)t->elem[1].u.data))<0) return ret; } break; case CASE_T: if ( (t->elem[1].type==ACTIONS_ST)&&(t->elem[1].u.data) ){ if ((ret=fix_actions((struct action*)t->elem[1].u.data))<0) return ret; } break; case DEFAULT_T: if ( (t->elem[0].type==ACTIONS_ST)&&(t->elem[0].u.data) ){ if ((ret=fix_actions((struct action*)t->elem[0].u.data))<0) return ret; } break; case MODULE_T: cmd = (cmd_export_t*)t->elem[0].u.data; LM_DBG("fixing %s, line %d\n", cmd->name, t->line); if (cmd->fixup){ if (cmd->param_no>0){ ret=cmd->fixup(&t->elem[1].u.data, 1); t->elem[1].type=MODFIXUP_ST; if (ret<0) goto error; } if (cmd->param_no>1){ ret=cmd->fixup(&t->elem[2].u.data, 2); t->elem[2].type=MODFIXUP_ST; if (ret<0) goto error; } if (cmd->param_no==0){ ret=cmd->fixup( 0, 0); if (ret<0) goto error; } } break; case FORCE_SEND_SOCKET_T: if (t->elem[0].type!=SOCKID_ST){ LM_CRIT("invalid subtype %d for force_send_socket\n", t->elem[0].type); return E_BUG; } he=resolvehost(((struct socket_id*)t->elem[0].u.data)->name,0); if (he==0){ LM_ERR(" could not resolve %s\n", ((struct socket_id*)t->elem[0].u.data)->name); ret = E_BAD_ADDRESS; goto error; } hostent2ip_addr(&ip, he, 0); si=find_si(&ip, ((struct socket_id*)t->elem[0].u.data)->port, ((struct socket_id*)t->elem[0].u.data)->proto); if (si==0){ LM_ERR("bad force_send_socket" " argument: %s:%d (ser doesn't listen on it)\n", ((struct socket_id*)t->elem[0].u.data)->name, ((struct socket_id*)t->elem[0].u.data)->port); ret = E_BAD_ADDRESS; goto error; } t->elem[0].u.data=si; t->elem[0].type=SOCKETINFO_ST; break; case SET_DEBUG_T: if (t->elem[0].type==NOSUBTYPE) break; if (t->elem[0].type!=NUMBER_ST) { LM_CRIT("fix_actions: BUG in setdebug() type %d\n", t->elem[0].type ); ret=E_BUG; goto error; } /* normalize the value */ if (t->elem[0].u.number>L_DBG) t->elem[0].u.number = L_DBG; else if (t->elem[0].u.number<L_ALERT) t->elem[0].u.number = L_ALERT; break; case SETFLAG_T: case RESETFLAG_T: case ISFLAGSET_T: if (t->elem[0].type!=NUMBER_ST) { LM_CRIT("bad xxxflag() type %d\n", t->elem[0].type ); ret=E_BUG; goto error; } if (!flag_in_range( t->elem[0].u.number )) { ret=E_CFG; goto error; } break; case SETSFLAG_T: case RESETSFLAG_T: case ISSFLAGSET_T: if (t->elem[0].type!=NUMBER_ST) { LM_CRIT("bad xxxsflag() type %d\n", t->elem[0].type ); ret=E_BUG; goto error; } t->elem[0].u.number = fixup_flag( t->elem[0].u.number ); if (t->elem[0].u.data==0) { ret=E_CFG; goto error; } break; case SETBFLAG_T: case RESETBFLAG_T: case ISBFLAGSET_T: if (t->elem[0].type!=NUMBER_ST || t->elem[1].type!=NUMBER_ST) { LM_CRIT("bad xxxbflag() type " "%d,%d\n", t->elem[0].type, t->elem[0].type); ret=E_BUG; goto error; } t->elem[1].u.number = fixup_flag( t->elem[1].u.number ); if (t->elem[1].u.data==0) { ret=E_CFG; goto error; } break; case EQ_T: case COLONEQ_T: case PLUSEQ_T: case MINUSEQ_T: case DIVEQ_T: case MULTEQ_T: case MODULOEQ_T: case BANDEQ_T: case BOREQ_T: case BXOREQ_T: if (t->elem[1].u.data){ if ((ret=fix_expr((struct expr*)t->elem[1].u.data))<0) return ret; } break; case USE_BLACKLIST_T: if (t->elem[0].type!=STRING_ST) { LM_CRIT("bad USE_BLACKLIST type %d\n", t->elem[0].type); ret=E_BUG; goto error; } host.s = t->elem[0].u.string; host.len = strlen(host.s); blh = get_bl_head_by_name(&host); if (blh==NULL) { LM_ERR("USE_BLACKLIST - list " "%s not configured\n", t->elem[0].u.string); ret=E_CFG; goto error; } t->elem[0].type = BLACKLIST_ST; t->elem[0].u.data = blh; break; } } return 0; error: LM_ERR("fixing failed (code=%d) at cfg line %d\n", ret, t->line); return ret; }