Index: channels/chan_h323.c
===================================================================
RCS file: /usr/cvsroot/asterisk/channels/chan_h323.c,v
retrieving revision 1.110
diff -u -r1.110 chan_h323.c
--- channels/chan_h323.c	29 Apr 2005 17:00:33 -0000	1.110
+++ channels/chan_h323.c	1 May 2005 10:52:29 -0000
@@ -357,7 +357,8 @@
 	if (user) {
 		memset(user, 0, sizeof(struct oh323_user));
 		strncpy(user->name, name, sizeof(user->name) - 1);
-		user->options.dtmfcodec = 101;
+		memcpy(&user->options, &global_options, sizeof(user->options));
+		user->capability = capability;
 		/* set a native brigding default value */
 		user->bridge = bridging;
 		/* and default context */
@@ -367,8 +368,8 @@
 				strncpy(user->context, v->value, sizeof(user->context) - 1);
 			} else if (!strcasecmp(v->name, "bridge")) {
 				user->bridge = ast_true(v->value);
-                      } else if (!strcasecmp(v->name, "nat")) {
-                              user->nat = ast_true(v->value);
+			} else if (!strcasecmp(v->name, "nat")) {
+				user->nat = ast_true(v->value);
 			} else if (!strcasecmp(v->name, "noFastStart")) {
 				user->options.noFastStart = ast_true(v->value);
 			} else if (!strcasecmp(v->name, "noH245Tunneling")) {
@@ -403,6 +404,29 @@
 				user->options.progress_audio = ast_true(v->value);
 			} else if (!strcasecmp(v->name, "dtmfcodec")) {
 				user->options.dtmfcodec = atoi(v->value);
+			} else if (!strcasecmp(v->name, "dtmfmode")) {
+				if (!strcasecmp(v->value, "inband")) {
+					user->dtmfmode = H323_DTMF_INBAND;
+				} else if (!strcasecmp(v->value, "rfc2833")) {
+					user->dtmfmode = H323_DTMF_RFC2833;
+				} else {
+					ast_log(LOG_WARNING, "Unknown DTMF Mode %s, using RFC2833\n", v->value);
+					user->dtmfmode = H323_DTMF_RFC2833;
+				}	
+			} else if (!strcasecmp(v->name, "allow")) {
+				format = ast_getformatbyname(v->value);
+				if (format < 1) {
+					ast_log(LOG_WARNING, "Cannot allow unknown format '%s'\n", v->value);
+				} else {
+					user->capability |= format;
+				}
+			} else if (!strcasecmp(v->name, "disallow")) {
+				format = ast_getformatbyname(v->value);
+				if (format < 1) {
+					ast_log(LOG_WARNING, "Cannot disallow unknown format '%s'\n", v->value);
+				} else {
+					user->capability &= ~format;
+				}
 			} else if (!strcasecmp(v->name, "host")) {
 				if (!strcasecmp(v->value, "dynamic")) {
 					ast_log(LOG_ERROR, "A dynamic host on a type=user does not make any sense\n");
@@ -473,8 +497,9 @@
 		peer->ha = NULL;
 		peer->addr.sin_family = AF_INET;
 		peer->capability = capability;
-		peer->options.dtmfcodec = 101;
-		peer->dtmfmode = H323_DTMF_RFC2833;
+		peer->dtmfmode = dtmfmode;
+		peer->bridge = bridging;
+		memcpy(&peer->options, &global_options, sizeof(peer->options));
 
 		while(v) {
 			if (!strcasecmp(v->name, "bridge")) {
@@ -530,7 +555,7 @@
 				if (format < 1) {
 					ast_log(LOG_WARNING, "Cannot disallow unknown format '%s'\n", v->value);
 				} else {
-					peer->capability |= ~format;
+					peer->capability &= ~format;
 				}
 			} else if (!strcasecmp(v->name, "host")) {
 				if (!strcasecmp(v->value, "dynamic")) {
@@ -1537,7 +1562,7 @@
 			}
 			strncpy(pvt->context, user->context, sizeof(pvt->context) - 1);
 			pvt->bridge = user->bridge;
-                      	pvt->nat = user->nat;
+			pvt->nat = user->nat;
 			if (!ast_strlen_zero(pvt->cd.call_dest_e164)) {
 				strncpy(pvt->exten, cd.call_dest_e164, sizeof(pvt->exten) - 1);
 			} else {
@@ -2043,13 +2068,13 @@
 		} else if (!strcasecmp(v->name, "dtmfcodec")) {
 			global_options.dtmfcodec = atoi(v->value);
 		} else if (!strcasecmp(v->name, "UserByAlias")) {
-                        userbyalias = ast_true(v->value);
-                } else if (!strcasecmp(v->name, "bridge")) {
-                        bridging = ast_true(v->value);
-                } else if (!strcasecmp(v->name, "noFastStart")) {
-                        global_options.noFastStart = ast_true(v->value);
-                } else if (!strcasecmp(v->name, "noH245Tunneling")) {
-                        global_options.noH245Tunneling = ast_true(v->value);
+			userbyalias = ast_true(v->value);
+		} else if (!strcasecmp(v->name, "bridge")) {
+			bridging = ast_true(v->value);
+		} else if (!strcasecmp(v->name, "noFastStart")) {
+			global_options.noFastStart = ast_true(v->value);
+		} else if (!strcasecmp(v->name, "noH245Tunneling")) {
+			global_options.noH245Tunneling = ast_true(v->value);
 		} else if (!strcasecmp(v->name, "noSilenceSuppression")) {
 			global_options.noSilenceSuppression = ast_true(v->value);
 		}
@@ -2061,7 +2086,7 @@
 		if (strcasecmp(cat, "general")) {
 			utype = ast_variable_retrieve(cfg, cat, "type");
 			if (utype) {
-				if (!strcasecmp(utype, "user") || !strcasecmp(utype, "friend")) {
+				if (!strcasecmp(utype, "user")) {
 					user = build_user(cat, ast_variable_browse(cfg, cat));
 					if (user) {
 						ast_mutex_lock(&userl.lock);
@@ -2069,8 +2094,23 @@
 						userl.users = user;
 						ast_mutex_unlock(&userl.lock);
 					}
-				}  else if (!strcasecmp(utype, "peer") || !strcasecmp(utype, "friend")) {
+				}  else if (!strcasecmp(utype, "peer")) {
+					peer = build_peer(cat, ast_variable_browse(cfg, cat));
+					if (peer) {
+						ast_mutex_lock(&peerl.lock);
+						peer->next = peerl.peers;
+						peerl.peers = peer;
+						ast_mutex_unlock(&peerl.lock);
+					}
+				}  else if (!strcasecmp(utype, "friend")) {
+					user = build_user(cat, ast_variable_browse(cfg, cat));
 					peer = build_peer(cat, ast_variable_browse(cfg, cat));
+					if (user) {
+						ast_mutex_lock(&userl.lock);
+						user->next = userl.users;
+						userl.users = user;
+						ast_mutex_unlock(&userl.lock);
+					}
 					if (peer) {
 						ast_mutex_lock(&peerl.lock);
 						peer->next = peerl.peers;
Index: channels/h323/ast_h323.cpp
===================================================================
RCS file: /usr/cvsroot/asterisk/channels/h323/ast_h323.cpp,v
retrieving revision 1.72
diff -u -r1.72 ast_h323.cpp
--- channels/h323/ast_h323.cpp	29 Apr 2005 04:22:28 -0000	1.72
+++ channels/h323/ast_h323.cpp	1 May 2005 10:52:30 -0000
@@ -298,7 +298,7 @@
 			cout << " -- Making call to " << fullAddress << " without gatekeeper." << endl;
 		}
 	}
-	if (!(connection = (MyH323Connection *)H323EndPoint::MakeCallLocked(fullAddress, token))) {
+	if (!(connection = (MyH323Connection *)H323EndPoint::MakeCallLocked(fullAddress, token, opts))) {
 		if (h323debug) {
 			cout << "Error making call to \"" << fullAddress << '"' << endl;
 		}
Index: channels/h323/chan_h323.h
===================================================================
RCS file: /usr/cvsroot/asterisk/channels/h323/chan_h323.h,v
retrieving revision 1.38
diff -u -r1.38 chan_h323.h
--- channels/h323/chan_h323.h	4 Apr 2005 07:06:26 -0000	1.38
+++ channels/h323/chan_h323.h	1 May 2005 10:52:30 -0000
@@ -31,16 +31,16 @@
 /** call_option struct holds various bits
  *         of information for each call */
 typedef struct call_options {
-	char            cid_num[80];
-	char            cid_name[80];
-	int             noFastStart;
-	int             noH245Tunneling;
-	int             noSilenceSuppression;
-	unsigned int    port;
-	int             progress_setup;
-	int             progress_alert;
-	int             progress_audio;
-	int		dtmfcodec;
+	char			cid_num[80];
+	char			cid_name[80];
+	int				noFastStart;
+	int				noH245Tunneling;
+	int				noSilenceSuppression;
+	unsigned int	port;
+	int				progress_setup;
+	int				progress_alert;
+	int				progress_audio;
+	int				dtmfcodec;
 } call_options_t;
 
 /* structure to hold the valid asterisk users */
@@ -51,6 +51,7 @@
 	char callerid[80];
 	char accountcode[20];
 	int amaflags;
+	int capability;
 	int bridge;
 	int nat;
 	int dtmfmode;
