Add server side support for epmapper pipe. Currently only does a fixed
[samba.git] / source / rpc_server / srv_epmapper_nt.c
1
2 /* 
3    Unix SMB/CIFS implementation.
4    Samba end point mapper utility and mapping functions
5    Copyright (C) Jim McDonough (jmcd@us.ibm.com) 2003
6    
7    This program is free software; you can redistribute it and/or modify
8    it under the terms of the GNU General Public License as published by
9    the Free Software Foundation; either version 2 of the License, or
10    (at your option) any later version.
11    
12    This program is distributed in the hope that it will be useful,
13    but WITHOUT ANY WARRANTY; without even the implied warranty of
14    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15    GNU General Public License for more details.
16    
17    You should have received a copy of the GNU General Public License
18    along with this program; if not, write to the Free Software
19    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 */
21
22 #include "includes.h"
23
24 /*******************************************************************/
25 /*  _epm_map - fill out mapping on input and output structs */
26 /*******************************************************************/
27 void _epm_map(pipes_struct *ps, const EPM_Q_MAP *q_u, EPM_R_MAP *r_u)
28 {
29         int i;
30         uint8 target_address[] = { 9, 53, 95, 27 };
31         EPM_FLOOR *floors = talloc(ps->mem_ctx, sizeof(EPM_FLOOR) *
32                                    q_u->tower->num_floors);
33         EPM_TOWER *towers = talloc(ps->mem_ctx, 
34                                    sizeof(EPM_TOWER) * MAX_TOWERS);
35         EPM_TOWER_ARRAY array;
36
37         if (!floors || !towers) {
38                 DEBUG(0, ("_epm_map: talloc failed!\n"));
39                 return;
40         }
41
42         for (i = 0; i < q_u->tower->num_floors; i++) {
43                 switch (q_u->tower->floors[i].lhs.protocol) {
44                 case EPM_FLOOR_UUID:
45                         init_epm_floor_uuid(&floors[i],
46                                             &q_u->tower->floors[i].
47                                             lhs.uuid.uuid,
48                                             q_u->tower->floors[i].
49                                             lhs.uuid.version);
50                         break;
51                 case EPM_FLOOR_RPC:
52                         init_epm_floor_rpc(&floors[i]);
53                         break;
54                 case EPM_FLOOR_TCP:
55                         /* for now map all requests to port 135 */
56                         init_epm_floor_tcp(&floors[i], 135);
57                         break;
58                 case EPM_FLOOR_IP:
59                         init_epm_floor_ip(&floors[i], target_address);
60                         break;
61                 }
62         }
63
64         init_epm_tower(ps->mem_ctx, &towers[0], floors, 5);
65         init_epm_tower_array(ps->mem_ctx, &array, towers, 1);
66         init_epm_r_map(ps->mem_ctx, r_u, &q_u->term_handle, &array, 1, 0);
67
68         return;
69
70 }