Changeset 3227:9fc52b79b1b8 in roaraudio
- Timestamp:
- 01/24/10 08:36:57 (14 years ago)
- Branch:
- default
- Phase:
- public
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
libroar/auth.c
r3225 r3227 60 60 * Auth response: 61 61 * The same as the auth request. 62 * if the server sends an zero size message back it means the server accepted our connection 63 * and no additional stage is needed. 62 64 * if the message type is OK the server accepted our auth. 63 65 * if the message type is ERROR the server recjected us. we may try other auth methodes. … … 125 127 */ 126 128 129 static int roar_auth_ask_server (struct roar_connection * con, struct roar_auth_message * authmes) { 130 struct roar_message mes; 131 char * header = mes.data; 132 int ret; 133 134 memset(&mes, 0, sizeof(struct roar_message)); // make valgrind happy! 135 136 mes.cmd = ROAR_CMD_AUTH; 137 mes.datalen = 4; 138 139 header[0] = authmes->type; 140 header[1] = authmes->stage; 141 header[2] = authmes->reserved.c[0]; 142 header[3] = authmes->reserved.c[1]; 143 144 if ( (ret = roar_req(con, &mes, NULL)) == -1 ) 145 return -1; 146 147 if ( mes.datalen < 4 ) { 148 memset(header+mes.datalen, 0, 4-mes.datalen); 149 } 150 151 authmes->type = header[0]; 152 authmes->stage = header[1]; 153 authmes->reserved.c[0] = header[2]; 154 authmes->reserved.c[1] = header[3]; 155 156 return 0; 157 } 158 159 static void roar_auth_mes_init(struct roar_auth_message * authmes, int type) { 160 memset(authmes, 0, sizeof(struct roar_auth_message)); 161 162 authmes->type = type; 163 authmes->stage = 0; 164 authmes->data = NULL; 165 authmes->len = 0; 166 } 167 127 168 int roar_auth (struct roar_connection * con) { 128 struct roar_message mes; 129 130 memset(&mes, 0, sizeof(struct roar_message)); // make valgrind happy! 131 132 mes.cmd = ROAR_CMD_AUTH; 133 mes.datalen = 0; 134 135 return roar_req(con, &mes, NULL); 169 struct roar_auth_message authmes; 170 int ret; 171 172 roar_auth_mes_init(&authmes, ROAR_AUTH_T_NONE); 173 174 if ( (ret = roar_auth_ask_server(con, &authmes)) == -1 ) 175 return -1; 176 177 if ( authmes.stage != 0 ) 178 return -1; 179 180 return 0; 136 181 } 137 182
Note: See TracChangeset
for help on using the changeset viewer.