config.c File Reference


Detailed Description

CDiameterPeer - start-up configuration.

Author:
Dragos Vingarzan vingarzan -at- fokus dot fraunhofer dot de

Definition in file config.c.

#include "config.h"

Go to the source code of this file.

Functions

dp_confignew_dp_config ()
 Create a new dp_config.
routing_realmnew_routing_realm ()
 Create a new dp_config.
routing_entrynew_routing_entry ()
 Create a new dp_config.
void free_routing_entry (routing_entry *re)
 Free the space claimed by a routing entry.
void free_routing_realm (routing_realm *rr)
 Free the space claimed by a routing realm.
void free_dp_config (dp_config *x)
 Frees the memory held by a dp_config.
void log_dp_config (int level, dp_config *x)
 Log the dp_config to output, for debug purposes.


Function Documentation

dp_config* new_dp_config (  )  [inline]

Create a new dp_config.

Definition at line 59 of file config.c.

References LOG_NO_MEM.

Referenced by parse_dp_config().

00060 {
00061     dp_config *x;   
00062     x = shm_malloc(sizeof(dp_config));
00063     if (!x) {
00064         LOG_NO_MEM("shm",sizeof(dp_config));
00065         goto error;
00066     }   
00067     memset(x,0,sizeof(dp_config));
00068     return x;
00069 error:
00070     LOG(L_ERR,"ERROR:%s(): failed to create new dp_config.\n",__FUNCTION__);    
00071     return 0;
00072 }

routing_realm* new_routing_realm (  )  [inline]

Create a new dp_config.

Definition at line 77 of file config.c.

References LOG_NO_MEM.

Referenced by parse_dp_config().

00078 {
00079     routing_realm *x;   
00080     x = shm_malloc(sizeof(routing_realm));
00081     if (!x) {
00082         LOG_NO_MEM("shm",sizeof(routing_realm));
00083         goto error;
00084     }   
00085     memset(x,0,sizeof(routing_realm));
00086     return x;
00087 error:
00088     LOG(L_ERR,"ERROR:%s(): failed to create new routing_realm.\n",__FUNCTION__);    
00089     return 0;
00090 }

routing_entry* new_routing_entry (  )  [inline]

Create a new dp_config.

Definition at line 95 of file config.c.

References LOG_NO_MEM.

Referenced by parse_dp_config().

00096 {
00097     routing_entry *x;   
00098     x = shm_malloc(sizeof(routing_entry));
00099     if (!x) {
00100         LOG_NO_MEM("shm",sizeof(routing_entry));
00101         goto error;
00102     }   
00103     memset(x,0,sizeof(routing_entry));
00104     return x;
00105 error:
00106     LOG(L_ERR,"ERROR:%s(): failed to create new routing_entry.\n",__FUNCTION__);    
00107     return 0;
00108 }

void free_routing_entry ( routing_entry re  )  [inline]

Free the space claimed by a routing entry.

Definition at line 114 of file config.c.

References _routing_entry::fqdn.

Referenced by free_dp_config(), and free_routing_realm().

00115 {
00116     if (!re) return;
00117     if (re->fqdn.s) shm_free(re->fqdn.s);
00118     shm_free(re);
00119 }

void free_routing_realm ( routing_realm rr  )  [inline]

Free the space claimed by a routing realm.

Definition at line 124 of file config.c.

References free_routing_entry(), _routing_entry::next, _routing_realm::realm, and _routing_realm::routes.

Referenced by free_dp_config().

00125 {
00126     routing_entry *re,*ren;
00127     if (!rr) return;
00128     if (rr->realm.s) shm_free(rr->realm.s);
00129     for(re=rr->routes;re;re=ren){
00130         ren = re->next;
00131         free_routing_entry(re);
00132     }
00133     shm_free(rr);
00134 }

void free_dp_config ( dp_config x  )  [inline]

Frees the memory held by a dp_config.

Definition at line 142 of file config.c.

References dp_config::acceptors, dp_config::acceptors_cnt, dp_config::applications, acceptor_config::bind, dp_config::fqdn, peer_config::fqdn, free_routing_entry(), free_routing_realm(), dp_config::identity, if, _routing_realm::next, _routing_entry::next, dp_config::peers, dp_config::peers_cnt, dp_config::product_name, dp_config::r_table, dp_config::realm, peer_config::realm, routing_table::realms, and routing_table::routes.

Referenced by diameter_peer_destroy(), diameter_peer_init(), and parse_dp_config().

00143 {
00144     int i;
00145     if (!x) return;
00146     if (x->fqdn.s) shm_free(x->fqdn.s);
00147     if (x->identity.s) shm_free(x->identity.s);
00148     if (x->realm.s) shm_free(x->realm.s);
00149     if (x->product_name.s) shm_free(x->product_name.s);
00150     if (x->peers) {
00151         for(i=0;i<x->peers_cnt;i++){
00152             if (x->peers[i].fqdn.s) shm_free(x->peers[i].fqdn.s);
00153             if (x->peers[i].realm.s) shm_free(x->peers[i].realm.s);
00154         }
00155         shm_free(x->peers);
00156     }
00157     if (x->acceptors) {
00158         for(i=0;i<x->acceptors_cnt;i++){
00159             if (x->acceptors[i].bind.s) shm_free(x->acceptors[i].bind.s);
00160         }       
00161         shm_free(x->acceptors);
00162     }
00163     if (x->applications) shm_free(x->applications);
00164     
00165     if (x->r_table) {
00166         routing_realm *rr,*rrn;
00167         routing_entry *re,*ren;
00168         for(rr=x->r_table->realms;rr;rr=rrn){
00169             rrn = rr->next;
00170             free_routing_realm(rr);
00171         }
00172         for(re=x->r_table->routes;re;re=ren){
00173             ren = re->next;
00174             free_routing_entry(re);
00175         }
00176         shm_free(x->r_table);
00177     }   
00178     shm_free(x);
00179 }

void log_dp_config ( int  level,
dp_config x 
) [inline]

Log the dp_config to output, for debug purposes.

Definition at line 184 of file config.c.

References dp_config::accept_unknown_peers, dp_config::acceptors, dp_config::acceptors_cnt, dp_config::applications, dp_config::applications_cnt, acceptor_config::bind, DP_AUTHORIZATION, dp_config::drop_unknown_peers, dp_config::fqdn, peer_config::fqdn, app_config::id, if, _routing_realm::next, dp_config::peers, dp_config::peers_cnt, peer_config::port, acceptor_config::port, dp_config::product_name, dp_config::queue_length, dp_config::r_table, dp_config::realm, peer_config::realm, routing_table::realms, dp_config::tc, app_config::type, app_config::vendor, dp_config::vendor_id, and dp_config::workers.

Referenced by diameter_peer_init().

00185 {
00186     int i;
00187     LOG(level,"Diameter Peer Config:\n");
00188     LOG(level,"\tFQDN    : %.*s\n",x->fqdn.len,x->fqdn.s);
00189     LOG(level,"\tRealm   : %.*s\n",x->realm.len,x->realm.s);
00190     LOG(level,"\tVendorID: %d\n",x->vendor_id);
00191     LOG(level,"\tProdName: %.*s\n",x->product_name.len,x->product_name.s);
00192     LOG(level,"\tAcceptUn: [%c]\n",x->accept_unknown_peers?'X':' ');
00193     LOG(level,"\tDropUnkn: [%c]\n",x->drop_unknown_peers?'X':' ');
00194     LOG(level,"\tTc      : %d\n",x->tc);
00195     LOG(level,"\tWorkers : %d\n",x->workers);
00196     LOG(level,"\tQueueLen: %d\n",x->queue_length);
00197     LOG(level,"\tPeers : %d\n",x->peers_cnt);
00198     for(i=0;i<x->peers_cnt;i++)
00199         LOG(level,"\t\tFQDN:  %.*s \t Realm: %.*s \t Port: %d\n",
00200             x->peers[i].fqdn.len,x->peers[i].fqdn.s,
00201             x->peers[i].realm.len,x->peers[i].realm.s,
00202             x->peers[i].port);
00203     LOG(level,"\tAcceptors : %d\n",x->acceptors_cnt);
00204     for(i=0;i<x->acceptors_cnt;i++)
00205         LOG(level,"\t\tPort:  %d \t Bind: %.*s \n",
00206             x->acceptors[i].port,
00207             x->acceptors[i].bind.len,x->acceptors[i].bind.s);
00208     LOG(level,"\tApplications : %d\n",x->applications_cnt);
00209     for(i=0;i<x->applications_cnt;i++)
00210         LOG(level,"\t\t%s ID:  %d \t Vendor: %d \n",
00211             (x->applications[i].type==DP_AUTHORIZATION)?"Auth":"Acct",
00212             x->applications[i].id,
00213             x->applications[i].vendor); 
00214     if (x->r_table){
00215         routing_realm *rr;
00216         routing_entry *re;
00217         LOG(level,"\tRouting Table : \n");
00218         for(rr=x->r_table->realms;rr;rr=rr->next){
00219             LOG(level,"\t\tRealm: %.*s\n",
00220                 rr->realm.len,rr->realm.s);
00221             for(re=rr->routes;re;re=re->next)       
00222                 LOG(level,"\t\t\tRoute: [%4d] %.*s\n",
00223                     re->metric,re->fqdn.len,re->fqdn.s);            
00224         }
00225         for(re=x->r_table->routes;re;re=re->next)       
00226             LOG(level,"\t\tDefaultRoute: [%4d] %.*s\n",
00227                 re->metric,re->fqdn.len,re->fqdn.s);            
00228     }
00229     
00230 }


Generated on Tue Jul 29 04:19:13 2008 for Open IMS Core CSCFs by  doxygen 1.5.2