Ignore:
Timestamp:
Nov 14, 2012, 12:59:34 PM (13 years ago)
Author:
Silvan Scherrer
Message:

Samba Server: update vendor to 3.6.0

Location:
vendor/current/source4/lib/socket
Files:
1 added
2 deleted
8 edited

Legend:

Unmodified
Added
Removed
  • vendor/current/source4/lib/socket/access.c

    r414 r740  
    3535#include "lib/socket/socket.h"
    3636#include "system/locale.h"
     37#include "lib/util/util_net.h"
    3738
    3839#define FAIL            (-1)
  • vendor/current/source4/lib/socket/connect_multi.c

    r414 r740  
    3434*/
    3535struct connect_multi_state {
    36         const char *server_address;
     36        struct socket_address *server_address;
    3737        int num_ports;
    3838        uint16_t *ports;
     
    6565_PUBLIC_ struct composite_context *socket_connect_multi_send(
    6666                                                    TALLOC_CTX *mem_ctx,
    67                                                     const char *server_address,
     67                                                    const char *server_name,
    6868                                                    int num_server_ports,
    6969                                                    uint16_t *server_ports,
     
    7575        int i;
    7676
     77        struct nbt_name name;
     78        struct composite_context *creq;
     79               
    7780        result = talloc_zero(mem_ctx, struct composite_context);
    7881        if (result == NULL) return NULL;
     
    8487        result->private_data = multi;
    8588
    86         multi->server_address = talloc_strdup(multi, server_address);
    87         if (composite_nomem(multi->server_address, result)) goto failed;
    88 
    8989        multi->num_ports = num_server_ports;
    9090        multi->ports = talloc_array(multi, uint16_t, multi->num_ports);
     
    9595        }
    9696
    97         if (!is_ipaddress(server_address)) {
    98                 /* 
    99                     we don't want to do the name resolution separately
     97        /* 
     98            we don't want to do the name resolution separately
    10099                    for each port, so start it now, then only start on
    101100                    the real sockets once we have an IP
    102                  */
    103                 struct nbt_name name;
    104                 struct composite_context *creq;
    105                 make_nbt_name_server(&name, server_address);
    106                 creq = resolve_name_send(resolve_ctx, multi, &name, result->event_ctx);
    107                 if (composite_nomem(creq, result)) goto failed;
    108                 composite_continue(result, creq, continue_resolve_name, result);
    109                 return result;
    110         }
    111 
    112         /* now we've setup the state we can process the first socket */
    113         connect_multi_next_socket(result);
    114 
    115         if (!NT_STATUS_IS_OK(result->status)) {
    116                 goto failed;
    117         }
     101        */
     102        make_nbt_name_server(&name, server_name);
     103
     104        creq = resolve_name_all_send(resolve_ctx, multi, 0, multi->ports[0], &name, result->event_ctx);
     105        if (composite_nomem(creq, result)) goto failed;
     106
     107        composite_continue(result, creq, continue_resolve_name, result);
    118108
    119109        return result;
     110
    120111
    121112 failed:
     
    149140        if (!composite_is_ok(result)) return;
    150141
    151         /* Form up the particular address we are interested in */
    152         state->addr = socket_address_from_strings(state, state->sock->backend_name,
    153                                                   multi->server_address, multi->ports[next]);
     142        state->addr = socket_address_copy(state, multi->server_address);
    154143        if (composite_nomem(state->addr, result)) return;
     144
     145        socket_address_set_port(state->addr, multi->ports[next]);
    155146
    156147        talloc_steal(state, state->sock);
     
    198189        struct connect_multi_state *multi = talloc_get_type(result->private_data,
    199190                                                            struct connect_multi_state);
    200         const char *addr;
    201 
    202         result->status = resolve_name_recv(creq, multi, &addr);
     191        struct socket_address **addr;
     192
     193        result->status = resolve_name_all_recv(creq, multi, &addr, NULL);
    203194        if (!composite_is_ok(result)) return;
    204195
    205         multi->server_address = addr;
     196        /* Let's just go for the first for now */
     197        multi->server_address = addr[0];
    206198
    207199        connect_multi_next_socket(result);
  • vendor/current/source4/lib/socket/interface.c

    r414 r740  
    2323#include "system/network.h"
    2424#include "lib/socket/netif.h"
     25#include "../lib/util/util_net.h"
    2526#include "../lib/util/dlinklist.h"
    2627
     
    9495        DLIST_ADD_END(*interfaces, iface, struct interface *);
    9596
    96         DEBUG(2,("added interface ip=%s nmask=%s\n", iface->ip_s, iface->nmask_s));
     97        DEBUG(3,("added interface ip=%s nmask=%s\n", iface->ip_s, iface->nmask_s));
    9798}
    9899
  • vendor/current/source4/lib/socket/netif.c

    r414 r740  
    3535#include "system/network.h"
    3636#include "netif.h"
     37#include "lib/util/tsort.h"
    3738
    3839/****************************************************************************
     
    110111
    111112        /* now we need to remove duplicates */
    112         qsort(ifaces, total, sizeof(ifaces[0]), QSORT_CAST iface_comp);
     113        TYPESAFE_QSORT(ifaces, total, iface_comp);
    113114
    114115        for (i=1;i<total;) {
  • vendor/current/source4/lib/socket/socket.c

    r414 r740  
    2525#include "system/network.h"
    2626#include "param/param.h"
     27#include "../lib/tsocket/tsocket.h"
     28#include "lib/util/util_net.h"
    2729
    2830/*
     
    343345
    344346        return sock->ops->fn_get_my_addr(sock, mem_ctx);
     347}
     348
     349_PUBLIC_ struct tsocket_address *socket_address_to_tsocket_address(TALLOC_CTX *mem_ctx,
     350                                                                   const struct socket_address *a)
     351{
     352        struct tsocket_address *r;
     353        int ret;
     354
     355        if (a->sockaddr) {
     356                ret = tsocket_address_bsd_from_sockaddr(mem_ctx,
     357                                                        a->sockaddr,
     358                                                        a->sockaddrlen,
     359                                                        &r);
     360        } else {
     361                ret = tsocket_address_inet_from_strings(mem_ctx,
     362                                                        a->family,
     363                                                        a->addr,
     364                                                        a->port,
     365                                                        &r);
     366        }
     367
     368        if (ret != 0) {
     369                return NULL;
     370        }
     371
     372        return r;
     373}
     374
     375_PUBLIC_ void socket_address_set_port(struct socket_address *a,
     376                                      uint16_t port)
     377{
     378        if (a->sockaddr) {
     379                set_sockaddr_port(a->sockaddr, port);
     380        } else {
     381                a->port = port;
     382        }
     383
     384}
     385
     386_PUBLIC_ struct socket_address *tsocket_address_to_socket_address(TALLOC_CTX *mem_ctx,
     387                                                                  const struct tsocket_address *a)
     388{
     389        ssize_t ret;
     390        struct sockaddr_storage ss;
     391        size_t sslen = sizeof(ss);
     392
     393        ret = tsocket_address_bsd_sockaddr(a, (struct sockaddr *)(void *)&ss, sslen);
     394        if (ret < 0) {
     395                return NULL;
     396        }
     397
     398        return socket_address_from_sockaddr(mem_ctx, (struct sockaddr *)(void *)&ss, ret);
     399}
     400
     401_PUBLIC_ struct tsocket_address *socket_get_remote_addr(struct socket_context *sock, TALLOC_CTX *mem_ctx)
     402{
     403        struct socket_address *a;
     404        struct tsocket_address *r;
     405
     406        a = socket_get_peer_addr(sock, mem_ctx);
     407        if (a == NULL) {
     408                return NULL;
     409        }
     410
     411        r = socket_address_to_tsocket_address(mem_ctx, a);
     412        talloc_free(a);
     413        return r;
     414}
     415
     416_PUBLIC_ struct tsocket_address *socket_get_local_addr(struct socket_context *sock, TALLOC_CTX *mem_ctx)
     417{
     418        struct socket_address *a;
     419        struct tsocket_address *r;
     420
     421        a = socket_get_my_addr(sock, mem_ctx);
     422        if (a == NULL) {
     423                return NULL;
     424        }
     425
     426        r = socket_address_to_tsocket_address(mem_ctx, a);
     427        talloc_free(a);
     428        return r;
    345429}
    346430
  • vendor/current/source4/lib/socket/socket.h

    r414 r740  
    128128
    129129struct resolve_context;
     130struct tsocket_address;
    130131
    131132/* prototypes */
     
    159160struct socket_address *socket_get_peer_addr(struct socket_context *sock, TALLOC_CTX *mem_ctx);
    160161struct socket_address *socket_get_my_addr(struct socket_context *sock, TALLOC_CTX *mem_ctx);
     162struct tsocket_address *socket_address_to_tsocket_address(TALLOC_CTX *mem_ctx,
     163                                                          const struct socket_address *a);
     164struct socket_address *tsocket_address_to_socket_address(TALLOC_CTX *mem_ctx,
     165                                                         const struct tsocket_address *a);
     166struct tsocket_address *socket_get_remote_addr(struct socket_context *sock, TALLOC_CTX *mem_ctx);
     167struct tsocket_address *socket_get_local_addr(struct socket_context *sock, TALLOC_CTX *mem_ctx);
    161168int socket_get_fd(struct socket_context *sock);
    162169NTSTATUS socket_dup(struct socket_context *sock);
     
    168175                                                    struct sockaddr *sockaddr,
    169176                                                    size_t addrlen);
     177_PUBLIC_ void socket_address_set_port(struct socket_address *a,
     178                                      uint16_t port);
    170179struct socket_address *socket_address_copy(TALLOC_CTX *mem_ctx,
    171180                                           const struct socket_address *oaddr);
     
    207216                              uint16_t *port);
    208217void set_socket_options(int fd, const char *options);
    209 void socket_set_flags(struct socket_context *socket, unsigned flags);
     218void socket_set_flags(struct socket_context *sock, unsigned flags);
    210219
    211220void socket_tevent_fd_close_fn(struct tevent_context *ev,
  • vendor/current/source4/lib/socket/socket_ip.c

    r414 r740  
    2626#include "lib/socket/socket.h"
    2727#include "system/network.h"
     28#include "lib/util/util_net.h"
    2829
    2930static NTSTATUS ipv4_init(struct socket_context *sock)
     
    712713static NTSTATUS ipv6_tcp_accept(struct socket_context *sock, struct socket_context **new_sock)
    713714{
    714         struct sockaddr_in cli_addr;
     715        struct sockaddr_in6 cli_addr;
    715716        socklen_t cli_addr_len = sizeof(cli_addr);
    716717        int new_fd;
  • vendor/current/source4/lib/socket/testsuite.c

    r414 r740  
    4343        struct interface *ifaces;
    4444
    45         load_interfaces(tctx, lp_interfaces(tctx->lp_ctx), &ifaces);
     45        load_interfaces(tctx, lpcfg_interfaces(tctx->lp_ctx), &ifaces);
    4646
    4747        status = socket_create("ip", SOCKET_TYPE_DGRAM, &sock1, 0);
     
    136136        talloc_steal(mem_ctx, sock2);
    137137
    138         load_interfaces(tctx, lp_interfaces(tctx->lp_ctx), &ifaces);
     138        load_interfaces(tctx, lpcfg_interfaces(tctx->lp_ctx), &ifaces);
    139139        localhost = socket_address_from_strings(sock1, sock1->backend_name,
    140140                                                iface_best_ip(ifaces, "127.0.0.1"), 0);
     
    189189struct torture_suite *torture_local_socket(TALLOC_CTX *mem_ctx)
    190190{
    191         struct torture_suite *suite = torture_suite_create(mem_ctx,
    192                                                                                                            "SOCKET");
     191        struct torture_suite *suite = torture_suite_create(mem_ctx, "socket");
    193192
    194193        torture_suite_add_simple_test(suite, "udp", test_udp);
Note: See TracChangeset for help on using the changeset viewer.