int meta2_filter_extract_header_storage_policy(struct gridd_filter_ctx_s *ctx, struct gridd_reply_ctx_s *reply) { GError *e = NULL; char buf[65]; TRACE_FILTER(); EXTRACT_STRING(NAME_MSGKEY_STGPOLICY, TRUE); return FILTER_OK; }
int meta2_filter_extract_header_string_size(struct gridd_filter_ctx_s *ctx, struct gridd_reply_ctx_s *reply) { GError *e = NULL; gchar buf[64]; const char *opt = meta2_filter_ctx_get_param(ctx, "CONTENT_LENGTH_OPT"); TRACE_FILTER(); EXTRACT_STRING(NAME_MSGKEY_CONTENTLENGTH, (opt != NULL)); return FILTER_OK; }
int meta2_filter_extract_header_copy(struct gridd_filter_ctx_s *ctx, struct gridd_reply_ctx_s *reply) { GError *e = NULL; char buf[512]; TRACE_FILTER(); EXTRACT_STRING(NAME_MSGKEY_COPY, TRUE); if (NULL != meta2_filter_ctx_get_param(ctx, NAME_MSGKEY_COPY)) meta2_filter_ctx_add_param(ctx, "BODY_OPT", "OK"); return FILTER_OK; }
PyObject* AcdkPythonProxy::peek(PyObject* self, PyObject* args) { EXTRACT_SELF_APP(); CHECK_ARGS(args, 1, !=, "acdk.Object.peek needs 1 argument"); const char* membername; EXTRACT_STRING( membername , PyTuple_GET_ITEM(args, 0) , "acdk.Object.peek expects 1 string arg"); ScriptVar retv = This->peek(membername); PyObject* ret = 0; if (acdk2python(retv, ret) == true) return ret; return 0; }
static void timer_send_full_state_notifies(int round) { db_key_t query_cols[1], result_cols[22], update_cols[1]; db_val_t query_vals[1], update_vals[1], *values; db_row_t *rows; db1_res_t *result = NULL; int n_result_cols = 0, i; int pres_uri_col, tuser_col, tdomain_col, fuser_col, fdomain_col; int wuser_col, wdomain_col, callid_col, to_tag_col, from_tag_col; int sockinfo_col, lcontact_col, contact_col, rroute_col, event_id_col; int reason_col, event_col, lcseq_col, rcseq_col, status_col; int version_col, expires_col; subs_t sub; str ev_sname; event_t parsed_event; xmlDocPtr doc = NULL; xmlNodePtr service_node = NULL; int now = (int)time(NULL); query_cols[0] = &str_updated_col; query_vals[0].type = DB1_INT; query_vals[0].nul = 0; query_vals[0].val.int_val = round; result_cols[pres_uri_col = n_result_cols++] = &str_presentity_uri_col; result_cols[tuser_col = n_result_cols++] = &str_to_user_col; result_cols[tdomain_col = n_result_cols++] = &str_to_domain_col; result_cols[fuser_col = n_result_cols++] = &str_from_user_col; result_cols[fdomain_col = n_result_cols++] = &str_from_domain_col; result_cols[wuser_col = n_result_cols++] = &str_watcher_username_col; result_cols[wdomain_col = n_result_cols++] = &str_watcher_domain_col; result_cols[callid_col = n_result_cols++] = &str_callid_col; result_cols[to_tag_col = n_result_cols++] = &str_to_tag_col; result_cols[from_tag_col = n_result_cols++] = &str_from_tag_col; result_cols[sockinfo_col = n_result_cols++] = &str_socket_info_col; result_cols[lcontact_col = n_result_cols++] = &str_local_contact_col; result_cols[contact_col = n_result_cols++] = &str_contact_col; result_cols[rroute_col = n_result_cols++] = &str_record_route_col; result_cols[event_id_col = n_result_cols++] = &str_event_id_col; result_cols[reason_col = n_result_cols++] = &str_reason_col; result_cols[event_col = n_result_cols++] = &str_event_col; result_cols[lcseq_col = n_result_cols++] = &str_local_cseq_col; result_cols[rcseq_col = n_result_cols++] = &str_remote_cseq_col; result_cols[status_col = n_result_cols++] = &str_status_col; result_cols[version_col = n_result_cols++] = &str_version_col; result_cols[expires_col = n_result_cols++] = &str_expires_col; update_cols[0] = &str_updated_col; update_vals[0].type = DB1_INT; update_vals[0].nul = 0; update_vals[0].val.int_val = NO_UPDATE_TYPE; if (rls_dbf.use_table(rls_db, &rlsubs_table) < 0) { LM_ERR("use table failed\n"); goto done; } if (dbmode == RLS_DB_ONLY && rls_dbf.start_transaction) { if (rls_dbf.start_transaction(rls_db) < 0) { LM_ERR("in start_transaction\n"); goto done; } } /* Step 1: Find rls_watchers that require full-state notification */ if (rls_dbf.query(rls_db, query_cols, 0, query_vals, result_cols, 1, n_result_cols, 0, &result) < 0) { LM_ERR("in sql query\n"); goto done; } if(result== NULL || result->n<= 0) goto done; /* Step 2: Reset the update flag so we do not full-state notify these watchers again */ if(rls_dbf.update(rls_db, query_cols, 0, query_vals, update_cols, update_vals, 1, 1)< 0) { LM_ERR("in sql update\n"); goto done; } if (dbmode == RLS_DB_ONLY && rls_dbf.end_transaction) { if (rls_dbf.end_transaction(rls_db) < 0) { LM_ERR("in end_transaction\n"); goto done; } } /* Step 3: Full-state notify each watcher we found */ rows = RES_ROWS(result); for (i = 0; i < RES_ROW_N(result); i++) { memset(&sub, 0, sizeof(subs_t)); values = ROW_VALUES(&rows[i]); EXTRACT_STRING(sub.pres_uri, VAL_STRING(&values[pres_uri_col])); EXTRACT_STRING(sub.to_user, VAL_STRING(&values[tuser_col])); EXTRACT_STRING(sub.to_domain, VAL_STRING(&values[tdomain_col])); EXTRACT_STRING(sub.from_user, VAL_STRING(&values[fuser_col])); EXTRACT_STRING(sub.from_domain, VAL_STRING(&values[fdomain_col])); EXTRACT_STRING(sub.watcher_user, VAL_STRING(&values[wuser_col])); EXTRACT_STRING(sub.watcher_domain, VAL_STRING(&values[wdomain_col])); EXTRACT_STRING(sub.callid, VAL_STRING(&values[callid_col])); EXTRACT_STRING(sub.to_tag, VAL_STRING(&values[to_tag_col])); EXTRACT_STRING(sub.from_tag, VAL_STRING(&values[from_tag_col])); EXTRACT_STRING(sub.sockinfo_str, VAL_STRING(&values[sockinfo_col])); EXTRACT_STRING(sub.local_contact, VAL_STRING(&values[lcontact_col])); EXTRACT_STRING(sub.contact, VAL_STRING(&values[contact_col])); EXTRACT_STRING(sub.record_route, VAL_STRING(&values[rroute_col])); EXTRACT_STRING(sub.event_id, VAL_STRING(&values[event_id_col])); EXTRACT_STRING(sub.reason, VAL_STRING(&values[reason_col])); EXTRACT_STRING(ev_sname, VAL_STRING(&values[event_col])); sub.event = pres_contains_event(&ev_sname, &parsed_event); if (sub.event == NULL) { LM_ERR("event not found and set to NULL\n"); goto done; } sub.local_cseq = VAL_INT(&values[lcseq_col]); sub.remote_cseq = VAL_INT(&values[rcseq_col]); sub.status = VAL_INT(&values[status_col]); sub.version = VAL_INT(&values[version_col]); if (VAL_INT(&values[expires_col]) > now + rls_expires_offset) { sub.expires = VAL_INT(&values[expires_col]) - now; if (rls_get_service_list(&sub.pres_uri, &sub.watcher_user, &sub.watcher_domain, &service_node, &doc) < 0) { LM_ERR("failed getting resource list\n"); goto done; } if (doc == NULL) { LM_WARN("no document returned for uri <%.*s>\n", sub.pres_uri.len, sub.pres_uri.s); goto done; } if (send_full_notify(&sub, service_node, &sub.pres_uri, 0) < 0) { LM_ERR("failed sending full state notify\n"); goto done; } xmlFreeDoc(doc); doc = NULL; } else { sub.expires = 0; rls_send_notify(&sub, NULL, NULL, NULL); delete_rlsdb(&sub.callid, &sub.to_tag, &sub.from_tag); } } done: if (result != NULL) rls_dbf.free_result(rls_db, result); if (doc != NULL) xmlFreeDoc(doc); if (dbmode == RLS_DB_ONLY && rls_dbf.abort_transaction) { if (rls_dbf.abort_transaction(rls_db) < 0) LM_ERR("in abort_transaction\n"); } }
void FWPprocessMessages( IceConn iceConn, IcePointer * client_data, int opcode, unsigned long length, Bool swap) { switch (opcode) { /* * this is really the only opcode we care about -- the one * which indicates an XFindProxy request for a connection * to a specified server */ case PM_GetProxyAddr: { pmGetProxyAddrMsg *pMsg; char *pData, *pStart; char *serviceName = NULL, *serverAddress = NULL; char *hostAddress = NULL, *startOptions = NULL; char *authName = NULL, *authData = NULL; int authLen; struct clientDataStruct * program_data; char * listen_port_string; int pm_send_msg_len; pmGetProxyAddrReplyMsg * pReply; char * pReplyData; struct hostent * hostptr; struct sockaddr_in server_sockaddr_in; struct sockaddr_in dummy_sockaddr_in; char * server_name_base; char * config_failure = "unrecognized server or permission denied"; char * tmp_str; int rule_number = -1; char * colon; char * tmpAddress = NULL; /* * this is where we need and get access to that client data we * went through such contortions to set up earlier! */ program_data = (struct clientDataStruct *) client_data; /* * initial check on expected message size */ CHECK_AT_LEAST_SIZE (iceConn, global_data.major_opcode, opcode, length, SIZEOF (pmGetProxyAddrMsg), IceFatalToProtocol); IceReadCompleteMessage (iceConn, SIZEOF (pmGetProxyAddrMsg), pmGetProxyAddrMsg, pMsg, pStart); if (!IceValidIO (iceConn)) { IceDisposeCompleteMessage (iceConn, pStart); return; } authLen = swap ? lswaps (pMsg->authLen) : pMsg->authLen; pData = pStart; SKIP_STRING (pData, swap); /* proxy-service */ SKIP_STRING (pData, swap); /* server-address */ SKIP_STRING (pData, swap); /* host-address */ SKIP_STRING (pData, swap); /* start-options */ if (authLen > 0) { SKIP_STRING (pData, swap); /* auth-name */ pData += (authLen + PAD64 (authLen)); /* auth-data */ } /* * now a detailed check on message size */ CHECK_COMPLETE_SIZE (iceConn, global_data.major_opcode, opcode, length, pData - pStart + SIZEOF (pmGetProxyAddrMsg), pStart, IceFatalToProtocol); pData = pStart; /* * extract message data, based on known characteristics * of this message type */ EXTRACT_STRING (pData, swap, serviceName); EXTRACT_STRING (pData, swap, serverAddress); EXTRACT_STRING (pData, swap, hostAddress); EXTRACT_STRING (pData, swap, startOptions); if (authLen > 0) { EXTRACT_STRING (pData, swap, authName); authData = (char *) malloc (authLen); memcpy (authData, pData, authLen); } #ifdef DEBUG (void) fprintf (stderr, "Got GetProxyAddr, serviceName = %s, serverAddr = %s\n", serviceName, serverAddress); (void) fprintf (stderr, "\thostAddr = %s, options = %s, authLen = %d\n", hostAddress, startOptions, authLen); if (authLen > 0) (void) fprintf (stderr, "\tauthName = %s\n", authName); #endif /* * need to copy the host port string because strtok() changes it */ if ((tmp_str = strdup (serverAddress)) == NULL) { (void) fprintf(stderr, "malloc - serverAddress copy\n"); goto sendFailure; } /* * before proceeding we want to verify that we are allowed to * accept connections from the host who called xfindproxy(); * the thing is, we don't get that host name from Proxy Manager * even if the "-host <hostname>" command-line option was present * in xfindproxy (and even if it was we shouldn't rely on it -- * much better to have ProxyMngr query the xfindproxy connect * socket for its origin); the upshot of all this that we do * a configuration check *only* on the destination (which we * assume in this case to be the serverAddress passed in by * xfindproxy(); so get the destination IP address! */ server_name_base = strtok(tmp_str, ":"); if ((hostptr = gethostbyname(server_name_base)) == NULL) { (void) fprintf(stderr, "gethostbyname (%s) failed\n", server_name_base); goto sendFailure; } memset(&server_sockaddr_in, 0, sizeof(server_sockaddr_in)); memset(&dummy_sockaddr_in, 0, sizeof(dummy_sockaddr_in)); memcpy((char *) &server_sockaddr_in.sin_addr, hostptr->h_addr, hostptr->h_length); /* * need to initialize dummy to something, but doesn't matter * what (should eventually be the true host address); * NOTE: source configuration will always match (see XFWP man * page) unless sysadmin explicitly chooses to deny */ memcpy((char *) &dummy_sockaddr_in.sin_addr, hostptr->h_addr, hostptr->h_length); if ((doConfigCheck(&dummy_sockaddr_in, &server_sockaddr_in, global_data.config_info, FINDPROXY, &rule_number)) == FAILURE) { (void) fprintf(stderr, "xfindproxy failed config check\n"); sendFailure: /* * report failure back to the ProxyMgr * */ pm_send_msg_len = STRING_BYTES(config_failure) + STRING_BYTES(NULL); IceGetHeaderExtra(iceConn, program_data->major_opcode, PM_GetProxyAddrReply, SIZEOF(pmGetProxyAddrReplyMsg), WORD64COUNT (pm_send_msg_len), pmGetProxyAddrReplyMsg, pReply, pReplyData); pReply->status = PM_Failure; STORE_STRING(pReplyData, NULL); STORE_STRING(pReplyData, config_failure); IceFlush(iceConn); free(tmp_str); return; } /* * okay, you got what you need from the PM to proceed, * so extract the fd of the selected connection and use * it to set up the remote client listen port and add * the name of the X server to your list of server connections */ /* * Before checking to see if you already have a PM connection * request for this server, make serverAddress a * FQDN so that synonomous names like oregon:0 and oregon.com:0 * will be recognized as the same Xserver. If this server * already exists, don't allocate another listen port for it - * use the already allocated one */ colon = strchr (serverAddress, ':'); if (colon) { struct hostent *hostent; *colon = '\0'; hostent = gethostbyname (serverAddress); *colon = ':'; if (hostent && hostent->h_name) { tmpAddress = (char *) malloc (strlen (hostent->h_name) + strlen (colon) + 1); (void) sprintf (tmpAddress, "%s%s", hostent->h_name, colon); serverAddress = tmpAddress; } } if ((doCheckServerList(serverAddress, &listen_port_string, program_data->config_info->num_servers)) == FAILURE) { /* * this server name isn't in your list; so set up a new * remote client listen port for it; extract the fd from * the connection and pass it in as index to array lookup */ if ((doSetupRemClientListen(&listen_port_string, program_data, serverAddress)) == FAILURE) { goto sendFailure; } } if (tmpAddress) free (tmpAddress); /* * the PM-sent server address *was* in your list, so send back * the rem client listen port you had already associated with * that server (it will presumably be forwarded to the remote * client through some other channel) * use IceGetHeaderExtra() and the */ pm_send_msg_len = STRING_BYTES(listen_port_string) + STRING_BYTES(NULL); IceGetHeaderExtra(iceConn, program_data->major_opcode, PM_GetProxyAddrReply, SIZEOF(pmGetProxyAddrReplyMsg), WORD64COUNT (pm_send_msg_len), pmGetProxyAddrReplyMsg, pReply, pReplyData); pReply->status = PM_Success; STORE_STRING(pReplyData, listen_port_string); STORE_STRING(pReplyData, NULL); IceFlush(iceConn); /* * before leaving this routine, change the select() timeout * here to be equal to the configured client listen timeout * (otherwise you'll never *get* to your listen timeout * if it's shorter than the startup select() default */ program_data->config_info->select_timeout.tv_sec = program_data->config_info->client_listen_timeout; break; } case ICE_Error: { iceErrorMsg *pMsg; char *pStart; CHECK_AT_LEAST_SIZE (iceConn, global_data.major_opcode, ICE_Error, length, sizeof(iceErrorMsg), IceFatalToProtocol); IceReadCompleteMessage (iceConn, SIZEOF (iceErrorMsg), iceErrorMsg, pMsg, pStart); if (!IceValidIO (iceConn)) { IceDisposeCompleteMessage (iceConn, pStart); return; } if (swap) { pMsg->errorClass = lswaps (pMsg->errorClass); pMsg->offendingSequenceNum = lswapl (pMsg->offendingSequenceNum); } (void) fprintf(stderr, "Proxy Manager reported ICE Error:\n"); (void) fprintf(stderr, "\tclass = 0x%x, offending minor opcode = %d\n", pMsg->errorClass, pMsg->offendingMinorOpcode); (void) fprintf(stderr, "\tseverity = %d, sequence = %ld\n", pMsg->severity, (long)pMsg->offendingSequenceNum); IceDisposeCompleteMessage (iceConn, pStart); break; } default: break; } /* end switch */ }
static void PMprocessMessages(IceConn iceConn, IcePointer clientData, int opcode, unsigned long length, Bool swap, IceReplyWaitInfo *replyWait, Bool *replyReadyRet) { if (replyWait) *replyReadyRet = False; switch (opcode) { case PM_GetProxyAddrReply: if (!replyWait || replyWait->minor_opcode_of_request != PM_GetProxyAddr) { _IceReadSkip (iceConn, length << 3); _IceErrorBadState (iceConn, PMopcode, PM_GetProxyAddrReply, IceFatalToProtocol); } else { pmGetProxyAddrReplyMsg *pMsg; char *pData, *pStart; GetProxyAddrReply *reply = (GetProxyAddrReply *) (replyWait->reply); #if 0 /* No-op */ CHECK_AT_LEAST_SIZE (iceConn, PMopcode, opcode, length, SIZEOF (pmGetProxyAddrReplyMsg), IceFatalToProtocol); #endif IceReadCompleteMessage (iceConn, SIZEOF (pmGetProxyAddrReplyMsg), pmGetProxyAddrReplyMsg, pMsg, pStart); if (!IceValidIO (iceConn)) { IceDisposeCompleteMessage (iceConn, pStart); return; } pData = pStart; SKIP_STRING (pData, swap); /* proxy-address */ SKIP_STRING (pData, swap); /* failure-reason */ CHECK_COMPLETE_SIZE (iceConn, PMopcode, opcode, length, pData - pStart + SIZEOF (pmGetProxyAddrReplyMsg), pStart, IceFatalToProtocol); pData = pStart; EXTRACT_STRING (pData, swap, reply->addr); EXTRACT_STRING (pData, swap, reply->error); reply->status = pMsg->status; *replyReadyRet = True; IceDisposeCompleteMessage (iceConn, pStart); } break; default: { _IceErrorBadMinor (iceConn, PMopcode, opcode, IceCanContinue); _IceReadSkip (iceConn, length << 3); break; } } }