Commit 3f64a8a6 authored by Dafydd Harries's avatar Dafydd Harries

reindent stun.c for consistency

darcs-hash:20070110164644-c9803-71026228f7b135922e39f9d6a7b2d75f77125e0f.gz
parent 90abca99
......@@ -43,7 +43,8 @@ stun_attribute_unpack (guint length, const gchar *s)
g_assert (length);
attr = stun_attribute_new (ntohs (*(guint16 *)s));
switch (attr->type) {
switch (attr->type)
{
case STUN_ATTRIBUTE_MAPPED_ADDRESS:
attr->address.af = (guint8) s[5];
g_assert (attr->address.af == 1);
......@@ -60,7 +61,8 @@ stun_attribute_unpack (guint length, const gchar *s)
guint
stun_attribute_pack (StunAttribute *attr, gchar **packed)
{
switch (attr->type) {
switch (attr->type)
{
case STUN_ATTRIBUTE_MAPPED_ADDRESS:
{
StunAttribute *ret = g_malloc0 (sizeof (StunAttribute));
......@@ -81,7 +83,8 @@ stun_attribute_pack (StunAttribute *attr, gchar **packed)
gchar *
stun_attribute_dump (StunAttribute *attr)
{
switch (attr->type) {
switch (attr->type)
{
case STUN_ATTRIBUTE_MAPPED_ADDRESS:
return g_strdup_printf (
"MAPPED-ADDRESS %d.%d.%d.%d:%d",
......@@ -121,7 +124,8 @@ stun_message_free (StunMessage *msg)
{
StunAttribute **attr;
if (msg->attributes) {
if (msg->attributes)
{
for (attr = msg->attributes; *attr; attr++)
stun_attribute_free (*attr);
......@@ -152,7 +156,8 @@ stun_message_unpack (guint length, gchar *s)
/* count the number of attributes */
for (offset = 20; offset < length; offset += attr_length + 4) {
for (offset = 20; offset < length; offset += attr_length + 4)
{
attr_length = ntohs (*(guint16 *)(s + offset + 2));
n_attributes++;
}
......@@ -164,9 +169,11 @@ stun_message_unpack (guint length, gchar *s)
/* unpack attributes */
for (i = 0, offset = 20; i < n_attributes; i++, offset += attr_length + 4) {
for (i = 0, offset = 20; i < n_attributes; i++, offset += attr_length + 4)
{
attr_length = ntohs (*(guint16 *)(s + offset + 2));
attr = msg->attributes[i] = stun_attribute_unpack (attr_length, s + offset);
attr = msg->attributes[i] = stun_attribute_unpack (attr_length,
s + offset);
}
return msg;
......@@ -180,7 +187,8 @@ stun_message_pack (StunMessage *msg, gchar **packed)
guint16 packed_length;
guint length = 0;
if (msg->attributes) {
if (msg->attributes)
{
StunAttribute **attr;
for (attr = msg->attributes; *attr; attr++)
......@@ -197,10 +205,12 @@ stun_message_pack (StunMessage *msg, gchar **packed)
((gchar *) &packed_length)[1]);
g_string_append_len (tmp, msg->transaction_id, 16);
if (msg->attributes) {
if (msg->attributes)
{
StunAttribute **attr;
for (attr = msg->attributes; *attr; attr++) {
for (attr = msg->attributes; *attr; attr++)
{
gchar *attr_packed;
guint attr_length = stun_attribute_pack (*attr, &attr_packed);
g_string_append_len (tmp, attr_packed, attr_length);
......@@ -238,13 +248,13 @@ stun_message_dump (StunMessage *msg)
*(guint32 *)(msg->transaction_id + 8),
*(guint32 *)(msg->transaction_id + 12));
if (msg->attributes) {
for (attr = msg->attributes; *attr; attr++) {
if (msg->attributes)
for (attr = msg->attributes; *attr; attr++)
{
gchar *dump = stun_attribute_dump (*attr);
g_string_append_printf (tmp, "\n %s", dump);
g_free (dump);
}
}
return g_string_free (tmp, FALSE);
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment