~ubuntu-branches/ubuntu/utopic/gssdp/utopic-proposed

« back to all changes in this revision

Viewing changes to libgssdp/gssdp-socket-source.c

  • Committer: Package Import Robot
  • Author(s): Andreas Henriksson
  • Date: 2013-05-18 01:54:22 UTC
  • mfrom: (11.1.11 experimental)
  • Revision ID: package-import@ubuntu.com-20130518015422-0fipaueo681ygjz7
Tags: 0.14.2-2
Upload to unstable.

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
 *
21
21
 * You should have received a copy of the GNU Library General Public
22
22
 * License along with this library; if not, write to the
23
 
 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
24
 
 * Boston, MA 02111-1307, USA.
 
23
 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
 
24
 * Boston, MA 02110-1301, USA.
25
25
 */
26
26
 
27
27
#include <config.h>
47
47
        GSource              *source;
48
48
        GSocket              *socket;
49
49
        GSSDPSocketSourceType type;
 
50
 
50
51
        char                 *host_ip;
 
52
        guint                 ttl;
51
53
};
52
54
 
53
55
enum {
54
56
    PROP_0,
55
57
    PROP_TYPE,
56
 
    PROP_HOST_IP
 
58
    PROP_HOST_IP,
 
59
    PROP_TTL,
57
60
};
58
61
 
59
62
static void
108
111
        case PROP_HOST_IP:
109
112
                self->priv->host_ip = g_value_dup_string (value);
110
113
                break;
 
114
        case PROP_TTL:
 
115
                self->priv->ttl = g_value_get_uint (value);
 
116
                break;
111
117
        default:
112
118
                G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
113
119
                break;
122
128
GSSDPSocketSource *
123
129
gssdp_socket_source_new (GSSDPSocketSourceType type,
124
130
                         const char           *host_ip,
 
131
                         guint                 ttl,
125
132
                         GError              **error)
126
133
{
127
134
        return g_initable_new (GSSDP_TYPE_SOCKET_SOURCE,
131
138
                               type,
132
139
                               "host-ip",
133
140
                               host_ip,
 
141
                               "ttl",
 
142
                               ttl,
134
143
                               NULL);
135
144
}
136
145
 
198
207
        }
199
208
 
200
209
        /* TTL */
 
210
        if (!self->priv->ttl)
 
211
                /* UDA/1.0 says 4, UDA/1.1 says 2 */
 
212
                self->priv->ttl = 4;
 
213
 
201
214
        if (!gssdp_socket_set_ttl (self->priv->socket,
202
 
                                   4,
 
215
                                   self->priv->ttl,
203
216
                                   &inner_error)) {
204
217
                g_propagate_prefixed_error (error,
205
218
                                            inner_error,
206
 
                                            "Failed to set TTL");
 
219
                                            "Failed to set TTL to %u", self->priv->ttl);
207
220
 
208
221
                goto error;
209
222
        }
 
223
 
210
224
        /* Set up additional things according to the type of socket desired */
211
225
        if (self->priv->type == GSSDP_SOCKET_SOURCE_TYPE_MULTICAST) {
212
226
                /* Enable multicast loopback */
422
436
                         G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY |
423
437
                         G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK |
424
438
                         G_PARAM_STATIC_BLURB));
 
439
 
 
440
        g_object_class_install_property
 
441
                (object_class,
 
442
                 PROP_TTL,
 
443
                 g_param_spec_uint
 
444
                        ("ttl",
 
445
                         "TTL",
 
446
                         "Time To Live for the socket",
 
447
                         0, 255,
 
448
                         0,
 
449
                         G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY |
 
450
                         G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK |
 
451
                         G_PARAM_STATIC_BLURB));
425
452
}