-XBT_LOG_NEW_DEFAULT_SUBCATEGORY(transport,gras,"Conveying bytes over the network");
-XBT_LOG_NEW_SUBCATEGORY(raw_trp,transport,"Conveying bytes over the network without formating");
-
-static xbt_dict_t _gras_trp_plugins; /* All registered plugins */
-static void gras_trp_plugin_free(void *p); /* free one of the plugins */
-
-static void gras_trp_socket_free(void *s); /* free one socket */
-
-static void
-gras_trp_plugin_new(const char *name, gras_trp_setup_t setup) {
- xbt_error_t errcode;
-
- gras_trp_plugin_t *plug = xbt_new0(gras_trp_plugin_t, 1);
-
- DEBUG1("Create plugin %s",name);
-
- plug->name=xbt_strdup(name);
-
- errcode = setup(plug);
- switch (errcode) {
- case mismatch_error:
- /* SG plugin return mismatch when in RL mode (and vice versa) */
- xbt_free(plug->name);
- xbt_free(plug);
- break;
-
- case no_error:
- xbt_dict_set(_gras_trp_plugins,
- name, plug, gras_trp_plugin_free);
- break;
-
- default:
- DIE_IMPOSSIBLE;
- }
-
-}
-
-void gras_trp_init(void){
- /* make room for all plugins */
- _gras_trp_plugins=xbt_dict_new();
-
- /* Add them */
- gras_trp_plugin_new("tcp", gras_trp_tcp_setup);
- gras_trp_plugin_new("file",gras_trp_file_setup);
- gras_trp_plugin_new("sg",gras_trp_sg_setup);
-
- /* buf is composed, so it must come after the others */
- gras_trp_plugin_new("buf", gras_trp_buf_setup);
-
-}
-
-void
-gras_trp_exit(void){
- xbt_dict_free(&_gras_trp_plugins);
-}
-
-
-void gras_trp_plugin_free(void *p) {
- gras_trp_plugin_t *plug = p;
-
- if (plug) {
- if (plug->exit) {
- plug->exit(plug);
- } else if (plug->data) {
- DEBUG1("Plugin %s lacks exit(). Free data anyway.",plug->name);
- xbt_free(plug->data);
- }
-
- xbt_free(plug->name);
- xbt_free(plug);
- }
-}
-